'Fortran runtime error: Bad value during floating point read (f7.0)
I am trying to execute a Fortran code and I get the following error:
At line 215 of file prepmegan4cmaq_grwform.f90 Fortran runtime error: Bad value during floating point read
And this is how the line 215 of my .f90 file looks like:
read(shrubfillvalue,"(f7.0)") missing_value
I do not have any experience with Fortran coding, can someone please tell me what it means and how I can fix this problem. Thank you in advance
Solution 1:[1]
This error is telling you that the text it tried to read did not meet the rules for a numeric value. The code itself is fine, the error is in the input (which you did not show).
The F7.0 format will accept seven characters that are valid as a number, for example: -1234.5, 2478bbb, 3.15E24, etc. (where "b" means blank). So, look at the input file and see what is in that line.
It is possible that the program is reading the wrong line from the file after having read an incorrect number of lines previously.
Solution 2:[2]
I have also been running the latest version of MEGANv3.2, and found this to be an issue with reading missing_value attribute in 3 out of 4 of the input files provided by the MEGAN team.
Since all of the missing_value attributes are the same between the four different files (i.e., -128), a very quick work around is to simply change the prepmegan4cmaq_grwform.f90 code to read only the treefillvalue for each of the four datasets:
!-----read growth form----------------------------------------------
scale_factor = 1.
inpname = trim(treefilename)
varname = trim(treevarname)
!missing_value = -1.
read(treefillvalue,"(f7.0)") missing_value
CALL megan2_bioemiss
inpname = trim(shrubfilename)
varname = trim(shrubvarname)
! read(shrubfillvalue,"(f7.0)") missing_value
read(treefillvalue,"(f7.0)") missing_value
CALL megan2_bioemiss
inpname = trim(cropfilename)
varname = trim(cropvarname)
! read(cropfillvalue,"(f7.0)") missing_value
read(treefillvalue,"(f7.0)") missing_value
CALL megan2_bioemiss
inpname = trim(grassfilename)
varname = trim(grassvarname)
! read(grassfillvalue,"(f7.0)") missing_value
read(treefillvalue,"(f7.0)") missing_value
CALL megan2_bioemiss
! endif
And then simply recompile the prepmegan4cmaq_grwform.f90 code. Hope this helps.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Steve Lionel |
| Solution 2 | Patrick Campbell |
