public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/33039]  New: Read NAMELIST:  reads wrong namelist name
@ 2007-08-09 16:41 slabinski dot victor at usno dot navy dot mil
  2007-08-09 18:40 ` [Bug fortran/33039] " burnus at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: slabinski dot victor at usno dot navy dot mil @ 2007-08-09 16:41 UTC (permalink / raw)
  To: gcc-bugs

This has probably already been submitted by Daniel Franke or Jerry DeLisle.
I am just trying to see if I can work this system.


             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

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?                                             namelist.f
      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 Itest = 95
      write(6,*) 'Itest=',Itest
      call exit(Itest)
      STOP 'namelist'
      END PROGRAM namelist

****************************************************************
   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'/

**********************************************************************
Program output from NAMELIST reads with added, interpretive comments;
call on FORTRAN compiler also listed.                     namelist.out

**************************************
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".

EOF


-- 
           Summary: Read NAMELIST:  reads wrong namelist name
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: slabinski dot victor at usno dot navy dot mil


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33039


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/33039] Read NAMELIST:  reads wrong namelist name
  2007-08-09 16:41 [Bug fortran/33039] New: Read NAMELIST: reads wrong namelist name slabinski dot victor at usno dot navy dot mil
@ 2007-08-09 18:40 ` burnus at gcc dot gnu dot org
  2007-08-09 23:27 ` jvdelisle at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-08-09 18:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from burnus at gcc dot gnu dot org  2007-08-09 18:39 -------
I think this is a duplicate of PR 33019.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33039


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/33039] Read NAMELIST:  reads wrong namelist name
  2007-08-09 16:41 [Bug fortran/33039] New: Read NAMELIST: reads wrong namelist name slabinski dot victor at usno dot navy dot mil
  2007-08-09 18:40 ` [Bug fortran/33039] " burnus at gcc dot gnu dot org
@ 2007-08-09 23:27 ` jvdelisle at gcc dot gnu dot org
  2007-08-09 23:37 ` jvdelisle at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-08-09 23:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jvdelisle at gcc dot gnu dot org  2007-08-09 23:27 -------
Regarding the test case: 

&code    char='Improper lower case name',X=-3.0/

Fortran 95 Standard 10.9.1 states:

"If a processor is capable of representing letters in both upper and lower
case, a group name or object name is without regard to case. "

So lower case is not improper.

The standard also states that at least one space is required after the namelist
name.  This patch fixes it:

Index: list_read.c
===================================================================
--- list_read.c (revision 127265)
+++ list_read.c (working copy)
@@ -2592,6 +2592,13 @@ find_nml_name:

   if (dtp->u.p.nml_read_error)
     goto find_nml_name;
+  
+  c = next_char (dtp);
+  if (c != ' ')
+    {
+      unget_char (dtp, c);
+      goto find_nml_name;
+    }




-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33039


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/33039] Read NAMELIST:  reads wrong namelist name
  2007-08-09 16:41 [Bug fortran/33039] New: Read NAMELIST: reads wrong namelist name slabinski dot victor at usno dot navy dot mil
  2007-08-09 18:40 ` [Bug fortran/33039] " burnus at gcc dot gnu dot org
  2007-08-09 23:27 ` jvdelisle at gcc dot gnu dot org
@ 2007-08-09 23:37 ` jvdelisle at gcc dot gnu dot org
  2007-08-09 23:38 ` jvdelisle at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-08-09 23:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from jvdelisle at gcc dot gnu dot org  2007-08-09 23:37 -------
*** Bug 33019 has been marked as a duplicate of this bug. ***


-- 

jvdelisle at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jvdelisle at gcc dot gnu dot
                   |                            |org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33039


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/33039] Read NAMELIST:  reads wrong namelist name
  2007-08-09 16:41 [Bug fortran/33039] New: Read NAMELIST: reads wrong namelist name slabinski dot victor at usno dot navy dot mil
                   ` (2 preceding siblings ...)
  2007-08-09 23:37 ` jvdelisle at gcc dot gnu dot org
@ 2007-08-09 23:38 ` jvdelisle at gcc dot gnu dot org
  2007-08-10  5:40 ` patchapp at dberlin dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-08-09 23:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jvdelisle at gcc dot gnu dot org  2007-08-09 23:38 -------
This report is better than my own. :)


-- 

