.nj .nfl .ps 2000,80 .lm 2 .rm 70 .SET para 5 0 .i -2 1 help .blank .c;* * * * * * N A M E L I S T * * * * * * .c;originally written by Derek Rowell and Douglass Wilson .c;Joint Computing Facility at MIT .blank .c;augmented by Frederick K. Knight .c;to be a versatile formated I/O package for VAX Fortran programs .c;at the Naval Research Laboratory (NRL) .c;and the Smithsonian Astrophysical Observatory (SAO) .blank .p This help file gives information on the JCF namelist submitted through decus and the modifications by Frederick K. Knight at NRL and SAO. As such, it is both a primer to using namelist and a detailed description of namelist. The topics in this help file are listed under TOPICS. For options of what to do next try WHAT_NEXT. .i -2 2 What_next .p If you are not familiar with the JCF namelist, you could .list .le Print or read NML$DIR:NML.DOC. .le Read introduction, data entry, interrogation, error messages and usage, in that order, in this help file. .end list .p If you are familiar with JCF namelist, then read modifications and examples in this help file. .i -2 2 Topics .p The topics in this help file are the following: .nf .rm 80 .blank introduction includes a basic example data_entry describes input, data types with examples examples one-line examples of namelist input interrogation ? and =? sequences nml_options describes sequences following '\' summary one-screen list of sample inputs usage how to implement namelist in a program logical names describes NML$HELP, NML$SETUP, NML$LIB & NML$DIR error messages $ It's simple to execute any DCL command. per_cent How to describe variables without a help file # How to initialize a program subscripts describes (*) sequence modifications a summary of the FKK changes subroutines list of all (I think) namelist routines future possible future modifications .f .rm 70 .i -2 1 Introduction .p Namelist input is a non-standard, but very useful, method of selectively inputting values to a Fortran program. It is most useful when a small number of variables out of a larger group are to be changed for each run. For example, suppose that a particular program has 20 different input values, but on any one run only two or three are to be changed. If the standard Fortran I/O statements are to be used, (READ, ACCEPT, WRITE, TYPE, PRINT), all twenty data items must be supplied. Using the namelist feature, the name and value of only those items to be changed is entered, the value of all other items will remain unchanged. .p This document describes the grammar and syntax of input lines, the incorporation of namelists into user programs, and the auxiliary features of namelist that allow variable inititialization with defaults, on-line help, access to DCL commands, and options that can be personalized. .i -2 2 example .p A typical line of namelist input might look like: .blank .nf ENTER VALUES: A(3)=5., NEW=.TRUE., TITLE= 'RESPONSE' ENTER VALUES: CMPLX_VAL=(3,4)& .f .blank .p Here the names A, NEW, TITLE, and CMPLX_VAL are a part of a namelist which may include many more variables. The system prompts ENTER VALUES and enters values into the specified variables until an ampersand (&) is encountered. In the above example, numeric, logical, character, and complex data types are demonstrated. .i -2 2 Implementation .p VAX namelist is implemented as a set of three user callable subroutines. Two of these are used to initialize namelists, (specify variables to be included in the namelists), the third performs namelist input. Additional subroutines may be called to set namelist options. .i -2 1 data_entry .p Namelist is character-based, but the user interacts via an input line described below. signals namelist to process all new input. However, continuation lines and automatic subscript recall, if enabled, allow input to continue past the without special effort. All fortran data types can be entered; the format is versatile. .i -2 2 input_line .p The input line takes the form of: .blank .nf .rm 80 prompt: var = val list, var = val list,.....& .blank where prompt....is a user supplied prompting message printed at the terminal to indicate that the system is awaiting input. var.......is a variable name, array element, or an array name val list..is a set of one or more numerical, logical, or character data values to be entered into the variable or array. &.........is the namelist terminator, specifying that there are no more variables to be entered. Each namelist input must be ended with a terminator. .f .rm 70 .p The input string may be broken into more than one line at positions where a comma appears. A comma at the end of each line is optional. .i -2 2 examples .p The following are equivalent: .nf .blank System Parameters: A=10.,CVAL=1E36,I=13.& .blank or System Parameters: I=13 System Parameters: CVAL=1E36, System Parameters: A=10.3 System Parameters: & .blank Note: the values may be entered in any order. .f .i -2 2 types .p Namelist supports LOGICAL*1, LOGICAL*2, LOGICAL*4, INTEGER*2, INTEGER*4, REAL*4, REAL*8, COMPLEX and CHARACTER data types. The subtopics describe the syntax of data items in the input line. .i -2 3 logical .p Namelist recognizes the following: .blank.i +5 t .true. .t. .TRUE. .T. T .i +5 f .false. .f. .FALSE. .F. F .blank Any mixture of upper and lower case is allowed. .i -2 3 numeric .p Each numeric datum is interpreted as a double precision number and is converted to the appropriate mode (integer, real or part of complex). The equivalent format field specification is D.0, where NCHAR is the length of the input string. .i -2 3 complex .p Each complex number must be entered in the form: .blank.i +5 (real, imag) .blank where real and imag are valid numerical quantities. The real and imaginary parts must be seperated by a comma, for example, (3.,4) or (IE-2,17.36). .i -2 3 character .p A valid character string or substring is enclosed in apostrophes, for example: .blank.i +5 'THIS IS VALID' .blank If the string itself includes an apostrophe, that apostrophe must appear as a pair of apostrophes, for example: .blank.i +5 'ISN''T THIS FUN?' .blank is the input specification for the character item: .blank.i +5 ISN'T THIS FUN? .blank The enclosing quotes are unnecessary unless the string contains any of the following characters: .blank.i +5 = ? * , & \ ' ! ; % # $ .blank and probably some others I forgot. When in doubt, use quotes. However, the feature to omit the quotes is great for filespecs. The trailing quote can be omitted at the end of the input line. .f .rm 70 .i -2 2 arrays .p When the variable name VAR is an array element or an array name some extra features apply. It is possible to enter a group of values into sequential elements of an array by including a list of values following the equals sign (=). In this case, the array name or element specifies a base for the sequential entry of data items in the value list. In the case of linear arrays, the values are placed sequentially in ascending elements, in the case of multiple dimensional arrays the values are entered from the base specified by the name or element with the first subscript varying most rapidly (the normal Fortran convention). .p If a group of sequential array elements are to be set to the same value, the * repeat factor may be used. The item n*val is equivalent to a list of val repeated n times. .p Any valid set of subscripts, (including negative subscripts), may be used for the base for sequential data storage, provided no attempt is made to exceed the array bounds specified in the dimension statement for the array. .i -2 3 example .p The following are valid namelist input lines for the array Y dimensioned (2,2): .blank.lm +5.lit ENTER VALUES: Y(1,1)=38., Y(2,2)=0& ENTER VALUES: Y = 1.,2.,3.,4& ENTER VALUES: Y(2,1)=-3,-4& ENTER VALUES: Y(*)=-5& ; cf. subscripts ENTER VALUES: Y = 4*1& .end lit.blank.lm -5 .p In the first line two specific elements of Y have been entered as though they were normal variables. In the second case the whole array has been entered and Y(1,1) = 1, Y(2,1) = 2, Y(1,2) = 3, and Y(2,2) = 4. The third line uses the element Y(2,1) as the base for the entry of two sequential elements Y(2,1) = -3, Y(1,2) = -4. The fourth line requires auto subscripts to be enabled (cf. subscripts) and fills the element following the last filled, in this case, Y(2,2)=-5. The fifth line sets all four elements of Y to 1. .i -2 1 examples .p Here, v and w are variables, simple or array, of any fortran data type. The examples are divided into categories as subtopics. .i -2 2 BASIC .rm 80.lm +1.lit ; comment or ! comment can start anyplace on line. v=1.,v=1,v=1e0 ; All these set v to 1; v is integer or real here. v=1,w=3. ; Separater is always a comma. v=1,2,3 ; Also between elements of an array. v(1,1)=1,2,3 ; Equivalent to last line when v is a 2-dim array. v=string ; Quotes are needed only with special characters, v=' %#?=+&*()!;' ; like all these. No doubt I forgot some. v(3:6)=ring ; Substrings can also be input. .end lit.lm -1 .i -2 2 HELP .lm +1.lit h topic ; Asks for help on topic from current help library. \h topic ; Asks for special nml help. .end lit.lm -1 .i -2 2 ADVANCED .lm +1.lit v=1,2,3 ; That's staightforward, but I forgot 4, so... v(*)=4 ; v(4) becomes 4. NML$SET_AUTOSUBS called 1st. v(2,3)=4,5,,,,7; Starts filling at (2,3) and skips 3 elements. v(2,3)=4,5,3*,7; Like last line. Read "3*" as "skip 3" or "keep 3". .end lit.lm -1 .i -2 2 INTERROGATION & DESCRIPTION .lm +1.lit v ; Prints current contents of v. v(2,3) ; Prints single element. v(2:3) ; Prints substring. = ; Prints ALL values of ALL variables. ? ; Prints names of ALL variables. v(*) ; Prints element to be changed to 6 by "v(*)=6". #v=6;set volume value ; Forces special prompt and allows default or new value. %v volume number for data ; Describes variable, stored in NML$SETUP, output with ? .end lit.lm -1 .i -2 2 SPECIAL .lm +1.lit \nml_char=\ ; Changes the special nml character to \. \end_char=& ; Changes the ending character to & (the default). \infile=f.dat ; Starts reading from f.dat. \promptfile=nl:; Outputs prompt to the null file. \promptfile=- ; Resets promptfile to previous value. \echofile=f.log; Sets echofile to f.log. \outfile=f.out ; Sets outfile to f.out. \prompt=picky-picky ; Sets prompt to picky-picky; reset with \prompt=-. \on_eof=stop ; If an eof =ctrl Z is read, namelist stops program. \library=f.hlb ; Help library becomes f.hlb. \nml_library=f.hlb; Changes the nml_library - all this explanation. \instat=old ; Sets the open status for new infiles to old. \promptstat=old; Sets the open status for new promptfiles to old. \echostat=old ; Sets the open status for new echofiles to old. .end lit.lm -1.rm 70.f .i -2 1 interrogation .p VAX namelist allows the user to inquire as to .blank .list 0 .le the names and description of variables in the current namelist - using "?" .le the current value of any item (variable or array) in the namelist - using "item" or "item=" or "item=?" .le the current value of all items in the namelist - using "=" or "=?" .end list .i -2 2 QUESTION_MARK .p A "?" typed at the keyboard will generate a summary of all the names and attributes of the current variables in the namelist. This is a useful feature to remind users of the names and dimensions to be used. .blank.lit ENTER VALUES: ? ALPHA(50) [REAL*4] LOGVAL(10) [LOGICAL*2] BRAVO [REAL*8] CHARLIE [INTEGER*4] PROG_NAME [CHARACTER*40] .end lit.blank .p In addition descriptions of variables can be added using the "%" option in setup files (cf % and logical names NML$SETUP). .i -2 2 item,item=,item=QUESTION_MARK .p The current value of an individual namelist variable, or a whole array may be interrogated by entering a "var name" or "var name=" or "var name = ?" in the input stream. For example, .blank.i +5 ENTER VALUES: ALPHA=3,4;5,10*-15,BRAVO=33.,CHARLIE=? .blank will enter the new values into ALPHA and BRAVO and then type the current value of the variable CHARLIE. The user can then make a decision whether or not to modify this value. .p In the case of an array name, a particular element may be interrogated by specifying a set of subscripts; if no subscripts are given the values of all array elements will be typed, in the order of storage in the array (first subscript varying most rapidly). .i -2 2 =QUESTION_MARK .p The current value of all variables in the namelist may be typed by simply issuing the command =? or =. For example, .blank.i +5 ENTER VALUES: A=0.1,2,3,=? .blank will set three new values into A and then type out the values of all namelist items. .p Alternatively, the calling program can force a sequence of variables to be set using lines beginning with "#". Here, namelist prompts the user and allows either default or new values (cf #). .i -2 1 nml_options .p Here is a list of the internal namelist variables accessed through the nml character (shown here as \). .lm 1 .rm 80 .nf Option Default Description --------------------- ------- --------------------------------- \? print all the internal variables \echofile= init value change the echo file \echostat=