Bug 36676 - Namelist Comments Problems
Summary: Namelist Comments Problems
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: ---
Assignee: Jerry DeLisle
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-30 15:44 UTC by Matthew Norman
Modified: 2008-07-02 05:15 UTC (History)
2 users (show)

See Also:
Host: powerpc-apple-darwin9
Target: powerpc-apple-darwin9
Build: powerpc-apple-darwin9
Known to work:
Known to fail:
Last reconfirmed: 2008-06-30 17:56:50


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Norman 2008-06-30 15:44:02 UTC
I'm having a failure on reading in a namelist in gfortran. The version information is below:

bash-3.2$ gfortran -v
Using built-in specs.
Target: powerpc-apple-darwin9.3.0
Configured with: /var/tmp/gfortran-20080530/ibin/../gcc/configure --prefix=/usr/local/gfortran --enable-languages=c,fortran --with-gmp=/var/tmp/gfortran-20080530/gfortran_libs --enable-bootstrap --with-included-gettext
Thread model: posix
gcc version 4.4.0 20080530 (experimental) [trunk revision 136204] (GCC)


What's happening is I have a namelist which begins with:

&INPUT

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!! DOMAIN AND INITIAL PARAMS !!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

nxc = 100,                  !Number of cells




And when it reads in, I get the following error:
bash-3.2$ ./Transport1D
At line 42 of file /Users/rossnorm/NCAR08/1D/src/mem_nml.f90 (unit = 101, file = 'Transport1D.namelist')
Fortran runtime error: Cannot match namelist object name !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!nxc




However, if I change the beginning of the namelist to the following:
&INPUT

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!! DOMAIN AND INITIAL PARAMS !!!!!!!!!!!!!!!!!!!!!!!!!!

nxc = 100,                  !Number of cells



the whole namelist is read in fine, and the correct values can be printed back out to stdout internally. So, that last line of "!!!!!" is for some reason causing a failure in the gfortran namelist reading routines when I do not believe there should be any hinderance according to the standards. Just in case you want my code to read in the namelist and the entire namelist itself (the namelist which failed), it is below. In the module mem_nml.f90, the subroutine readNamelist() is what reads in the values.





mem_nml.f90
!Module to read input parameters for a 1D transport
!simulation. The file must be 'Transport1D.namelist'

module mem_nml
    implicit none
    integer, save :: nxc
    double precision, save :: dleft
    double precision, save :: dright
    integer, save :: init_type
    double precision, save :: dt
    double precision, save :: max_courant
    double precision, save :: sim_time
    integer, save :: time_method
    integer, save :: sd_timesolver
    integer, save :: subgrid_approx
    integer, save :: linear_lim
    integer, save :: ppm_filter
    logical, save :: pd_filter
    character*100,save :: outfile_prefix
    
    contains
    
    subroutine readNamelist()
        implicit none
        
        namelist /INPUT/    nxc,            &
                            dleft,          &
                            dright,         &
                            init_type,      &
                            dt,             &
                            max_courant,    &
                            sim_time,       &
                            time_method,    &
                            sd_timesolver,  &
                            subgrid_approx, &
                            linear_lim,     &
                            ppm_filter,     &
                            pd_filter,      &
                            outfile_prefix
        
        open(unit = 101, file = 'Transport1D.namelist', action = 'read')
        read(unit = 101, nml = INPUT)
        close(unit = 101)
        
    endsubroutine
    
endmodule mem_nml















Transport1D.namelist
&INPUT

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!! DOMAIN AND INITIAL PARAMS !!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

nxc = 100,                  !Number of cells

dleft = 0.,                 !Domain left location (meters)

dright = 1.,                !Domain right location (meters)
                            !dright must be < dleft

!Note that the grid spacing is calculated dynamically as:
!(domain length) / nxc   =   (dright - dleft) / nxc

init_type = 1,              !Type of initialization to use
                            !   1: sine wave
                            !   2: rectangle wave
                            !   3: triangle wave
                            !   4: irregular signal
                            !   5: "double hump"







!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!! TIME INTEGRATION PARAMS !!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

dt = 0.000,                 !Time step (seconds)
                            !A value <= 0 will invoke automated calculation
                            !of time step based on max domain wave speed.

max_courant = 2.0,          !This specifies the maximum Courant number desired
                            !during the simulation.
                            !(Only activated if dt == 0)

sim_time = 0.225,           !time length of simulation (seconds)

!Note two things:
!(1) The number of time steps = ceiling( (sim_time) / (avg time step) )
!    since the timestep may change if dt = 0
!(2) The simulation does not necessarily end precisely at sim_time unless
!    sim_time is chosen to be a multiple of dt (i.e. non-zero dt specification)

time_method = 1,            !How to treat the time derivative of the PDE:
                            !   1: Decouple spatial and temporal accuracy via
                            !      the semi-discrete system. This enables the
                            !      specification of sd_timesolver
                            !   2: Coupled spatial/temporal accuracy via
                            !      integrating along characteristics.
                            !      In this case, temporal accuracy is generally
                            !      the same as spatial, depending upon the
                            !      choice of sub-grid functional approximation.

sd_timesolver = 1,          !Type of time integration to use for semi-discrete
                            !solver type (only activated if time_method == 1):
                            !   1: RK-1 (1)
                            !   2: RK-2 (1/2 , 1)
                            !   3: RK-3 (1/3 , 1/2 , 1)
                            !   4: RK-4 (1/4 , 1/3 , 1/2 , 1)








!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!! SPATIAL APPROXIMATION PARAMS !!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

