Module containing the routines that perform the actual reading and parsing of the input file author: P J Knight, CCFE, Culham Science Centre N/A This module provides a set of routines to read in data from the main PROCESS input file (IN.DAT). The format of the file is similar to the F90 NAMELIST structure, but with a few additional features:
Character strings, integers and double precision values can be read in.
The following rules must be obeyed when writing an input file:
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | public, | parameter | :: | nin | = | 10 | |
integer, | private, | parameter | :: | maxlen | = | 2000 | |
character(len=maxlen), | private | :: | line | ||||
integer, | private | :: | linelen | ||||
integer, | private | :: | lineno | ||||
integer, | private | :: | iptr | ||||
integer, | private | :: | infile | ||||
integer, | private | :: | outfile | ||||
integer, | private | :: | report_changes | ||||
integer, | private | :: | icode | ||||
logical, | private | :: | subscript_present | ||||
logical, | private | :: | error | ||||
character(len=78), | private | :: | error_message | ||||
integer, | private | :: | show_changes | ||||
logical, | private | :: | constraints_exist |
Initialise module variables
Routine that calls the main input file parsing routines author: P J Knight, CCFE, Culham Science Centre None This routine provides the interface between the input file reading routines and the rest of PROCESS. A User's Guide to the PROCESS Systems Code, P. J. Knight, AEA Fusion Report AEA FUS 251, 1993
Set icase description based on device type
Routine that parses the contents of the input file author: P J Knight, CCFE, Culham Science Centre author: J Morris, CCFE, Culham Science Centre author: F Warmer, IPP Greifswald in_file : input integer : Fortran input unit identifier out_file : input integer : Fortran output unit identifier show_changes : input integer : switch to turn on (1) or off (0) reporting of changed values This routine reads the data from the PROCESS input file (IN.DAT), dealing with comments or blank lines correctly, and sets the value of any variables found in the file. Any changes from the default values may be reported if required.
Each possible variable in this block is dealt with individually. (To add additional input variables, simply copy and edit one of the similar existing examples.) The routine also does the extremely useful function of checking that the given value for a variable lies within a sensible predefined range, and stops the program if apparently nonsensical values are attempted. A User's Guide to the PROCESS Systems Code, P. J. Knight, AEA Fusion Report AEA FUS 251, 1993
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | in_file | |||
integer, | intent(in) | :: | out_file | |||
integer, | intent(in) | :: | show_changes |
Routine that obtains the value of a real variable from the input file and checks that it lies within the expected range author: P J Knight, CCFE, Culham Science Centre varnam : input string : name of the variable varval : input/output real : value of the variable vmin : input real : minimum allowed value for the variable vmax : input real : maximum allowed value for the variable description : input string : brief description of the variable This routine parses a line containing a 'name = value' pair for a real variable, extracting the value from the line and checking whether it lies between user-defined lower and upper limits. None
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | varnam | |||
real(kind=dp), | intent(inout) | :: | varval | |||
real(kind=dp), | intent(in) | :: | vmin | |||
real(kind=dp), | intent(in) | :: | vmax | |||
character(len=*), | intent(in) | :: | description |
Routine that obtains the value of an integer variable from the input file and checks that it lies within the expected range author: P J Knight, CCFE, Culham Science Centre varnam : input string : name of the variable varval : input/output integer : value of the variable vmin : input integer : minimum allowed value for the variable vmax : input integer : maximum allowed value for the variable description : input string : brief description of the variable This routine parses a line containing a 'name = value' pair for an integer variable, extracting the value from the line and checking whether it lies between user-defined lower and upper limits. None
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | varnam | |||
integer, | intent(inout) | :: | varval | |||
integer, | intent(in) | :: | vmin | |||
integer, | intent(in) | :: | vmax | |||
character(len=*), | intent(in) | :: | description |
Routine that obtains the value of a string variable from the input file author: P J Knight, CCFE, Culham Science Centre varnam : input string : name of the variable varval : input/output string : value of the variable description : input string : brief description of the variable This routine parses a line containing a 'name = value' pair for a string variable, extracting the value from the line. None
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | varnam | |||
character(len=*), | intent(inout) | :: | varval | |||
character(len=*), | intent(in) | :: | description |
Routine that obtains the values of a real array from the input file author: P J Knight, CCFE, Culham Science Centre varnam : input string : name of the variable varval(n) : input/output real array : value of the variable isub1 : input integer : array element pointer n : input integer : size of varval array icode : output integer : diagnostic flag description : input string : brief description of the variable This routine parses a line in one of the two following forms:
name = v1[, v2, ...] name(element) = v
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | varnam | |||
real(kind=dp), | intent(inout), | dimension(n) | :: | varval | ||
integer, | intent(inout) | :: | isub1 | |||
integer, | intent(in) | :: | n | |||
character(len=*), | intent(in) | :: | description | |||
integer, | intent(out) | :: | icode |
Routine that obtains the values of an integer array from the input file author: P J Knight, CCFE, Culham Science Centre varnam : input string : name of the variable varval(n) : input/output integer array : value of the variable isub1 : input integer : array element pointer n : input integer : size of varval array icode : output integer : diagnostic flag description : input string : brief description of the variable This routine parses a line in one of the two following forms:
name = v1[, v2, ...] name(element) = v
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | varnam | |||
integer, | intent(inout), | dimension(n) | :: | varval | ||
integer, | intent(inout) | :: | isub1 | |||
integer, | intent(in) | :: | n | |||
character(len=*), | intent(in) | :: | description | |||
integer, | intent(out) | :: | icode | |||
integer, | intent(in), | optional | :: | startindex |
Routine that converts the ASCII digits in a string to an integer author: P J Knight, CCFE, Culham Science Centre string : input string : contains digits of the number length : input integer : useful length of character string ivar : output integer : value stored in the string icode : output integer : diagnostic flag This routine converts the ASCII digits in string(1:length) to the integer ivar. It is equivalent to doing 'READ(STRING(1:LENGTH),I) IVAR' but this routine conforms to the ANSI standard. Each digit is parsed in turn, the current total is multiplied by ten and the new digit is added. None
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | string | |||
integer, | intent(in) | :: | length | |||
integer, | intent(out) | :: | ivar | |||
integer, | intent(out) | :: | icode |
Routine that converts the ASCII digits in a string to a real value author: P J Knight, CCFE, Culham Science Centre string : input string : contains digits of the number length : input integer : useful length of character string rvar : output real : value stored in the string icode : output integer : diagnostic flag This routine converts the ASCII digits in string(1:length) to the real variable rvar. The string is parsed one character at a time, from the left, handling the mantissa, and all other components of the real number separately, combining them at the end. None
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | string | |||
integer, | intent(in) | :: | length | |||
real(kind=dp), | intent(out) | :: | rval | |||
integer, | intent(out) | :: | icode |
Routine that extracts an integer value from a line of the input file author: P J Knight, CCFE, Culham Science Centre ival : output integer : extracted integer value icode : output integer : diagnostic flag This routine extracts an integer value from the current line of the input file, i.e. the value of an integer variable as specified by the user. None
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(out) | :: | ival | |||
integer, | intent(out) | :: | icode |
Routine that extracts a real value from a line of the input file author: P J Knight, CCFE, Culham Science Centre rval : output real : extracted real value icode : output integer : diagnostic flag This routine extracts a real value from the current line of the input file, i.e. the value of a real variable as specified by the user. None
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=dp), | intent(out) | :: | rval | |||
integer, | intent(out) | :: | icode |
Routine that extracts a substring from a line of the input file author: P J Knight, CCFE, Culham Science Centre string : output string : extracted string icode : output integer : diagnostic flag This routine extracts a string from the current line of the input file, i.e. the value of a string variable as specified by the user. Unlike routine get_substring_trim, this routine does not truncate the string found at its first non-leading blank. None
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(out) | :: | string | |||
integer, | intent(out) | :: | icode |
Routine that extracts any subscripts present in a line of the input file author: P J Knight, CCFE, Culham Science Centre isub1 : output integer : first subscript found isub2 : output integer : second subscript found icode : output integer : diagnostic flag This routine extracts any subscripts from the current line of the input file, i.e. if any array elements are specified by the user. It looks at the next non-space character in the line, and if it is a left bracket, it assumes that at least one subscript is to follow and extracts it/them. None
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(out) | :: | isub1 | |||
integer, | intent(out) | :: | isub2 | |||
integer, | intent(out) | :: | icode |
Routine that extracts a variable name from a line of
the input file
author: P J Knight, CCFE, Culham Science Centre
varnam : output string : extracted variable name
varlen : output integer : length of variable name
isub1 : output integer : first subscript found
isub2 : output integer : second subscript found
This routine extracts a variable name from the current line of
the input file. It also extracts any subscripts present.
On exit, the counter iptr
points to the first
character of the value to be assigned to the variable.
If the routine finds an error a value of 0 is returned in
variable varlen
.
None
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(out) | :: | varnam | |||
integer, | intent(out) | :: | varlen | |||
integer, | intent(out) | :: | isub1 | |||
integer, | intent(out) | :: | isub2 |
Routine that checks whether an integer variable lies within the desired range author: P J Knight, CCFE, Culham Science Centre outfile : input integer : Fortran output unit identifier cvar : input string : name of variable varval : input integer : value of variable min_value : input integer : minimum allowed value of variable max_value : input integer : maximum allowed value of variable This routine checks whether an integer variable lies within the range predetermined by the user, and reports an error and stops if it doesn't. None
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | cvar | |||
integer, | intent(in) | :: | varval | |||
integer, | intent(in) | :: | min_value | |||
integer, | intent(in) | :: | max_value |
Routine that checks whether a real variable lies within the desired range author: P J Knight, CCFE, Culham Science Centre cvar : input string : name of variable varval : input real : value of variable min_value : input real : minimum allowed value of variable max_value : input real : maximum allowed value of variable This routine checks whether a real variable lies within the range predetermined by the user, and reports an error and stops if it doesn't. None
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | cvar | |||
real(kind=dp), | intent(in) | :: | varval | |||
real(kind=dp), | intent(in) | :: | min_value | |||
real(kind=dp), | intent(in) | :: | max_value |
Routine that converts a (sub-)string to lowercase author: P J Knight, CCFE, Culham Science Centre string : input string : character string of interest start : optional input integer : starting character for conversion finish : optional input integer : final character for conversion This routine converts the specified section of a string to lowercase. By default, the whole string will be converted. None
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(inout) | :: | string | |||
integer, | intent(in), | optional | :: | start | ||
integer, | intent(in), | optional | :: | finish |