A utility to parse information in an ASCII file.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| type(entry_obj), | public, | allocatable | :: | entries(:) |
Entries in file |
Finalizes object and frees allocated memory.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(parser_obj), | intent(inout) | :: | this |
Parser object |
Reads 0D (scalar) values of kind real, integer, logical, or character string. If label is not found and the optional default is provided, the value will be set to the default value. If the label is not found and there is no optional default, this subroutine will return an error.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(parser_obj), | intent(inout) | :: | this |
Parser object |
||
| character(len=*), | intent(in) | :: | label |
Label |
||
| class(*), | intent(out) | :: | value |
Value to return |
||
| class(*), | intent(in), | optional | :: | default |
Default value to return in case label is not found |
Reads 1D (array) values of kind real, integer, logical, or character string. If label is not found and the optional default is provided, the value will be set to the default value. If the label is not found and there is no optional default, this subroutine will return an error.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(parser_obj), | intent(inout) | :: | this |
Parser object |
||
| character(len=*), | intent(in) | :: | label |
Label |
||
| class(*), | intent(out) | :: | value(:) |
Value to return |
||
| class(*), | intent(in), | optional | :: | default(:) |
Default value to return in case label is not found |
Initializes the parser object.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(parser_obj), | intent(inout) | :: | this |
Parser object |
Checks whether a label was found when parsing the file.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(parser_obj), | intent(in) | :: | this |
Parser object |
||
| character(len=*), | intent(in) | :: | label |
label to look for |
Result
Parses an ASCII file. This subroutine will identify all entries in the file (label-value pairs) and store them internally. Users can specify the filename using the optional optInput variable. Otherwise, the default filename is 'input'.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(parser_obj), | intent(inout) | :: | this |
Parser object |
||
| character(len=*), | intent(in), | optional | :: | optInput |
Optional input file name |
Prints all variables found in the parsed file.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(parser_obj), | intent(inout) | :: | this |
Parser object |
Resizes entries array to add a new entry.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(parser_obj), | intent(inout) | :: | this |
Parser object |
||
| type(entry_obj), | intent(in) | :: | entry |
New entrysize |
Sets 0D (scalar) value equal to 0D (scalar) default.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(*), | intent(out) | :: | value |
Value to return |
||
| class(*), | intent(in) | :: | default |
Default value to return in case label is not found |
Sets 1D (array) values equal to 1D (array) defaults.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(*), | intent(out) | :: | value(:) |
Value to return |
||
| class(*), | intent(in) | :: | default(:) |
Default value to return in case label is not found |
Returns ID of label in entries array. Returns 0 if label not found.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(parser_obj), | intent(in) | :: | this |
Parser object |
||
| character(len=*), | intent(in) | :: | label |
label to look for |
Parses a line by finding the label-value pair and storing it as a new entry.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(parser_obj), | intent(inout) | :: | this |
Parser object |
||
| character(len=MAX_LINE_SIZE), | intent(inout) | :: | line |
A line from the input file |
Sets 0D (scalar) value equal to 0D (scalar) default.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(*), | intent(out) | :: | value |
Value to return |
||
| class(*), | intent(in) | :: | default |
Default value to return in case label is not found |
Sets 1D (array) values equal to 1D (array) defaults.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(*), | intent(out) | :: | value(:) |
Value to return |
||
| class(*), | intent(in) | :: | default(:) |
Default value to return in case label is not found |
Fomats a line by removing comments and replacing tabs with spaces.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=MAX_LINE_SIZE), | intent(inout) | :: | line |
A line from the input file |
Reads 0D (scalar) values of kind real, integer, logical, or character string. If label is not found and the optional default is provided, the value will be set to the default value. If the label is not found and there is no optional default, this subroutine will return an error.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(parser_obj), | intent(inout) | :: | this |
Parser object |
||
| character(len=*), | intent(in) | :: | label |
Label |
||
| class(*), | intent(out) | :: | value |
Value to return |
||
| class(*), | intent(in), | optional | :: | default |
Default value to return in case label is not found |
Reads 1D (array) values of kind real, integer, logical, or character string. If label is not found and the optional default is provided, the value will be set to the default value. If the label is not found and there is no optional default, this subroutine will return an error.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(parser_obj), | intent(inout) | :: | this |
Parser object |
||
| character(len=*), | intent(in) | :: | label |
Label |
||
| class(*), | intent(out) | :: | value(:) |
Value to return |
||
| class(*), | intent(in), | optional | :: | default(:) |
Default value to return in case label is not found |
type :: parser_obj !> A utility to parse information in an ASCII file. type(entry_obj), allocatable :: entries(:) !! Entries in file contains procedure :: Initialize => parser_obj_Init procedure :: Finalize => parser_obj_Final procedure :: ParseFile => parser_obj_ParseFile generic :: Get => parser_obj_read0D,parser_obj_read1D procedure :: IsDefined => parser_obj_IsDefined procedure :: Print => parser_obj_Print ! Internal/private procedures procedure, private :: ParseLine => parser_obj_ParseLine procedure, private :: AddEntry => parser_obj_AddEntry procedure, private :: FetchLabelID => parser_obj_FetchLabelID generic , private :: AssignDefault => parser_obj_AssignDefault0D,parser_obj_AssignDefault1D procedure, private,nopass :: parser_obj_ReformatLine procedure, private :: parser_obj_read0D procedure, private :: parser_obj_read1D procedure, private,nopass :: parser_obj_AssignDefault0D procedure, private,nopass :: parser_obj_AssignDefault1D end type parser_obj