24.11.2014 Views

Open Watcom FORTRAN 77 Language Reference

Open Watcom FORTRAN 77 Language Reference

Open Watcom FORTRAN 77 Language Reference

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Language</strong> <strong>Reference</strong><br />

2.61 NAMELIST Statement<br />

NAMELIST /name/ vlist [[,]/name/ vlist] ...<br />

where:<br />

name<br />

vlist<br />

is the name, enclosed in slashes, of a group of variables. It may not be the same as a variable<br />

or array name.<br />

is a list of variable names and array names separated by commas.<br />

The NAMELIST statement is used to declare a group name for a set of variables so that they may be read or<br />

written with a single namelist-directed READ, WRITE, or PRINT statement.<br />

The list of variable or array names belonging to a NAMELIST name ends with a new NAMELIST name<br />

enclosed in slashes or with the end of the NAMELIST statement. The same variable name may appear in<br />

more than one namelist.<br />

A dummy variable, dummy array name, or allocatable array may not appear in a NAMELIST list. Also, a<br />

variable whose type is a user-defined structure may not appear in a NAMELIST list.<br />

The NAMELIST statement must precede any statement function definitions and all executable statements.<br />

A NAMELIST name must be declared in a NAMELIST statement and may be declared only once. The<br />

name may appear only in input/output statements. The READ, WRITE, and PRINT statements may be used<br />

to transmit data between a file and the variables specified in a namelist.<br />

Example:<br />

CHARACTER*20 NAME<br />

CHARACTER*20 STREET<br />

CHARACTER*15 CITY<br />

CHARACTER*20 STATE<br />

CHARACTER*20 COUNTRY<br />

CHARACTER*10 ZIP_CODE<br />

INTEGER AGE<br />

INTEGER MARKS(10)<br />

NAMELIST /PERSON/ NAME, STREET, CITY, STATE,<br />

+ COUNTRY, ZIP_CODE, AGE, MARKS<br />

OPEN( UNIT=1, FILE=’PEOPLE’ )<br />

LOOP<br />

READ( UNIT=1, FMT=PERSON, END=99 )<br />

WRITE( UNIT=6, FMT=PERSON )<br />

ENDLOOP<br />

99 CLOSE( UNIT=1 )<br />

END<br />

The following example shows another form of a namelist-directed READ statement.<br />

108 NAMELIST Statement

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!