28 character(*),
intent(in) :: user_configuration_file
43 character(*),
intent(in) :: filename
44 integer,
intent(in) :: file_id
45 logical,
intent(in) :: is_user_file
47 integer :: file_status, comment_point
48 logical :: continue_parsing, found_global
49 character(len=10000) :: raw_line
52 continue_parsing=.true.
53 open(unit=file_id, file=filename, status=
'old', access=
'sequential', form=
'formatted',&
54 action=
'read', iostat=file_status)
55 if (file_status .ne. 0)
then
59 do while (continue_parsing)
60 read(file_id,
'(A)', iostat=file_status) raw_line
61 if (is_iostat_end(file_status))
then
62 continue_parsing=.false.
67 comment_point=index(raw_line,
'#')
68 if (comment_point .eq. 0) comment_point=index(raw_line,
'!')
69 if (comment_point .ne. 0) raw_line = raw_line(:comment_point - 1)
72 raw_line=adjustl(raw_line)
73 if (len_trim(raw_line) .gt. 0)
then
92 character(*),
intent(in) :: raw_line
93 logical,
intent(in) :: is_user_file
94 logical,
intent(inout) :: found_global
96 integer :: mode, start_split, end_split
97 character(len=10000) :: config_key, config_value
101 if (mode .ge. 1 .and. raw_line(1:1) .ne.
'#' .and. raw_line(1:1) .ne.
'!')
then
102 config_key=raw_line(1:start_split)
103 config_value=adjustl(raw_line(end_split:))
117 if (is_user_file .and. .not. found_global) &
145 character(*),
intent(in) :: configuration_value
158 character(*),
intent(in) :: raw_line
159 integer,
intent(out) :: mode, start_split, end_split
161 integer :: split_point
163 split_point=index(raw_line,
"+=")
164 if (split_point .eq. 0) split_point=index(raw_line,
"=+")
165 if (split_point .ne. 0)
then
167 start_split=split_point-1
168 end_split=split_point+2
170 split_point=index(raw_line,
"=")
171 if (split_point .ne. 0)
then
173 start_split=split_point-1
174 end_split=split_point+1
189 character(*),
intent(in) :: config_key, config_value
190 integer,
intent(in) :: mode
192 integer :: array_index, key_end_index
194 if (mode .eq. 2)
then
196 key_end_index=len(config_key)
199 key_end_index=scan(config_key,
"(")-1
203 trim(adjustl(config_value)), array_index)
210 character(*),
intent(in) :: config_key
212 integer :: open_brace_index, close_brace_index
214 open_brace_index=scan(config_key,
"(")
215 close_brace_index=scan(config_key,
")")
217 if (close_brace_index - open_brace_index .lt. 2)
then
219 trim(config_key)//
" but no element provided")
230 character(*),
intent(in) :: config_key
234 loc=scan(config_key,
"(")
236 loc=scan(config_key,
")")
252 character(*),
intent(in) :: config_key, config_value
253 integer,
intent(in) :: mode
255 character(len=len(config_value)) :: raw_value
256 character(len=len(config_key)) :: parsed_config_key
258 integer :: comma_posn, index
264 parsed_config_key=config_key(:scan(config_key,
"(")-1)
266 parsed_config_key=config_key
269 else if (mode==2)
then
273 raw_value=config_value
274 comma_posn=scan(raw_value,
",")
275 do while (comma_posn .gt. 0)
277 trim(adjustl(raw_value(1:comma_posn-1))), index)
278 raw_value=raw_value(comma_posn+1:)
279 comma_posn=scan(raw_value,
",")
283 trim(adjustl(raw_value(1:))), index)
294 character(*),
intent(in) :: config_key, config_value
295 integer,
intent(in),
optional :: array_index
297 integer :: comment_location
298 character(len=len(config_value)) :: parsed_value
300 comment_location=scan(config_value,
"#")
301 if (comment_location == 0) comment_location=scan(config_value,
"!")
302 if (comment_location .gt. 0)
then
303 parsed_value=config_value(:comment_location-1)
305 parsed_value=config_value
309 if (
present(array_index))
then
310 call options_add(options_database, trim(config_key), &
312 array_index=array_index)
314 call options_add(options_database, trim(config_key), &
318 if (
present(array_index))
then
319 call options_add(options_database, trim(config_key), &
321 array_index=array_index)
323 call options_add(options_database, trim(config_key), &
327 if (
present(array_index))
then
328 call options_add(options_database, trim(config_key), &
334 if (
present(array_index))
then
335 call options_add(options_database, trim(config_key), &
338 call options_add(options_database, trim(config_key), &
350 character(len=*),
intent(in) :: string_value
353 integer :: quotation_index_start, quotation_index_end
355 quotation_index_start=scan(string_value,
"""")
356 if (quotation_index_start .gt. 0)
then
357 quotation_index_end=scan(string_value(quotation_index_start+1:),
"""")+&
358 quotation_index_start
359 if (quotation_index_end .gt. 0)
then