Module demonstrates reading f90 program global arguments from parameter file
and/or command line.
Implementation:
In the present module as global variables declare and set default values
to all code parameters. To reset them from parameter file and/or command line
in the Main program call once subroutine prog_args
from this module.
All modules may access these values via Use mparam
declaration.
You may use Only
phrase to restrict access/prevent confusion with
local variables. To make code clearer you may capitalize parameters though
it has no impact on the compiler so name variables with care.
Operation:
The initial declared values are overwritten subsequently by those present
in the parameter file and command line. Syntax rules follow those of f90
NAMELIST file. Note insensitivity to capitalization and order and
use of both space and comma as delimiters.
Parameter lists including strings must be enclosed with
yet another pair of string marks (see examples).
History:
Based on an example Namelist use by John S. Urban, 2009
http://www.urbanjost.altervista.org/LIBRARY/libGPF/arguments/namelist/index.html
(C) alex schwarzenberg-czerny, 2018, alex@camk.edu.pl
Example parameter file prog_args.par:
&par OTHER_INTEGER=2 /
Example calls:
./t SOME_LOGICAL=T some_real=200e3 OTHER_INTEGER=200
./t "SOME_STRING='my character string' SOME_INTEGER=10,SOME_REAL=20.30"
./t other_INTEGER=33333, SOME_INTEGER=22222
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
logical, | public | :: | VERBOSE | = | .False. | Printout control |
|
logical, | public | :: | ERRIN | = | .False. | Error column present? |
|
integer, | public | :: | NBEST | = | 5 | Number of best frequencies |
|
integer, | public | :: | CTMIN | = | 5 | minimum bin occupancy |
|
real(kind=SP), | public | :: | FSAMPL | = | 7._SP | oversampling factor |
|
real(kind=TIME), | public | :: | FR0 | = | 0. | lower frequency |
|
real(kind=TIME), | public | :: | FRU | = | 4. | upper frequency |
|
real(kind=TIME), | public | :: | FRS | = | 0. | frequency step (0.-optimum sampling) warning: undersampling risk for FRS>0. |
|
integer, | public | :: | MXFRQ | = | 1000000 | max number of frequencies |
|
integer, | public | :: | NPAR | = | 5 | number of model parameters |
|
integer, | public | :: | NCOV | = | 2 | number of bin coverages |
|
character(len=4), | public, | parameter | :: | meths(8) | = | (/'AOV ', 'ATR ', 'AMH ', 'PWS ', 'AOVW', 'ATRW', 'AMHW', 'PWSW'/) | |
character(len=4), | public | :: | METHOD | = | 'AMH' | select from AOV,ATR,AMH,PWS,AOVW,ATRW,AMHW,PWSW |
|
character(len=5), | public | :: | SPTYPE | = | 'AOV' | select from RAW,AOV,MODEL,RESID |
|
character(len=LSTRING), | public | :: | DIR | = | '' | LC file name prefix |
|
character(len=LSTRING), | public | :: | EXT | = | '.dat' | LC file name extension obligatory command parameter (no keyword, order matters) |
|
character(len=LSTRING), | public | :: | STAR | = | 'SIMUL' | star name;
|
|
character(len=LSTRING), | public | :: | STRLST | = | '' | star list file name; If non-empty it replaces STAR as source of star names |
|
character(len=LSTRING), | public | :: | EPOCH | = | 'AVE' | epoch type: ... just add more variable declaration here and append them to NAMELIST |
Inputs arguments succesively from parameter file and command line and resets module NAMELIST global variables, if present in input, as an intended side effect. par and NAMELIST variables are external.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | pname | name of parameter file |
status
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | logunit |