subgrid_approx = 0,         !What type of subgrid recontruction to use?
                            !    0: Constant
                            !    1: Linear
                            !    2: WENO (2nd-order)
                            !    3: Piecewise Hyperbolic Method (PHM)
                            !    4: Piecewise Double Hyperbolic Method (PDHM)
                            !    5: Piecewise Logarithmic Method (PLM)
                            !       Cannot use PLM with time_method == 2
                            !    6: Piecewise Double Logarithmic Method (PDLM)
                            !       Should not use PDLM with time_method == 2
                            !    7: Piecewise Parabolic Method (PPM)
                            !    8: Piecewise Double Logarithmic Method (PRM)
                            !    9: WENO (3rd-order)
                            !   10: WENO (4th-order)
                            !   11: WENO (5th-order)

linear_lim = 0,             !Type of limiter to use for linear reconstruction
                            !Taken directly from Wikipedia's wiki.
                            !   0: No limiter
                            !   1: CHARM (Zhou, 1995)                 [not TVD]
                            !   2: HCUS (Waterson & Deconinck, 1995)  [not TVD]
                            !   3: HQUICK (Waterson & Deconinck, 1995)[not TVD]
                            !   4: Koren (Koren, 1993)
                            !   5: minmod (Roe, 1986)
                            !   6: monotonized central (van Leer, 1977)
                            !   7: Osher (Chatkravathy and Osher, 1983)
                            !   8: ospre (Waterson & Deconinck, 1995)
                            !   9: smart (Gaskell & Lau, 1988)        [not TVD]
                            !  10: superbee (Roe, 1986)
                            !  11: Sweby (Sweby, 1984)
                            !  12: UMIST (Lien & Leschziner, 1994)
                            !  13: van Albada 1 (van Albada et al, 1982)
                            !  14: van Albada 2 (Kermani, 2003)       [not TVD]
                            !  15: van Leer (van Leer, 1974)

ppm_filter = 1,             !What type of monotonic filter to use for PPM
                            !   0: No filter
                            !   1: Standard Collela & Woodward (1984) filter

pd_filter = .true.,         !Use a positivity filter (multiplicative filler)?
                            !This is a conservative filter redistributing the
                            !mass gained in the hole filling by taking away
                            !from other fields proportionalto the amount
                            !currently in the field (with a minimum cutoff).









!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! OUTPUT PARAMS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!Prefix of the output files. Two files will be written per
!simulation: prefix_init.dat and prefix_final.dat

outfile_prefix = 'test'

&END
Comment 1 Jerry DeLisle 2008-06-30 17:56:50 UTC
This may have been fixed with a recent patch.  I will check and report back this evening.
Comment 2 Jerry DeLisle 2008-06-30 23:50:46 UTC
Bug confirmed on trunk.
Comment 3 Jerry DeLisle 2008-07-01 05:43:31 UTC
Patch:

Index: list_read.c
===================================================================
--- list_read.c (revision 137236)
+++ list_read.c (working copy)
@@ -2922,8 +2922,8 @@ find_nml_name:
       goto find_nml_name;
     }

-  if (c == '!')
-    eat_line (dtp);
+  unget_char (dtp, c);
+  eat_separator (dtp);

   /* Ready to read namelist objects.  If there is an error in input
      from stdin, output the error message and continue.  */
Comment 4 Jerry DeLisle 2008-07-02 03:59:44 UTC
Subject: Bug 36676

Author: jvdelisle
Date: Wed Jul  2 03:58:57 2008
New Revision: 137334

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=137334
Log:
2008-07-01  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/36676
	* io/list_read.c (find_nml_name): Use eat_separator instead of eat_line.

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

Comment 5 Jerry DeLisle 2008-07-02 04:02:47 UTC
Subject: Bug 36676

Author: jvdelisle
Date: Wed Jul  2 04:01:57 2008
New Revision: 137335

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=137335
Log:
2008-07-01  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/36676
	* gfortran.dg/namelist_51.f90: New test.

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

Comment 6 Jerry DeLisle 2008-07-02 04:45:08 UTC
Subject: Bug 36676

Author: jvdelisle
Date: Wed Jul  2 04:44:21 2008
New Revision: 137336

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=137336
Log:
2008-07-01  Jerry DeLisle  <jvdelisle@gcc.gnu.org

	PR fortran/36676
	PR fortran/36657
	PR fortran/36546
	Backport from trunk.
	* io/list_read.c (find_nml_name): Use unget_char before eat_separator.
	(read_character): Check for '!' along with separators.
	(eat_separator): Add tab character to condition	for looping past
	whitespace.

Modified:
    branches/gcc-4_3-branch/libgfortran/ChangeLog
    branches/gcc-4_3-branch/libgfortran/io/list_read.c

Comment 7 Jerry DeLisle 2008-07-02 04:53:38 UTC
Subject: Bug 36676

Author: jvdelisle
Date: Wed Jul  2 04:52:47 2008
New Revision: 137337

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=137337
Log:
2008-07-01  Jerry DeLisle  <jvdelisle@gcc.gnu.org

	PR fortran/36676
	PR fortran/36657
	PR fortran/36546
	PR fortran/36538
	* gfortran.dg/namelist_50.f90
	* gfortran.dg/namelist_51.f90
	* gfortran.dg/namelist_48.f90
	* gfortran.dg/namelist_49.f90

Added:
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/namelist_48.f90
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/namelist_49.f90
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/namelist_50.f90
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/namelist_51.f90
Modified:
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog

Comment 8 Jerry DeLisle 2008-07-02 05:15:55 UTC
Fixed on trunk and 4.3