parse_init, parse_int, ..., parse_finish


The Fortran90 module paramfile_io contains functions to obtain parameters from parameter files or interactively

Location in HEALPix directory tree: src/f90/mod/paramfile_io.F90 


ARGUMENTS

name&dimensionality kind in/out description
       
fname CHR IN file containing the simulation parameters. If empty, parameters are obtained interactively.
handle PMF INOUT Object of type (paramfile_handle) used to store parameter information
keyname CHR IN name of the required parameter
default XXX IN optional argument containing the default value for a given simulation parameter; must be of appropriate type.
vmin XXX IN optional argument containing the minimum value for a given simulation parameter; must be of appropriate type.
vmax XXX IN optional argument containing the maximum value for a given simulation parameter; must be of appropriate type.
descr CHR IN optional argument containing a description of the required simulation parameter
filestatus CHR IN optional argument. If present, the parameter must be a valid filename. If filestatus=='new', the file must not exist; if filestatus=='old', the file must exist.
code CHR IN optional argument. Contains the name of the executable.
silent LGT IN optional argument. If set to .true. the parsing routines will run silently in non-interactive mode (except for warning or error messages, which will always appear). This is mainly intended for MPI usage where many processors parse the same parameter file: silent can be set to .true. on all CPUs except one.

ROUTINES:
handle = parse_init (fname [,silent])

    initializes the parser to work on the file fname, or interactively, if fname is empty

intval = parse_int (handle, keyname [, default, vmin, vmax, descr])

longval = parse_long (handle, keyname [, default, vmin, vmax, descr])

realval = parse_real (handle, keyname [, default, vmin, vmax, descr])

doubleval = parse_double (handle, keyname [, default, vmin, vmax, descr])

stringval = parse_string (handle, keyname [, default, descr, filestatus])

logicval = parse_lgt (handle, keyname [, default, descr])

    These routines obtain integer(i4b), integer(i8b), real(sp), real(dp), character(len=*) and logical values, respectively.
Note: parse_string will expand all environment variables of the form ${XXX} (eg: ${HOME}). It will also replace a leading ~$\!$/ by the user's home directory.

call parse_summarize (handle [, code])

    if the parameters were set interactively, this routine will print out a parameter file performing the same settings.

call parse_check_unused (handle [, code])

    if a parameter file was read, this routine will print out all the parameters found in the file but not used by the code. Intended at detecting typos in parameter names.

call parse_finish (handle)

    frees the memory


EXAMPLE:

program who_r_u
use healpix_types
use paramfile_io
use extension

implicit none
type(paramfile_handle) :: handle
character(len=256) :: parafile, name
real(DP) :: age

parafile = ''
if (nArguments() == 1) call getArgument(1, parafile)
handle = parse_init(parafile)
name = parse_string(handle, 'name',descr='Enter your last name: ')
age = parse_double(handle, 'age', descr='Enter your age in years: ', &
& default=18.d0,vmin=0.d0)
call parse_summarize(handle, 'who_r_u')
end program who_r_u
If a file is provided as command line argument when running the executable who_r_u, that file will be parsed in search of the lines starting with 'name =' and 'age =', otherwise the same questions will be asked interactively.


RELATED ROUTINES

This section lists the routines related to parse_init, parse_int, ..., parse_finish

concatnl
generates from a set of strings the multi-line description
nArguments
returns the number of command line arguments
getArgument
returns the list of command line arguments

Version 3.31, 2017-01-06