jvdelisle at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jvdelisle at gcc dot gnu dot
                   |dot org                     |org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-08-09 23:38:27
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33039


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/33039] Read NAMELIST:  reads wrong namelist name
  2007-08-09 16:41 [Bug fortran/33039] New: Read NAMELIST: reads wrong namelist name slabinski dot victor at usno dot navy dot mil
                   ` (3 preceding siblings ...)
  2007-08-09 23:38 ` jvdelisle at gcc dot gnu dot org
@ 2007-08-10  5:40 ` patchapp at dberlin dot org
  2007-08-10 12:36 ` jvdelisle at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: patchapp at dberlin dot org @ 2007-08-10  5:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from patchapp at dberlin dot org  2007-08-10 05:40 -------
Subject: Bug number PR33039

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2007-08/msg00643.html


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33039


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/33039] Read NAMELIST:  reads wrong namelist name
  2007-08-09 16:41 [Bug fortran/33039] New: Read NAMELIST: reads wrong namelist name slabinski dot victor at usno dot navy dot mil
                   ` (4 preceding siblings ...)
  2007-08-10  5:40 ` patchapp at dberlin dot org
@ 2007-08-10 12:36 ` jvdelisle at gcc dot gnu dot org
  2007-08-10 12:40 ` jvdelisle at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-08-10 12:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jvdelisle at gcc dot gnu dot org  2007-08-10 12:36 -------
Subject: Bug 33039

Author: jvdelisle
Date: Fri Aug 10 12:36:01 2007
New Revision: 127332

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=127332
Log:
2007-08-10  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

        PR libfortran/33039
        * io/list_read.c (find_nml_name): Check for a space after a namelist
        name match.

Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/io/list_read.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33039


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/33039] Read NAMELIST:  reads wrong namelist name
  2007-08-09 16:41 [Bug fortran/33039] New: Read NAMELIST: reads wrong namelist name slabinski dot victor at usno dot navy dot mil
                   ` (5 preceding siblings ...)
  2007-08-10 12:36 ` jvdelisle at gcc dot gnu dot org
@ 2007-08-10 12:40 ` jvdelisle at gcc dot gnu dot org
  2007-08-10 12:43 ` jvdelisle at gcc dot gnu dot org
  2007-08-14 13:45 ` fxcoudert at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-08-10 12:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jvdelisle at gcc dot gnu dot org  2007-08-10 12:40 -------
Subject: Bug 33039

Author: jvdelisle
Date: Fri Aug 10 12:39:46 2007
New Revision: 127333

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=127333
Log:
2007-08-10  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

        PR libfortran/33039
        * gfortran.dg/namelist_37.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/namelist_37.f90
Modified:
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33039


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/33039] Read NAMELIST:  reads wrong namelist name
  2007-08-09 16:41 [Bug fortran/33039] New: Read NAMELIST: reads wrong namelist name slabinski dot victor at usno dot navy dot mil
                   ` (6 preceding siblings ...)
  2007-08-10 12:40 ` jvdelisle at gcc dot gnu dot org
@ 2007-08-10 12:43 ` jvdelisle at gcc dot gnu dot org
  2007-08-14 13:45 ` fxcoudert at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-08-10 12:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from jvdelisle at gcc dot gnu dot org  2007-08-10 12:43 -------
Fixed on 4.3


-- 

jvdelisle at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33039


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/33039] Read NAMELIST:  reads wrong namelist name
  2007-08-09 16:41 [Bug fortran/33039] New: Read NAMELIST: reads wrong namelist name slabinski dot victor at usno dot navy dot mil
                   ` (7 preceding siblings ...)
  2007-08-10 12:43 ` jvdelisle at gcc dot gnu dot org
@ 2007-08-14 13:45 ` fxcoudert at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-08-14 13:45 UTC (permalink / raw)
  To: gcc-bugs



-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.3.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33039


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2007-08-14 13:45 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-09 16:41 [Bug fortran/33039] New: Read NAMELIST: reads wrong namelist name slabinski dot victor at usno dot navy dot mil
2007-08-09 18:40 ` [Bug fortran/33039] " burnus at gcc dot gnu dot org
2007-08-09 23:27 ` jvdelisle at gcc dot gnu dot org
2007-08-09 23:37 ` jvdelisle at gcc dot gnu dot org
2007-08-09 23:38 ` jvdelisle at gcc dot gnu dot org
2007-08-10  5:40 ` patchapp at dberlin dot org
2007-08-10 12:36 ` jvdelisle at gcc dot gnu dot org
2007-08-10 12:40 ` jvdelisle at gcc dot gnu dot org
2007-08-10 12:43 ` jvdelisle at gcc dot gnu dot org
2007-08-14 13:45 ` fxcoudert at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).