FORTRAN 77 Language Reference

Data Syntax

The first record of NAMELIST input data has the special symbol $ (dollar sign) in column two or beyond, followed by the NAMELIST group name. This is followed by a series of assignment statements, starting in or after column two, on the same or subsequent records, each assigning a value to a variable (or one or more values to array elements) of the specified group. The input data is terminated with another $ in or after column two, as in the pattern:

¤$group-name variable
=value [,variable

You can alternatively use an ampersand (&) in place of each dollar sign, but the beginning and ending delimiters must match. END is an optional part of the last delimiter.

The input data assignment statements must be in one of the following forms:

array=value1[, value2,]...
array(subscript)=value1[, value2,]...
array(subscript,subscript)=value1[, value2,]...
variable=character constant
variable(index:index)=character constant

If an array is subscripted, it must be subscripted with the appropriate number of subscripts: 1, 2, 3,...

Use quotes (either " or ') to delimit character constants. For more on character constants, see the next section.

The following is sample data to be read by the program segment above:

¤$case delta=0.05, mat( 2, 2 ) = 2.2, sample='Demo' $

The data could be on several records. Here NEW was not input, and the order is not the same as in the example NAMELIST statement:

¤mat( 2, 2 ) = 2.2 

Syntax Rules

The following syntax rules apply for input data to be read by NAMELIST:

A complex constant is a pair of real or integer constants separated by a comma and enclosed in parentheses. Spaces can occur only around the punctuation.

A logical constant is any form of true or false value, such as .TRUE. or .FALSE., or any value beginning with .T, .F, and so on.

A null data item is denoted by two consecutive commas, and it means the corresponding array element or complex variable value is not to be changed. Null data item can be used with array elements or complex variables only. One null data item represents an entire complex constant; you cannot use it for either part of a complex constant.

Example: NAMELIST input with some null data:

* nam2.f Namelist input with consecutive commas 
	WRITE ( *, * ) 'Input?' 
	READ ( *, GRID ) 
	WRITE ( *, GRID ) 

The data for nam2.f is:

¤$GRID ARRAY = 9,9,9,9,,,,,8,8,8,8 $

This code loads 9s into row 1, skips 4 elements, and loads 8s into row 3 of ARRAY.

Arrays Only

The forms r*c and r* can be used only with an array.

The form r*c stores r copies of the constant c into an array, where r is a nonzero, unsigned integer constant, and c is any constant.

Example: NAMELIST with repeat-factor in data:

* nam3.f Namelist "r*c" and "r* " 	REAL PSI(10) 	NAMELIST /GRID/ PSI 	WRITE ( *, * ) 'Input?' 	READ ( *, GRID ) 	WRITE ( *, GRID ) 	END 

The input for nam3.f is:

¤$GRID PSI = 5*980 $

The program, nam3.f, reads the above input and loads 980.0 into the first 5 elements of the array PSI.

Example: NAMELIST input with some skipped data.

The other input is:

¤$GRID PSI = 3* 5*980 $

The program, nam3.f, with the above input, skips the first 3 elements and loads 980.0 into elements 4,5,6,7,8 of PSI.