Documentation for module cp_parser_methods

Utility routines to read data from files. Kept as close as possible to the old parser because 1. string handling is a weak point of fortran compilers, and it is easy to write correct things that do not work 2. conversion of old code

source: cp_parser_methods.F
Loading...

Generic procedures:

parser_get_object

public Subroutines/Functions:

Read the next input line and broadcast the input information. Skip (nline-1) lines and skip also all comment lines.
return a description of the part of the file acually parsed
Read the next line from a logical unit "unit" (I/O node only). Skip (nline-1) lines and skip also all comment lines.
Search a string pattern in a file defined by its logical unit number "unit". A case sensitive search is performed, if ignore_case is .FALSE.. begin_line: give back the parser at the beginning of the line matching the search
Skips the whitespaces
FUNCTION
CHARACTER(3)
parser_test_next_token (parser, string_length)
Test next input object. - test_result : "EOL": End of line - test_result : "EOS": End of section - test_result : "FLT": Floating point number - test_result : "INT": Integer number - test_result : "STR": String
Returns a floating point number read from a string including fraction like z1/z2.
Returns an integer number read from a string including products of integer numbers like iz1*iz2*iz3

Generic procedure parser_get_object

...

POINTER
:: parser × × × ×
INTEGER,
INTENT(out)
:: object ×
LOGICAL,
INTENT(out)
:: object ×
REAL(dp),
INTENT(out)
:: object ×
CHARACTER(*),
INTENT(out)
:: object ×
LOGICAL,
INTENT(in),
OPTIONAL
:: newline × × × ×
INTEGER,
INTENT(in),
OPTIONAL
:: skip_lines × × × ×
INTEGER,
INTENT(in),
OPTIONAL
:: string_length × × × ×
LOGICAL,
INTENT(out),
OPTIONAL
:: at_end × × × ×
LOGICAL,
INTENT(in),
OPTIONAL
:: lower_to_upper ×

SUBROUTINEparser_get_next_line(parser, nline, at_end)

Read the next input line and broadcast the input information. Skip (nline-1) lines and skip also all comment lines.

Arguments:
POINTER
:: parser ...
INTEGER,
INTENT(in)
:: nline ...
LOGICAL,
INTENT(out),
OPTIONAL
:: at_end ...

FUNCTIONparser_location(parser)

return a description of the part of the file acually parsed

Return Value ::
Arguments:
POINTER
:: parser the parser

SUBROUTINEparser_read_line(parser, nline, at_end)

Read the next line from a logical unit "unit" (I/O node only). Skip (nline-1) lines and skip also all comment lines.

Arguments:
POINTER
:: parser ...
INTEGER,
INTENT(in)
:: nline ...
LOGICAL,
INTENT(out),
OPTIONAL
:: at_end ...

SUBROUTINEparser_search_string(parser, string, ignore_case, found, line, begin_line, search_from_begin_of_file)

Search a string pattern in a file defined by its logical unit number "unit". A case sensitive search is performed, if ignore_case is .FALSE.. begin_line: give back the parser at the beginning of the line matching the search

Arguments:
POINTER
:: parser ...
CHARACTER(*),
INTENT(in)
:: string ...
LOGICAL,
INTENT(in)
:: ignore_case ...
LOGICAL,
INTENT(out)
:: found ...
CHARACTER(*),
INTENT(out),
OPTIONAL
:: line ...
LOGICAL,
INTENT(in),
OPTIONAL
:: begin_line ...
LOGICAL,
INTENT(in),
OPTIONAL
:: search_from_begin_of_file ...

SUBROUTINEparser_skip_space(parser)

Skips the whitespaces

Arguments:
POINTER
:: parser ...

FUNCTIONparser_test_next_token(parser, string_length)

Test next input object. - test_result : "EOL": End of line - test_result : "EOS": End of section - test_result : "FLT": Floating point number - test_result : "INT": Integer number - test_result : "STR": String

Return Value ::
CHARACTER(3)
Arguments:
POINTER
:: parser ...
INTEGER,
INTENT(in),
OPTIONAL
:: string_length ...

SUBROUTINEread_float_object(string, object, error_message)

Returns a floating point number read from a string including fraction like z1/z2.

Arguments:
CHARACTER(*),
INTENT(in)
:: string ...
REAL(dp),
INTENT(out)
:: object ...
CHARACTER(*),
INTENT(out)
:: error_message ...

SUBROUTINEread_integer_object(string, object, error_message)

Returns an integer number read from a string including products of integer numbers like iz1*iz2*iz3

Arguments:
CHARACTER(*),
INTENT(in)
:: string ...
INTEGER,
INTENT(out)
:: object ...
CHARACTER(*),
INTENT(out)
:: error_message ...

SUBROUTINEparser_get_integer(parser, object, newline, skip_lines, string_length, at_end)

Read an integer number.

Arguments:
POINTER
:: parser ...
INTEGER,
INTENT(out)
:: object ...
LOGICAL,
INTENT(in),
OPTIONAL
:: newline ...
INTEGER,
INTENT(in),
OPTIONAL
:: skip_lines ...
INTEGER,
INTENT(in),
OPTIONAL
:: string_length ...
LOGICAL,
INTENT(out),
OPTIONAL
:: at_end ...

SUBROUTINEparser_get_logical(parser, object, newline, skip_lines, string_length, at_end)

Read a string representing logical object.

Arguments:
POINTER
:: parser ...
LOGICAL,
INTENT(out)
:: object ...
LOGICAL,
INTENT(in),
OPTIONAL
:: newline ...
INTEGER,
INTENT(in),
OPTIONAL
:: skip_lines ...
INTEGER,
INTENT(in),
OPTIONAL
:: string_length ...
LOGICAL,
INTENT(out),
OPTIONAL
:: at_end ...

SUBROUTINEparser_get_real(parser, object, newline, skip_lines, string_length, at_end)

Read a floating point number.

Arguments:
POINTER
:: parser ...
REAL(dp),
INTENT(out)
:: object ...
LOGICAL,
INTENT(in),
OPTIONAL
:: newline ...
INTEGER,
INTENT(in),
OPTIONAL
:: skip_lines ...
INTEGER,
INTENT(in),
OPTIONAL
:: string_length ...
LOGICAL,
INTENT(out),
OPTIONAL
:: at_end ...

SUBROUTINEparser_get_string(parser, object, lower_to_upper, newline, skip_lines, string_length, at_end)

Read a string.

Arguments:
POINTER
:: parser ...
CHARACTER(*),
INTENT(out)
:: object ...
LOGICAL,
INTENT(in),
OPTIONAL
:: lower_to_upper ...
LOGICAL,
INTENT(in),
OPTIONAL
:: newline ...
INTEGER,
INTENT(in),
OPTIONAL
:: skip_lines ...
INTEGER,
INTENT(in),
OPTIONAL
:: string_length ...
LOGICAL,
INTENT(out),
OPTIONAL
:: at_end ...