<html lang="en"> <head> <title>Extensions to namelist - The GNU Fortran Compiler</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="The GNU Fortran Compiler"> <meta name="generator" content="makeinfo 4.13"> <link title="Top" rel="start" href="index.html#Top"> <link rel="up" href="Extensions-implemented-in-GNU-Fortran.html#Extensions-implemented-in-GNU-Fortran" title="Extensions implemented in GNU Fortran"> <link rel="prev" href="Old_002dstyle-variable-initialization.html#Old_002dstyle-variable-initialization" title="Old-style variable initialization"> <link rel="next" href="X-format-descriptor-without-count-field.html#X-format-descriptor-without-count-field" title="X format descriptor without count field"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <!-- Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with the Invariant Sections being ``Funding Free Software'', the Front-Cover Texts being (a) (see below), and with the Back-Cover Texts being (b) (see below). A copy of the license is included in the section entitled ``GNU Free Documentation License''. (a) The FSF's Front-Cover Text is: A GNU Manual (b) The FSF's Back-Cover Text is: You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development.--> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } --></style> </head> <body> <div class="node"> <a name="Extensions-to-namelist"></a> <p> Next: <a rel="next" accesskey="n" href="X-format-descriptor-without-count-field.html#X-format-descriptor-without-count-field">X format descriptor without count field</a>, Previous: <a rel="previous" accesskey="p" href="Old_002dstyle-variable-initialization.html#Old_002dstyle-variable-initialization">Old-style variable initialization</a>, Up: <a rel="up" accesskey="u" href="Extensions-implemented-in-GNU-Fortran.html#Extensions-implemented-in-GNU-Fortran">Extensions implemented in GNU Fortran</a> <hr> </div> <h4 class="subsection">6.1.3 Extensions to namelist</h4> <p><a name="index-Namelist-308"></a> GNU Fortran 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: <p>Old-style use of ‘<samp><span class="samp">$</span></samp>’ instead of ‘<samp><span class="samp">&</span></samp>’ <pre class="smallexample"> $MYNML X(:)%Y(2) = 1.0 2.0 3.0 CH(1:4) = "abcd" $END </pre> <p>It should be noted that the default terminator is ‘<samp><span class="samp">/</span></samp>’ rather than ‘<samp><span class="samp">&END</span></samp>’. <p>Querying of the namelist when inputting from stdin. After at least one space, entering ‘<samp><span class="samp">?</span></samp>’ sends to stdout the namelist name and the names of the variables in the namelist: <pre class="smallexample"> ? &mynml x x%y ch &end </pre> <p>Entering ‘<samp><span class="samp">=?</span></samp>’ outputs the namelist to stdout, as if <code>WRITE(*,NML = mynml)</code> had been called: <pre class="smallexample"> =? &MYNML 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, / </pre> <p>To aid this dialog, when input is from stdin, errors send their messages to stderr and execution continues, even if <code>IOSTAT</code> is set. <p><code>PRINT</code> namelist is permitted. This causes an error if <samp><span class="option">-std=f95</span></samp> is used. <pre class="smallexample"> PROGRAM test_print REAL, dimension (4) :: x = (/1.0, 2.0, 3.0, 4.0/) NAMELIST /mynml/ x PRINT mynml END PROGRAM test_print </pre> <p>Expanded namelist reads are permitted. This causes an error if <samp><span class="option">-std=f95</span></samp> is used. In the following example, the first element of the array will be given the value 0.00 and the two succeeding elements will be given the values 1.00 and 2.00. <pre class="smallexample"> &MYNML X(1,1) = 0.00 , 1.00 , 2.00 / </pre> </body></html>