FORTRAN IV DATA statements
Stephan Buchert
scb@irfu.se
Wed Sep 2 12:12:00 GMT 2009
Thanks for all the answers. I have modified my copy of the NRLMSISE-00
Fortran code, such that gfortran compiles it. And I can inform the
maintainers of the MSIS model about the problem. The code is actively
used by perhaps 100-1000 people in the world (eg to model air drag on
space craft, radiation levels from cosmic radiation, and electrical
currents in the ionosphere). It was last updated in 2004, but offending
lines were probably there in previous versions as well. Google does not
bring up any other user complaints about the code, neither have I heard
of any. So most FORTRAN compilers seem to compile the code, or so far
all the affected users have fixed the issue silently for themselves.
As it was noted in some of the answers the lines
COMMON/DATIME/ISDATE(3),ISTIME(2),NAME(2)
DATA ISDATE/'01-F','EB-0','2 '/,ISTIME/'15:4','9:27'/
make use of literal constants, enclosed in apostrophes, which is a
feature in FORTRAN IV, a standard by IBM:
http://www.fh-jena.de/~kleine/history/languages/GC28-6515-10-FORTRAN-IV-Language.pdf
If I change the lines to
COMMON/DATIME/ISDATE(3),ISTIME(2),NAME(2)
DATA ISDATE/4H01-F,4HEB-0,4H2 /,ISTIME/4H15:4,4H9:27/
which is valid FORTRAN 66 with Hollerith constants, but invalid FORTRAN
77 because of the incompatible types, then gfortran does indeed compile
the code with warnings like
DATA ISDATE/4H01-F,4HEB-0,4H2 /,ISTIME/4H15:4,4H9:27/
1
Warning: Extension: Conversion from HOLLERITH to INTEGER(4) at (1)
If I use gfortran -std=legacy ... then compilation is without the
warning.
So with respect to ANSI Fortran standards, gfortran seems to do the
right things: refusing the original lines as invalid FORTRAN 77 but
accepting FORTRAN 66 where there is no requirement that types in data
statements are compatible.
However, in this case the original lines are really meant to be FORTRAN
66 with extensions, i.e. FORTRAN IV. From my viewpoint it would be good
if the extensions of FORTRAN IV to FORTRAN 66 were also allowed with
the "legacy" switch.
--
Stephan Buchert <scb@irfu.se>
Swedish Institute of Space Physics
More information about the Fortran
mailing list