user3197390
user3197390

Reputation: 13

Bad value during floating point read in Fortran

I am trying to read data from .wve file. 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"

And óji.wve' looks like this:

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)"

I've tried different modifications of the code but didn't get any result. Any help would be greatly appreciated!

Upvotes: 0

Views: 8240

Answers (1)

chw21
chw21

Reputation: 8140

Format (F10.5) means 10 characters per input. But your file has 11 characters per number. So for the 5th number, it tries to get 9 -5.641 which it can't interpret.

-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

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

Upvotes: 2

Related Questions