NAMELIST - ver 0.6 - 20-JUL-1979 "Namelist" is a feature of some extended Fortrans which provide run-time input/output of variable names and corresponding values. The NAMELIST statement defines a named collection of variables. Namelist input requires the name of the list, any number of the variables of the list with their corresponding values, and a termination character (details below). Namelist output shows all variables of a list by name and value. This capability is currently implemented by the use of CALL statements, rather than direct FORTRAN language statements. To use these routines, replace the statement: NAMELIST / list / var-1, var-2, ..., var-i, var-j, ... by the CALL statement(s): CALL NAM$LIST ('list', 'var-1', %DESCR(var-1), * 'var-2', %DESCR(var-2), ..., 'var-i', %DESCR(var-i)) CALL NAM$CONT ('var-j', %DESCR(var-j), ... ) and the namelist I/O statements: READ (unit, list [,END=endst,ERR=errst] ) WRITE (unit, list) by the CALLs: CALL NAM$READ (unit,'list'[,*endst,*errst]) CALL NAM$WRITE (unit,'list') where list is the name of the namelist being used, var-x is the name of a variable that is part of a list, endst is the statement number of a statement to go to on end-of-file, errst is the statement number of a statement to go to on error. Note the use of the string delimiters ('). These provide for passing the name of the lists and variables to the namelist routines. (Do not use nHxxx.) The %DESCR provides the types and dimensions of the variable. The routine NAM$CONT is used to continue a namelist "declared" by a previous NAM$LIST call. The FORTRAN compiler limits the number of arguments to a routine to 60. This implies that the limit of variables that can be declared in a CALL NAM$LIST statement is 29. Error messages are written to SYS$ERROR (unit 6, unless redefined). Restrictions: Both arguments corresponding to a given variable must be specified in the same CALL statement (NAM$LIST or NAM$CONT). Any (reasonable) number of NAM$CONT calls may follow a NAM$LIST call. Up to about 40 namelists may be declared, depending on NAM$CONT calls. Variables (including CHARACTER) that have been given character values may not be output by NAM$WRITE in a form that may be re-read by NAM$READ. If the optional error-return statement number is given, an end-return statement must also be given. If neither statement number is given the program will continue following either end-of-file or an error. NAM$READ and NAM$WRITE must refer to namelists defined at the same program/subprogram level. Variables used in namlist statements must either be in common or the routine must be compiled with /NOOPTIMIZE option. The reason for this is the fortran compiler does not know that namelist variables can be modified via the CALL NAM$READ statement or are output via the CALL NAM$WRITE statement, consequently it may optimize code into the use of registers set before calls to NAM$READ & NAM$WRITE rather than the contents of the variable itself. I N P U T D A T A General rules: Column 1 is always ignored. Tabs are treated as blanks. "!" indicates a comment; the remainder of the record is ignored. First record (for a given read) Column 2: $ or &. Column 3: namelist name followed by at least 1 blank. Records will be read until one of the above format is found or until end-of-file is encountered. Remainder of above record and remaining records: One or more variable specifications separated by (optional) commas, and terminated by $ or &. Each (possibly subscripted) variable may be assigned one or more values, separated by commas, or repeated by a repeat count followed by * preceding the value. Conversions made: variable type data type permitted REAL real, integer COMPLEX complex INTEGER real, integer LOGICAL logical, integer CHARACTER string In addition, any variable type may be given a string value (up to the length of the variable). Character variables are blank filled if the string given is shorter than the variable. Miscellaneous (definitions, etc.): Integer: optional + or - followed by digits; e.g. 5, -5, +5555 Real/double precison: optional sign, integer portion, decimal point, fraction portion, exponent (E or D followed by optional sign and 1 or 2 digits); 5, 5., .5, 0.5, 5.0, 5E1, .5D-1, .E1 (meaningless). Complex: a pair of real values, separated by comma, enclosed by (). Logical: T or F. String: ' any characters ', using '' for ' within the string. Truncated if necessary to maximum length of variable (no error message). Must be contained in single record; end of record taken as end of string if ending ' is missing. Blanks: may be used most anywhere, except: imbedded within a variable or namelist name; imbedded within a numeric value, including between a sign and the following value (they may appear before and after the real values that make up a complex value). Names (variables and namelists): follow Fortran conventions, i.e., 1-15 characters, first is alphabetic, others are alphabetic, numeric, $, or _. Subscripts: if given, must agree with the Fortran program specification in number of subscripts and bounds of each subscript (including negative). Multiple values: (1) not permitted for non-array variables; (2) stored in "memory sequence", i.e., first subscript varies fastest: X(1,1), X(2,1),... H O W T O U S E These routines are contained in LOCALIB and may be linked by: $ LINK obj,obj,...,SYS$LIBRARY:LOCALIB/LIB Questions or comments by be directed to: Byron Bassett 773-0752 or 773-5028 E X A M P L E program REAL*8 A DIMENSION B(10,5) COMPLEX C LOGICAL D C NAMELIST /MYLIST/ A,B,C,D CALL NAM$LIST ('MYLIST','A',%DESCR(A), 1 'B',%DESCR(B),'C',%DESCR(C)) CALL NAM$CONT ('D',%DESCR(D)) ... C READ (1,MYLIST,*10,*10) CALL NAM$READ (1,'MYLIST') ... COME HERE IF ERROR OR END OF FILE ON INPUT-- 10 ... file FOR001.DAT (default unit 1) !<--column 2 $MYLIST A = 12345.67891011 ! LIST-NAME AND SET A B=4,-56.78E9,0.12D-23,.44556, ! B(1,1)...B(4,1) B(1,3) = 67, 89, 18*456.78, ! B(1,3)...B(2,10) B (1,5) = 'ALPHA STRING!, INCLUDING APOSTROPHE ('')' ! 39-CHARACTER STRING INTO B(1,5)...B(10,5), EXCEPT LAST BYTE. D = F, C=(5.68,-8) $ SCAN STOPS WITH $