43#include "../base/base_uses.f90"
52 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'cp_parser_methods'
55 MODULE PROCEDURE parser_get_integer, &
75 res =
", File: '"//trim(parser%input_file_name)//
"', Line: "// &
76 trim(adjustl(
cp_to_string(parser%input_line_number)))// &
78 IF (parser%icol == -1)
THEN
79 res(len_trim(res):) =
" (EOF)"
80 ELSE IF (max(1, parser%icol1) <= parser%icol2)
THEN
81 res(len_trim(res):) =
", Chunk: <"// &
82 parser%input_line(max(1, parser%icol1):parser%icol2)//
">"
93 SUBROUTINE parser_store_status(parser)
97 cpassert(
ASSOCIATED(parser%status))
98 parser%status%in_use = .true.
99 parser%status%old_input_line = parser%input_line
100 parser%status%old_input_line_number = parser%input_line_number
101 parser%status%old_icol = parser%icol
102 parser%status%old_icol1 = parser%icol1
103 parser%status%old_icol2 = parser%icol2
107 END SUBROUTINE parser_store_status
115 SUBROUTINE parser_retrieve_status(parser)
120 IF (parser%buffer%buffer_id /= parser%status%buffer%buffer_id)
THEN
123 parser%status%in_use = .false.
124 parser%input_line = parser%status%old_input_line
125 parser%input_line_number = parser%status%old_input_line_number
126 parser%icol = parser%status%old_icol
127 parser%icol1 = parser%status%old_icol1
128 parser%icol2 = parser%status%old_icol2
133 END SUBROUTINE parser_retrieve_status
149 INTEGER,
INTENT(IN) :: nline
150 LOGICAL,
INTENT(out),
OPTIONAL :: at_end
152 CHARACTER(LEN=*),
PARAMETER :: routinen =
'parser_read_line'
154 INTEGER :: handle, iline, istat
156 CALL timeset(routinen, handle)
158 IF (
PRESENT(at_end)) at_end = .false.
162 CALL parser_get_line_from_buffer(parser, istat)
167 IF (
PRESENT(at_end))
THEN
176 CALL cp_abort(__location__, &
177 "An I/O error occurred (IOSTAT = "// &
181 CALL timestop(handle)
187 IF (nline > 0) parser%icol = 0
189 CALL timestop(handle)
199 SUBROUTINE parser_get_line_from_buffer(parser, istat)
202 INTEGER,
INTENT(OUT) :: istat
206 IF (parser%buffer%present_line_number == parser%buffer%size)
THEN
207 IF (
ASSOCIATED(parser%buffer%sub_buffer))
THEN
212 CALL parser_read_line_low(parser)
215 parser%buffer%present_line_number = parser%buffer%present_line_number + 1
216 parser%input_line_number = parser%buffer%input_line_numbers(parser%buffer%present_line_number)
217 parser%input_line = parser%buffer%input_lines(parser%buffer%present_line_number)
218 IF ((parser%buffer%istat /= 0) .AND. &
219 (parser%buffer%last_line_number == parser%buffer%present_line_number))
THEN
220 istat = parser%buffer%istat
223 END SUBROUTINE parser_get_line_from_buffer
231 SUBROUTINE parser_read_line_low(parser)
235 CHARACTER(LEN=*),
PARAMETER :: routinen =
'parser_read_line_low'
237 INTEGER :: handle, iline, imark, islen, istat, &
238 last_buffered_line_number
239 LOGICAL :: non_white_found, &
240 this_line_is_white_or_comment
242 CALL timeset(routinen, handle)
244 parser%buffer%input_lines =
""
245 IF (parser%para_env%is_source())
THEN
248 parser%buffer%buffer_id = parser%buffer%buffer_id + 1
249 parser%buffer%present_line_number = 0
250 parser%buffer%last_line_number = parser%buffer%size
251 last_buffered_line_number = parser%buffer%input_line_numbers(parser%buffer%size)
252 DO WHILE (iline /= parser%buffer%size)
255 last_buffered_line_number = last_buffered_line_number + 1
258 parser%buffer%input_line_numbers(iline) = last_buffered_line_number
259 READ (unit=parser%input_unit, fmt=
"(A)", iostat=istat) parser%buffer%input_lines(iline)
265 islen = len_trim(parser%buffer%input_lines(iline))
266 this_line_is_white_or_comment = is_comment_line(parser, parser%buffer%input_lines(iline))
267 IF (.NOT. this_line_is_white_or_comment .AND. parser%apply_preprocessing)
THEN
268 imark = index(parser%buffer%input_lines(iline) (1:islen),
"$")
271 parser%input_file_name, parser%buffer%input_line_numbers(iline))
272 islen = len_trim(parser%buffer%input_lines(iline))
274 imark = index(parser%buffer%input_lines(iline) (1:islen),
"@")
277 parser%input_file_name, parser%buffer%input_line_numbers(iline), &
279 islen = len_trim(parser%buffer%input_lines(iline))
281 last_buffered_line_number = 0
287 this_line_is_white_or_comment = is_comment_line(parser, parser%buffer%input_lines(iline))
289 ELSE IF (istat < 0)
THEN
290 IF (parser%inpp%io_stack_level > 0)
THEN
293 parser%buffer%input_line_numbers(iline), parser%input_unit)
295 last_buffered_line_number = parser%buffer%input_line_numbers(iline)
303 parser%buffer%istat = istat
304 parser%buffer%last_line_number = iline
305 parser%buffer%input_line_numbers(iline:) = 0
306 parser%buffer%input_lines(iline:) =
""
311 IF (.NOT. parser%parse_white_lines)
THEN
312 non_white_found = .NOT. this_line_is_white_or_comment
314 non_white_found = .true.
316 IF (.NOT. non_white_found)
THEN
318 last_buffered_line_number = last_buffered_line_number - 1
323 CALL broadcast_input_information(parser)
325 CALL timestop(handle)
327 END SUBROUTINE parser_read_line_low
336 SUBROUTINE broadcast_input_information(parser)
340 CHARACTER(len=*),
PARAMETER :: routinen =
'broadcast_input_information'
345 CALL timeset(routinen, handle)
347 para_env => parser%para_env
348 IF (para_env%num_pe > 1)
THEN
349 CALL para_env%bcast(parser%buffer%buffer_id)
350 CALL para_env%bcast(parser%buffer%present_line_number)
351 CALL para_env%bcast(parser%buffer%last_line_number)
352 CALL para_env%bcast(parser%buffer%istat)
353 CALL para_env%bcast(parser%buffer%input_line_numbers)
354 CALL para_env%bcast(parser%buffer%input_lines)
357 CALL timestop(handle)
359 END SUBROUTINE broadcast_input_information
369 ELEMENTAL FUNCTION is_comment_line(parser, line)
RESULT(resval)
372 CHARACTER(LEN=*),
INTENT(IN) :: line
375 CHARACTER(LEN=1) :: thischar
379 DO icol = 1, len(line)
380 thischar = line(icol:icol)
382 IF (.NOT. is_comment(parser, thischar)) resval = .false.
387 END FUNCTION is_comment_line
398 ELEMENTAL FUNCTION is_comment(parser, testchar)
RESULT(resval)
401 CHARACTER(LEN=1),
INTENT(IN) :: testchar
406 IF (any(parser%comment_character == testchar)) resval = .true.
408 END FUNCTION is_comment
423 INTEGER,
INTENT(IN) :: nline
424 LOGICAL,
INTENT(out),
OPTIONAL :: at_end
430 IF (
PRESENT(at_end))
THEN
437 ELSE IF (
PRESENT(at_end))
THEN
459 IF (parser%icol == -1)
THEN
469 parser%icol = parser%icol + 1
472 IF ((parser%icol > len_trim(parser%input_line)) .OR. &
473 is_comment(parser, parser%input_line(parser%icol:parser%icol)))
THEN
480 IF (.NOT.
is_whitespace(parser%input_line(parser%icol:parser%icol)))
THEN
482 IF (parser%input_line(parser%icol:parser%icol) == parser%continuation_character)
THEN
483 inner_loop:
DO i = parser%icol + 1, len_trim(parser%input_line)
485 IF (is_comment(parser, parser%input_line(i:i)))
THEN
489 parser%icol2 = len_trim(parser%input_line)
490 CALL cp_abort(__location__, &
491 "Found a non-blank token which is not a comment after the line continuation character '"// &
497 CALL cp_abort(__location__, &
498 "Unexpected end of file (EOF) found after line continuation"// &
504 parser%icol = parser%icol - 1
505 parser%icol1 = parser%icol
506 parser%icol2 = parser%icol
524 SUBROUTINE parser_next_token(parser, string_length)
527 INTEGER,
INTENT(IN),
OPTIONAL :: string_length
529 CHARACTER(LEN=1) :: token
530 INTEGER :: i, len_trim_inputline, length
533 IF (
PRESENT(string_length))
THEN
535 cpabort(
"string length > max_line_length")
537 length = string_length
544 len_trim_inputline = len_trim(parser%input_line)
551 IF (parser%icol == -1)
THEN
555 length = min(len_trim_inputline - parser%icol1 + 1, length)
556 parser%icol1 = parser%icol + 1
557 parser%icol2 = parser%icol + length
558 i = index(parser%input_line(parser%icol1:parser%icol2), parser%quote_character)
559 IF (i > 0) parser%icol2 = parser%icol + i
560 parser%icol = parser%icol2
567 IF (parser%icol == -1)
THEN
577 parser%icol = parser%icol + 1
580 IF (parser%icol > len_trim_inputline)
THEN
586 token = parser%input_line(parser%icol:parser%icol)
591 ELSE IF (is_comment(parser, token))
THEN
594 parser%first_separator = .true.
596 ELSE IF (token == parser%quote_character)
THEN
598 parser%icol1 = parser%icol + 1
599 parser%icol2 = parser%icol + index(parser%input_line(parser%icol1:), parser%quote_character)
600 IF (parser%icol2 == parser%icol)
THEN
601 parser%icol1 = parser%icol
602 parser%icol2 = parser%icol
603 CALL cp_abort(__location__, &
606 parser%icol = parser%icol2
607 parser%icol2 = parser%icol2 - 1
608 parser%first_separator = .true.
611 ELSE IF (token == parser%continuation_character)
THEN
613 inner_loop1:
DO i = parser%icol + 1, len_trim_inputline
616 ELSE IF (is_comment(parser, parser%input_line(i:i)))
THEN
620 parser%icol2 = len_trim_inputline
621 CALL cp_abort(__location__, &
622 "Found a non-blank token which is not a comment after the line continuation character '"// &
628 CALL cp_abort(__location__, &
629 "Unexpected end of file (EOF) found after line continuation"//trim(
parser_location(parser)))
631 len_trim_inputline = len_trim(parser%input_line)
633 ELSE IF (index(parser%separators, token) > 0)
THEN
634 IF (parser%first_separator)
THEN
635 parser%first_separator = .false.
638 parser%icol1 = parser%icol
639 parser%icol2 = parser%icol
640 CALL cp_abort(__location__, &
641 "Unexpected separator token '"//token// &
645 parser%icol1 = parser%icol
646 parser%first_separator = .true.
654 parser%icol = parser%icol + 1
655 IF (parser%icol > len_trim_inputline)
EXIT outer_loop2
656 token = parser%input_line(parser%icol:parser%icol)
657 IF (
is_whitespace(token) .OR. is_comment(parser, token) .OR. &
658 (token == parser%continuation_character))
THEN
660 ELSE IF (index(parser%separators, token) > 0)
THEN
661 parser%first_separator = .false.
666 parser%icol2 = parser%icol - 1
668 IF (parser%input_line(parser%icol:parser%icol) == &
669 parser%continuation_character) parser%icol = parser%icol2
673 END SUBROUTINE parser_next_token
694 INTEGER,
INTENT(IN),
OPTIONAL :: string_length
695 CHARACTER(LEN=3) :: test_result
697 CHARACTER(LEN=max_line_length) :: error_message, string
699 LOGICAL :: ilist_in_use
705 CALL parser_store_status(parser)
708 ilist_in_use = parser%ilist%in_use .AND. (parser%ilist%ipresent < parser%ilist%iend)
709 IF (ilist_in_use)
THEN
711 CALL parser_retrieve_status(parser)
716 IF (
PRESENT(string_length))
THEN
717 CALL parser_next_token(parser, string_length=string_length)
719 CALL parser_next_token(parser)
723 IF (parser%icol1 > parser%icol2)
THEN
725 CALL parser_retrieve_status(parser)
729 string = parser%input_line(parser%icol1:parser%icol2)
734 CALL parser_retrieve_status(parser)
739 IF (string(1:n) == parser%end_section)
THEN
741 CALL parser_retrieve_status(parser)
748 IF (len_trim(error_message) == 0)
THEN
750 CALL parser_retrieve_status(parser)
757 IF (len_trim(error_message) == 0)
THEN
759 CALL parser_retrieve_status(parser)
764 CALL parser_retrieve_status(parser)
786 search_from_begin_of_file)
789 CHARACTER(LEN=*),
INTENT(IN) :: string
790 LOGICAL,
INTENT(IN) :: ignore_case
791 LOGICAL,
INTENT(OUT) :: found
792 CHARACTER(LEN=*),
INTENT(OUT),
OPTIONAL :: line
793 LOGICAL,
INTENT(IN),
OPTIONAL :: begin_line, search_from_begin_of_file
795 CHARACTER(LEN=LEN(string)) :: pattern
796 CHARACTER(LEN=max_line_length+1) :: current_line
798 LOGICAL :: at_end, begin, do_reset
803 IF (
PRESENT(begin_line)) begin = begin_line
804 IF (
PRESENT(search_from_begin_of_file)) do_reset = search_from_begin_of_file
805 IF (
PRESENT(line)) line =
""
819 current_line = parser%input_line
820 IF (ignore_case)
CALL uppercase(current_line)
821 ipattern = index(current_line, trim(pattern))
823 IF (ipattern > 0)
THEN
825 parser%icol = ipattern - 1
826 IF (
PRESENT(line))
THEN
827 IF (len(line) < len_trim(parser%input_line))
THEN
828 CALL cp_warn(__location__, &
829 "The returned input line has more than "// &
831 " characters and is therefore too long to fit in the "// &
832 "specified variable"// &
842 IF (begin) parser%icol = 0
846 IF (
PRESENT(line)) line = parser%input_line
847 IF (.NOT. begin)
CALL parser_next_token(parser)
863 ELEMENTAL FUNCTION integer_object(string)
RESULT(contains_integer_object)
865 CHARACTER(LEN=*),
INTENT(IN) :: string
866 LOGICAL :: contains_integer_object
868 INTEGER :: i, idots, istar, n
870 contains_integer_object = .true.
874 contains_integer_object = .false.
878 idots = index(string(1:n),
"..")
879 istar = index(string(1:n),
"*")
882 contains_integer_object = is_integer(string(1:idots - 1)) .AND. &
883 is_integer(string(idots + 2:n))
884 ELSE IF (istar /= 0)
THEN
886 DO WHILE (istar /= 0)
887 IF (.NOT. is_integer(string(i:i + istar - 2)))
THEN
888 contains_integer_object = .false.
892 istar = index(string(i:n),
"*")
894 contains_integer_object = is_integer(string(i:n))
896 contains_integer_object = is_integer(string(1:n))
899 END FUNCTION integer_object
906 ELEMENTAL FUNCTION is_integer(string)
RESULT(check)
908 CHARACTER(LEN=*),
INTENT(IN) :: string
921 IF ((index(
"+-", string(1:1)) > 0) .AND. (n == 1))
THEN
926 IF (index(
"+-0123456789", string(1:1)) == 0)
THEN
932 IF (index(
"0123456789", string(i:i)) == 0)
THEN
938 END FUNCTION is_integer
952 SUBROUTINE parser_get_integer(parser, object, newline, skip_lines, &
953 string_length, at_end)
956 INTEGER,
INTENT(OUT) :: object
957 LOGICAL,
INTENT(IN),
OPTIONAL :: newline
958 INTEGER,
INTENT(IN),
OPTIONAL :: skip_lines, string_length
959 LOGICAL,
INTENT(out),
OPTIONAL :: at_end
961 CHARACTER(LEN=max_line_length) :: error_message
965 IF (
PRESENT(skip_lines))
THEN
971 IF (
PRESENT(newline))
THEN
972 IF (newline) nline = nline + 1
976 IF (
PRESENT(at_end))
THEN
978 IF (my_at_end)
RETURN
979 ELSE IF (my_at_end)
THEN
983 IF (parser%ilist%in_use)
THEN
986 IF (
PRESENT(string_length))
THEN
987 CALL parser_next_token(parser, string_length=string_length)
989 CALL parser_next_token(parser)
991 IF (parser%icol1 > parser%icol2)
THEN
992 parser%icol1 = parser%icol
993 parser%icol2 = parser%icol
994 CALL cp_abort(__location__, &
995 "An integer type object was expected, found end of line"// &
999 IF (index(parser%input_line(parser%icol1:parser%icol2),
"..") /= 0)
THEN
1000 CALL ilist_setup(parser%ilist, parser%input_line(parser%icol1:parser%icol2))
1004 IF (integer_object(parser%input_line(parser%icol1:parser%icol2)))
THEN
1005 IF (parser%ilist%in_use)
THEN
1006 object = parser%ilist%ipresent
1009 CALL read_integer_object(parser%input_line(parser%icol1:parser%icol2), object, error_message)
1010 IF (len_trim(error_message) > 0)
THEN
1015 CALL cp_abort(__location__, &
1016 "An integer type object was expected, found <"// &
1017 parser%input_line(parser%icol1:parser%icol2)//
">"// &
1021 END SUBROUTINE parser_get_integer
1037 SUBROUTINE parser_get_logical(parser, object, newline, skip_lines, &
1038 string_length, at_end)
1041 LOGICAL,
INTENT(OUT) :: object
1042 LOGICAL,
INTENT(IN),
OPTIONAL :: newline
1043 INTEGER,
INTENT(IN),
OPTIONAL :: skip_lines, string_length
1044 LOGICAL,
INTENT(out),
OPTIONAL :: at_end
1046 CHARACTER(LEN=max_line_length) :: input_string
1047 INTEGER :: input_string_length, nline
1048 LOGICAL :: my_at_end
1050 cpassert(.NOT. parser%ilist%in_use)
1051 IF (
PRESENT(skip_lines))
THEN
1057 IF (
PRESENT(newline))
THEN
1058 IF (newline) nline = nline + 1
1062 IF (
PRESENT(at_end))
THEN
1064 IF (my_at_end)
RETURN
1065 ELSE IF (my_at_end)
THEN
1069 IF (
PRESENT(string_length))
THEN
1070 CALL parser_next_token(parser, string_length=string_length)
1072 CALL parser_next_token(parser)
1075 input_string_length = parser%icol2 - parser%icol1 + 1
1077 IF (input_string_length == 0)
THEN
1078 parser%icol1 = parser%icol
1079 parser%icol2 = parser%icol
1080 CALL cp_abort(__location__, &
1081 "A string representing a logical object was expected, found end of line"// &
1085 input_string(:input_string_length) = parser%input_line(parser%icol1:parser%icol2)
1089 SELECT CASE (trim(input_string))
1090 CASE (
"0",
"F",
".F.",
"FALSE",
".FALSE.",
"N",
"NO",
"OFF")
1092 CASE (
"1",
"T",
".T.",
"TRUE",
".TRUE.",
"Y",
"YES",
"ON")
1095 CALL cp_abort(__location__, &
1096 "A string representing a logical object was expected, found <"// &
1100 END SUBROUTINE parser_get_logical
1114 SUBROUTINE parser_get_real(parser, object, newline, skip_lines, string_length, &
1118 REAL(KIND=
dp),
INTENT(OUT) :: object
1119 LOGICAL,
INTENT(IN),
OPTIONAL :: newline
1120 INTEGER,
INTENT(IN),
OPTIONAL :: skip_lines, string_length
1121 LOGICAL,
INTENT(out),
OPTIONAL :: at_end
1123 CHARACTER(LEN=max_line_length) :: error_message
1125 LOGICAL :: my_at_end
1127 cpassert(.NOT. parser%ilist%in_use)
1129 IF (
PRESENT(skip_lines))
THEN
1135 IF (
PRESENT(newline))
THEN
1136 IF (newline) nline = nline + 1
1140 IF (
PRESENT(at_end))
THEN
1142 IF (my_at_end)
RETURN
1143 ELSE IF (my_at_end)
THEN
1147 IF (
PRESENT(string_length))
THEN
1148 CALL parser_next_token(parser, string_length=string_length)
1150 CALL parser_next_token(parser)
1153 IF (parser%icol1 > parser%icol2)
THEN
1154 parser%icol1 = parser%icol
1155 parser%icol2 = parser%icol
1156 CALL cp_abort(__location__, &
1157 "A floating point type object was expected, found end of the line"// &
1162 CALL read_float_object(parser%input_line(parser%icol1:parser%icol2), object, error_message)
1163 IF (len_trim(error_message) > 0)
THEN
1167 END SUBROUTINE parser_get_real
1182 SUBROUTINE parser_get_string(parser, object, lower_to_upper, newline, skip_lines, &
1183 string_length, at_end)
1186 CHARACTER(LEN=*),
INTENT(OUT) :: object
1187 LOGICAL,
INTENT(IN),
OPTIONAL :: lower_to_upper, newline
1188 INTEGER,
INTENT(IN),
OPTIONAL :: skip_lines, string_length
1189 LOGICAL,
INTENT(out),
OPTIONAL :: at_end
1191 INTEGER :: input_string_length, nline
1192 LOGICAL :: my_at_end
1195 cpassert(.NOT. parser%ilist%in_use)
1196 IF (
PRESENT(skip_lines))
THEN
1202 IF (
PRESENT(newline))
THEN
1203 IF (newline) nline = nline + 1
1207 IF (
PRESENT(at_end))
THEN
1209 IF (my_at_end)
RETURN
1210 ELSE IF (my_at_end)
THEN
1211 CALL cp_abort(__location__, &
1215 IF (
PRESENT(string_length))
THEN
1216 CALL parser_next_token(parser, string_length=string_length)
1218 CALL parser_next_token(parser)
1221 input_string_length = parser%icol2 - parser%icol1 + 1
1223 IF (input_string_length <= 0)
THEN
1224 CALL cp_abort(__location__, &
1225 "A string type object was expected, found end of line"// &
1227 ELSE IF (input_string_length > len(object))
THEN
1228 CALL cp_abort(__location__, &
1229 "The input string <"//parser%input_line(parser%icol1:parser%icol2)// &
1231 " characters and is therefore too long to fit in the "// &
1233 object = parser%input_line(parser%icol1:parser%icol1 + len(object) - 1)
1235 object(:input_string_length) = parser%input_line(parser%icol1:parser%icol2)
1239 IF (
PRESENT(lower_to_upper))
THEN
1240 IF (lower_to_upper)
CALL uppercase(object)
1243 END SUBROUTINE parser_get_string
1260 CHARACTER(LEN=*),
INTENT(IN) :: string
1261 REAL(kind=
dp),
INTENT(OUT) :: object
1262 CHARACTER(LEN=*),
INTENT(OUT) :: error_message
1264 INTEGER,
PARAMETER :: maxlen = 5
1266 CHARACTER(LEN=maxlen) :: func
1267 INTEGER :: i, ileft, iop, iright, is, islash, &
1269 LOGICAL :: parsing_done
1270 REAL(kind=
dp) :: fsign, z
1277 n = len_trim(string)
1279 parsing_done = .false.
1281 DO WHILE (.NOT. parsing_done)
1283 islash = index(string(i:n),
"/")
1284 istar = index(string(i:n),
"*")
1285 IF ((islash == 0) .AND. (istar == 0))
THEN
1288 parsing_done = .true.
1289 ELSE IF ((islash > 0) .AND. (istar > 0))
THEN
1290 iop = min(islash, istar)
1291 ELSE IF (islash > 0)
THEN
1293 ELSE IF (istar > 0)
THEN
1296 ileft = index(string(i:min(n, i + maxlen + 1)),
"(")
1299 is = ichar(string(i:i))
1303 func = string(i + 1:i + ileft - 2)
1306 func = string(i + 1:i + ileft - 2)
1309 func = string(i:i + ileft - 2)
1311 iright = index(string(i:n),
")")
1312 READ (unit=string(i + ileft:i + iright - 2), fmt=*, iostat=istat) z
1313 IF (istat /= 0)
THEN
1314 error_message =
"A floating point type object as argument for function <"// &
1315 trim(func)//
"> is expected, found <"// &
1316 string(i + ileft:i + iright - 2)//
">"
1335 error_message =
"Unknown function <"//trim(func)//
"> found"
1339 READ (unit=string(i:i + iop - 2), fmt=*, iostat=istat) z
1340 IF (istat /= 0)
THEN
1341 error_message =
"A floating point type object was expected, found <"// &
1342 string(i:i + iop - 2)//
">"
1348 ELSE IF (string(i - 1:i - 1) ==
"*")
THEN
1351 IF (z == 0.0_dp)
THEN
1352 error_message =
"Division by zero found <"// &
1353 string(i:i + iop - 2)//
">"
1376 CHARACTER(LEN=*),
INTENT(IN) :: string
1377 INTEGER,
INTENT(OUT) :: object
1378 CHARACTER(LEN=*),
INTENT(OUT) :: error_message
1380 CHARACTER(LEN=20) :: fmtstr
1381 INTEGER :: i, iop, istat, n
1382 INTEGER(KIND=int_8) :: iz8, object8
1383 LOGICAL :: parsing_done
1389 n = len_trim(string)
1391 parsing_done = .false.
1393 DO WHILE (.NOT. parsing_done)
1397 iop = index(string(i:n),
"*")
1404 parsing_done = .true.
1407 IF (iop - 1 > 0)
THEN
1411 WRITE (fmtstr, fmt=
'(A,I0,A)')
'(I', iop - 1,
')'
1412 READ (unit=string(i:i + iop - 2), fmt=fmtstr, iostat=istat) iz8
1414 IF (istat /= 0)
THEN
1415 error_message =
"An integer type object was expected, found <"// &
1416 string(i:i + iop - 2)//
">"
1422 object8 = object8*iz8
1424 IF (abs(object8) > huge(0))
THEN
1425 error_message =
"The specified integer number <"//string(i:i + iop - 2)// &
1426 "> exceeds the allowed range of a 32-bit integer number."
1431 object = int(object8)
various routines to log and control the output. The idea is that decisions about where to log should ...
a module to allow simple buffering of read lines of a parser
recursive subroutine, public copy_buffer_type(buffer_in, buffer_out, force)
Copies buffer types.
subroutine, public initialize_sub_buffer(sub_buffer, buffer)
Initializes sub buffer structure.
subroutine, public finalize_sub_buffer(sub_buffer, buffer)
Finalizes sub buffer structure.
a module to allow simple internal preprocessing in input files.
subroutine, public ilist_update(ilist)
updates the integer listing type
subroutine, public ilist_setup(ilist, token)
setup the integer listing type
subroutine, public ilist_reset(ilist)
updates the integer listing type
a module to allow simple internal preprocessing in input files.
subroutine, public inpp_expand_variables(inpp, input_line, input_file_name, input_line_number)
expand all ${VAR} or $VAR variable entries on the input string (LTR, no nested vars)
subroutine, public inpp_end_include(inpp, input_file_name, input_line_number, input_unit)
Restore older file status from stack after EOF on include file.
subroutine, public inpp_process_directive(inpp, input_line, input_file_name, input_line_number, input_unit)
process internal preprocessor directives like @INCLUDE, @SET, @IF/@ENDIF
Utility routines to read data from files. Kept as close as possible to the old parser because.
subroutine, public parser_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...
elemental subroutine, public read_integer_object(string, object, error_message)
Returns an integer number read from a string including products of integer numbers like iz1*iz2*iz3.
subroutine, public parser_skip_space(parser)
Skips the whitespaces.
subroutine, public parser_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 ...
character(len=3) function, public parser_test_next_token(parser, string_length)
Test next input object.
character(len=default_path_length+default_string_length) function, public parser_location(parser)
return a description of the part of the file actually parsed
elemental subroutine, public read_float_object(string, object, error_message)
Returns a floating point number read from a string including fraction like z1/z2.
subroutine, public parser_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 ...
Utility routines to read data from files. Kept as close as possible to the old parser because.
subroutine, public parser_reset(parser)
Resets the parser: rewinding the unit and re-initializing all parser structures.
Defines the basic variable types.
integer, parameter, public max_line_length
integer, parameter, public int_8
integer, parameter, public dp
integer, parameter, public default_string_length
integer, parameter, public default_path_length
Definition of mathematical constants and functions.
real(kind=dp), parameter, public radians
Interface to the message passing library MPI.
Utilities for string manipulations.
elemental logical function, public is_whitespace(testchar)
returns .true. if the character passed is a whitespace char.
elemental subroutine, public uppercase(string)
Convert all lower case characters in a string to upper case.
stores all the informations relevant to an mpi environment