FORTRAN NAMELIST Run Time Problem: Bug Report
slabiv@chan.usno.navy.mil
slabiv@chan.usno.navy.mil
Tue Aug 7 21:20:00 GMT 2007
To the Project:
I am not sure how to make a bug report that includes the files given
here as attachments:
namelist.let Describes the problem.
namelist.f FORTRAN source code for short program that reproduces the
problem.
namelist.in Input file with namelists for the test program.
namelist.out Annotated output file showing the output from program
compiled using gfortran (gives run time errors) and g77
(no run time errors).
I have checked the bug reports on the gcc.gnu.org website and found
no real examples of namelist bugs, so I submit this report.
Please advise me on how to do this. I registered my Email address
with bugzilla and received a password.
Victor J. Slabinski
-------------- next part --------------
FORTRAN NAMELIST Run Time Problem
The FORTRAN statement
READ(5, nml=CODE)
should read through the input file (connected to device number 5)
until it finds a namelist with the name 'CODE', and then read/process
that one namelist. On the next call to this read statement, the
program should read further into the input file to find the next
occurrence of the name 'CODE'.
This was the behaviour from the IBM and HP FORTRAN 77 compilers.
It is also the behaviour from the open source g77 compiler. A namelist
with name 'CODEone', 'CODEtwo', or 'CODEx' is treated as having a
different name, on the basis that the name ends at the trailing
'space' delimiter.
A gfortran compiled program appears to read these names and
conclude that since the first four letters match the requested name
'CODE', it has found the requested namelist. The program then treats
the remaining letters in the name as a variable name and complains
that 'one' and 'two' are not defined variables for this namelist.
In the case of reading the name 'CODEx', the gfortran program treats
the x as a variable name that it recognizes as a valid variable, but
complains that it is not followed by an equal sign.
It appears that the compiled program needs to read the whole
namelist name (up to the delimiting space) and then ask if this name
matches the request in the READ statement.
I include a short FORTRAN program 'namelist.f' that illustrates
the problem when used with the supplied input file 'namelist.in' .
The annotated output file 'namelist.out' gives the output (with errors)
I found using gfortran and g77 compilers. The problem occurs using
gcc-gfortran - 4.1.2-13.fc6.x86_64
libgfortran - 4.1.2-13.fc6.x86_64
running under Linux (Red Hat Fedora Core 6) and
gcc-gfortran - 4.1.2-12.i386
libgfortran - 4.1.2-12.i386
running under Linux (Red Hat Fedora Core 7).
Victor J. Slabinski
-------------- next part --------------
C********1*********2*********3*********4*********5*********6*********7**
C Test of namelist operation in Linux gfortran compiled program:
C Does the "namelist read" skip over namelists with other names or
C similar names?
PROGRAM namelist
CHARACTER*25 CHAR
NAMELIST /CODE/ CHAR, X
NAMELIST /CODEtwo/ X
C
OPEN(5, file='namelist.in')
100 CHAR = 'Initialize string ***'
X = -777.
READ(5, nml=CODE, END=999)
WRITE(6,*) CHAR, X
GO TO 100
999 STOP 'namelist'
END PROGRAM namelist
-------------- next part --------------
File namelist.in with test NAMELIST inputs
&CODVJS char='VJS-Not a proper nml name', X=-0.5/
&CODEone char='CODEone input', X=-1.0 /
&CODEtwo char='CODEtwo inputs', X=-2.0/
&code char='Improper lower case name',X=-3.0/
&CODE char='Desired namelist sel', X=44./
&CODEx char='Should not read CODEx nml', X=-5./
$CODE char='Second desired nml', X=66.0 /
$CODE X=77.0, char='Reordered desired nml'/
-------------- next part --------------
Program output from NAMELIST reads with added, interpretive comments;
call on FORTRAN compiler also listed.
*************************************************************************
FORTRAN compiler call:
gfortran namelist.f -o namelist
Output from executing program 'namelist':
Cannot match namelist object name one !variable name 'one' is actually
part of nml name CODEone
CODEone input -1.000000 !output for namelist read that
should not have occurred
Cannot match namelist object name two !variable name 'two' is actually
part of nml name CODEtwo
CODEtwo inputs -2.000000 !output for namelist read that
should not have occurred
Improper lower case name -3.000000 !shows that nml name upper/lower
case does not matter
Desired namelist sel 44.00000
Equal sign must follow namelist object name x !variable name 'x' is
actually part of nml
name CODEx
Cannot match namelist object name har !words in nml string
namelist read: missplaced = sign !variable are now
Cannot match namelist object name should !treated as variable
Cannot match namelist object name not !names
Cannot match namelist object name read
Cannot match namelist object name codex
Cannot match namelist object name nml',
Initialize string *** -5.000000 !output for namelist read that
should not have occurred; note
that string variable 'char' never
changed value after initialization
Second desired nml 66.00000 !Note that input used '$' here, not
Reordered desired nml 77.00000 !standard '&', in front of nml name
STOP namelist
*************************************************************************
FORTRAN compiler call:
g77 namelist.f -o namelist77
Output from executing program 'namelist77' SHOWS CORRECT OPERATION HERE:
[Note that "Skipping namelist" warning messages are not really necessary.]
Skipping namelist "CODVJS": seeking namelist "CODE".
Skipping namelist "CODEONE": seeking namelist "CODE".
Skipping namelist "CODETWO": seeking namelist "CODE".
Improper lower case name -3.
Desired namelist sel 44.
Skipping namelist "CODEX": seeking namelist "CODE".
Second desired nml 66. !Note that input used '$' here, not
Reordered desired nml 77. !standard '&', in front of nml name
STOP namelist statement executed
EOF****************************
More information about the Fortran
mailing list