Next: , Previous: Old-style variable initialization, Up: Extensions

7.3 Extensions to namelist

gfortran fully supports the Fortran 95 standard for namelist I/O including array qualifiers, substrings and fully qualified derived types. The output from a namelist write is compatible with namelist read. The output has all names in upper case and indentation to column 1 after the namelist name. Two extensions are permitted:

Old-style use of $ instead of &

      X(:)%Y(2) = 1.0 2.0 3.0
      CH(1:4) = "abcd"

It should be noticed that the default terminator is / rather than &END.

Querying of the namelist when inputting from stdin. After at least one space, entering ? sends to stdout the namelist name and the names of the variables in the namelist:


Entering =? outputs the namelist to stdout, as if WRITE (*,NML = mynml) had been called:

      X(1)%Y=  0.000000    ,  1.000000    ,  0.000000    ,
      X(2)%Y=  0.000000    ,  2.000000    ,  0.000000    ,
      X(3)%Y=  0.000000    ,  3.000000    ,  0.000000    ,
      CH=abcd,  /

To aid this dialog, when input is from stdin, errors send their messages to stderr and execution continues, even if IOSTAT is set.

PRINT namelist is permitted. This causes an error if -std=f95 is used.

     PROGRAM test_print
       REAL, dimension (4)  ::  x = (/1.0, 2.0, 3.0, 4.0/)
       NAMELIST /mynml/ x
       PRINT mynml
     END PROGRAM test_print