Silverfrost Forums

Welcome to our forums

NAMELIST in a MODULE error

14 Jun 2010 7:25 (Edited: 15 Jun 2010 7:27) #6525

On an intel microchannel quad cpu 64 bit windows 7 The last downlodable version of SilverFrost Fortran,

  • which installed flawless from default administrator protected 32 bit, builds, debugs, and runs all ok here.

The NAMELIST statement works ok in a MAIN program, the first
example program; The NAMELIST statement does not seem to work in a MODULE, the second example. .n.g. why ... Metcalf and Reid seem to say that all module declarations are replicated in to the program unit/s that USE the module.

PROGRAM NAMELIST_TEST
IMPLICIT NONE INTEGER :: n REAL :: x CHARACTER(len=32) :: word001 NAMELIST /dphotdef/ n , x, word001 ! Declare a namelist WRITE(,) 'Start the namelist_test' WRITE(,) 'Read and print the namelist' WRITE(,) OPEN ( unit =3, file = 'dphotdefval.dat' ) READ(unit=3,NML=dphotdef) ! Read the namelist
WRITE(,) WRITE(,NML=dphotdef)
WRITE(
,) WRITE(,*) 'done namelist_test' END PROGRAM NAMELIST_TEST

A text file named dphotdefval.dat exists in the working directory and contains:

! test namelist. A comment line ! &DPHOTDEF ! do not edit the & in this line n=1, ! integer. an inline comment. comma can be deleted optional
x=1.234567890123456789e000, ! real word001='abc namelist' ! charter / ! do not edit the / in this line ! trailing comment line/s
!

On execution the test returns:

Start the namelist_test Read and print the namelist &DPHOTDEF N = 1 X = 1.23457 WORD001 = 'abc namelist ' / done namelist_test Press RETURN to close window . . .

Ok fine so far. Now the build consists of 2 program units, a MAIN and a MODULE

PROGRAM NAMELIST_TEST USE namelistmodule CALL namelistvars END PROGRAM NAMELIST_TEST

MODULE namelistmodule IMPLICIT NONE NAMELIST /dphotdef/ n , x, word001 INTEGER :: n REAL :: x CHARACTER(len=32) :: word001 CONTAINS SUBROUTINE namelistvars OPEN ( unit=10, file = 'dphotdefval.dat' ) READ(unit=10, NML=dphotdef) CLOSE(unit=10) WRITE(*,NML=dphotdef) END SUBROUTINE namelistvars END MODULE namelistmodule

Builds ok, execution returns : Run-time Error *** Error 204, Invalid identifier in namelist input group 00401000 NAMELISTMODULE!NAMELISTVARS [+00b7] 00401180 main [+0042]

This last example runs just fine on Intel Linux FORTRAN 11.1-072

20 Jun 2010 9:13 #6551

Hi erom,

I have reproduced your problem. It looks like it only occurs when a contained subroutine attempts to read the namelist - perhaps as a workaround you could read it from a normal subroutine instead?

I'll log this as a bug and we'll look into it soon.

Thanks for reporting it.

Martin

Please login to reply.