Names a group of variables for I/O processing.
Syntax
NAMELIST /group-name/var-list [ [ ,]/group-name/var-list ]... |
- group-name
is a unique namelist group name.
- var-list
is a comma-separated list of scalar and array variable
names.
Description
The NAMELIST statement declares var-list as a namelist group and associates the group with group-name.
Variables appearing in var-list may be of any type, including objects of derived
types or their components, saved variables, variables on the local
stack, and subroutine parameters. The following, however, are not
allowed:
Record or composite references
Pointers or their targets
Assumed-size array parameters
Adjustable-size array parameters
Assumed-size character parameters
Individual components of a derived type object
The var-list explicitly defines which items may be read or written
in a namelist-directed I/O statement. It is not necessary for every
item in var-list to be defined in namelist-directed input, but every
input item must belong to the namelist group. The order of items
in var-list determines the order of the values written in namelist-directed
output.
More than one NAMELIST statement with the same group-name may appear within the same scoping unit. Each successive var-list in multiple NAMELIST statements with the same group-name is treated as a continuation of the list for group-name.
The same variable name may appear in different NAMELIST statements within the same scoping unit.
Examples
PROGRAM INTEGER i, j(10) CHARACTER*10 c NAMELIST /n1/ i, j, c ! Define the namelist group n1 READ (UNIT=5,NML=n1) WRITE (6, n1) END |
When this program is compiled and executed with the following
input record:
&n1 j(8) = 6, 7, 8 i = 5c = 'xxxxxxxxx' j = 5*0, -1, 2 c(2:6) = 'abcde' / |
its output is:
&n1 I = 5 J = 0 0 0 0 0 -1 2 6 7 8 C ='xabcdexxx' / |
Related statements
ACCEPT, OPEN, INQUIRE, PRINT, READ, and WRITE
Related concepts
Namelist-directed I/O is described in “Namelist-directed
I/O”.