简体   繁体   English

在Fortran中读取浮点时的值错误

[英]Bad value during floating point read in Fortran

I am trying to read data from .wve file. 我正在尝试从.wve文件读取数据。 But there is some error which i could not found. 但是有一些我找不到的错误。

This is error message: "At line 84 of file arbitime_T16_parts.for (unit = 30, file = 'oji.wve') Fortran runtime error: Bad value during floating point read" 这是错误消息:“在文件arbitime_T16_parts.for的第84行(单位= 30,文件='oji.wve')Fortran运行时错误:浮点读取期间值错误”

And óji.wve' looks like this: óji.wve看起来像这样:

29981    .0100 1.0
-5.63983   -5.64221   -5.64460   -5.63959   -5.64150   -5.65437   -5.65652   -5.64579
-5.64102   -5.64150   -5.63983   -5.62433   -5.62695   -5.62934   -5.63649   -5.63363
-5.63625   -5.63673   -5.62958   -5.64341   -5.64984   -5.63601   -5.63601   -5.64436
-5.63721   -5.64436   -5.64245   -5.64412   -5.64650   -5.66176   -5.65294   -5.64054
-5.63888   -5.63578   -5.63721   -5.63959   -5.64531   -5.64460   -5.63911   -5.64007
-5.63840   -5.63816   -5.64174   -5.63411   -5.63053   -5.63578   -5.64269   -5.64293
-5.64770   -5.64698   -5.64078   -5.62362   -5.62982   -5.63578   -5.63649   -5.64388
-5.64221   -5.64150   -5.64460   -5.65008   -5.64698   -5.64555   -5.63864   -5.63458
-5.63673   -5.63888   -5.63482   -5.63649   -5.64221   -5.63792   -5.62672   -5.63172
-5.64531   -5.65080   -5.64388   -5.64174   -5.64007   -5.65032   -5.65533   -5.65747
-5.64817   -5.63244   -5.62910   -5.63554   -5.64364   -5.64603   -5.63530   -5.63530
.....................................................................

And program : 和程序:

 C     READ EARTHQUAKE DATA
 C
       READ(30,*) NEND,DT,GAL
       WRITE(6,*) NEND,DT,GAL
       READ(30,2222) (Z(JJ),JJ=1,NEND)
  2222 FORMAT(8F10.5)
       CLOSE(30)

Line 84 is "READ(30,2222) (Z(JJ),JJ=1,NEND)" 第84行是“ READ(30,2222)(Z(JJ),JJ = 1,NEND)”

I've tried different modifications of the code but didn't get any result. 我尝试对代码进行不同的修改,但没有得到任何结果。 Any help would be greatly appreciated! 任何帮助将不胜感激!

Format (F10.5) means 10 characters per input. 格式(F10.5)表示每个输入10个字符。 But your file has 11 characters per number. 但是您的文件每个数字有11个字符。 So for the 5th number, it tries to get 9 -5.641 which it can't interpret. 因此,对于第5个数字,它尝试获得9 -5.641 ,它无法解释。

-5.63983   -5.64221   -5.64460   -5.63959   -5.64150   -5.65437   -5.65652   -5.64579
|--- 1---||--- 2---||--- 3---||--- 4---||--- 5---||--- 6---||--- 7---||--- 8---|

The easiest solution is to change 最简单的解决方案是更改

 2222 FORMAT(8F10.5)

into one of these two options: 进入以下两个选项之一:

 2222 FORMAT(8F11.5)
 2222 FORMAT(8(F10.5,X))

Or you can take the FORMAT statement out completely, and just type 或者您可以完全取出FORMAT语句,然后键入

READ(30, *) (Z(JJ),JJ=1,NEND)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM