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
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.
64 raw_line=adjustl(raw_line)
65 if (len_trim(raw_line) .gt. 0)
then 84 character(*),
intent(in) :: raw_line
85 logical,
intent(in) :: is_user_file
86 logical,
intent(inout) :: found_global
88 integer :: mode, start_split, end_split
89 character(len=10000) :: config_key, config_value
93 if (mode .ge. 1 .and. raw_line(1:1) .ne.
'#' .and. raw_line(1:1) .ne.
'!')
then 94 config_key=raw_line(1:start_split)
95 config_value=adjustl(raw_line(end_split:))
104 if (is_user_file .and. .not. found_global) &
132 character(*),
intent(in) :: configuration_value
145 character(*),
intent(in) :: raw_line
146 integer,
intent(out) :: mode, start_split, end_split
148 integer :: split_point
150 split_point=index(raw_line,
"+=")
151 if (split_point .eq. 0) split_point=index(raw_line,
"=+")
152 if (split_point .ne. 0)
then 154 start_split=split_point-1
155 end_split=split_point+2
157 split_point=index(raw_line,
"=")
158 if (split_point .ne. 0)
then 160 start_split=split_point-1
161 end_split=split_point+1
175 type(hashmap_type),
intent(inout) :: options_database
176 character(*),
intent(in) :: config_key, config_value
177 integer,
intent(in) :: mode
179 integer :: array_index, key_end_index
181 if (mode .eq. 2)
then 182 array_index=options_get_array_size(options_database, config_key)+1
183 key_end_index=len(config_key)
186 key_end_index=scan(config_key,
"(")-1
190 trim(adjustl(config_value)), array_index)
197 character(*),
intent(in) :: config_key
199 integer :: open_brace_index, close_brace_index
201 open_brace_index=scan(config_key,
"(")
202 close_brace_index=scan(config_key,
")")
204 if (close_brace_index - open_brace_index .lt. 2)
then 205 call log_master_log(log_error,
"Array element format for key "//&
206 trim(config_key)//
" but no element provided")
217 character(*),
intent(in) :: config_key
221 loc=scan(config_key,
"(")
223 loc=scan(config_key,
")")
238 type(hashmap_type),
intent(inout) :: options_database
239 character(*),
intent(in) :: config_key, config_value
240 integer,
intent(in) :: mode
242 character(len=len(config_value)) :: raw_value
243 character(len=len(config_key)) :: parsed_config_key
245 integer :: comma_posn, index
248 call options_remove_key(options_database, config_key)
251 parsed_config_key=config_key(:scan(config_key,
"(")-1)
253 parsed_config_key=config_key
256 else if (mode==2)
then 257 index=options_get_array_size(options_database, config_key)+1
260 raw_value=config_value
261 comma_posn=scan(raw_value,
",")
262 do while (comma_posn .gt. 0)
264 trim(adjustl(raw_value(1:comma_posn-1))), index)
265 raw_value=raw_value(comma_posn+1:)
266 comma_posn=scan(raw_value,
",")
270 trim(adjustl(raw_value(1:))), index)
280 type(hashmap_type),
intent(inout) :: options_database
281 character(*),
intent(in) :: config_key, config_value
282 integer,
intent(in),
optional :: array_index
284 integer :: comment_location
285 character(len=len(config_value)) :: parsed_value
287 comment_location=scan(config_value,
"#")
288 if (comment_location == 0) comment_location=scan(config_value,
"!")
289 if (comment_location .gt. 0)
then 290 parsed_value=config_value(:comment_location-1)
292 parsed_value=config_value
295 if (conv_is_logical(trim(parsed_value)))
then 296 if (
present(array_index))
then 297 call options_add(options_database, trim(config_key), &
298 conv_to_logical(trim(parsed_value)), &
299 array_index=array_index)
301 call options_add(options_database, trim(config_key), &
302 conv_to_logical(trim(parsed_value)))
304 else if (conv_is_integer(parsed_value))
then 305 if (
present(array_index))
then 306 call options_add(options_database, trim(config_key), &
307 conv_to_integer(trim(parsed_value)), &
308 array_index=array_index)
310 call options_add(options_database, trim(config_key), &
311 conv_to_integer(trim(parsed_value)))
313 else if (conv_is_real(parsed_value))
then 314 if (
present(array_index))
then 315 call options_add(options_database, trim(config_key), &
316 conv_single_real_to_double(conv_to_real(trim(parsed_value))), array_index=array_index)
318 call options_add(options_database, trim(config_key), conv_single_real_to_double(conv_to_real(trim(parsed_value))))
321 if (
present(array_index))
then 322 call options_add(options_database, trim(config_key), &
325 call options_add(options_database, trim(config_key), &
337 character(len=*),
intent(in) :: string_value
338 character(len=len(string_value)) :: remove_string_quotation
340 integer :: quotation_index_start, quotation_index_end
342 quotation_index_start=scan(string_value,
"""")
343 if (quotation_index_start .gt. 0)
then 344 quotation_index_end=scan(string_value(quotation_index_start+1:),
"""")+&
345 quotation_index_start
346 if (quotation_index_end .gt. 0)
then 347 remove_string_quotation=string_value(quotation_index_start+1:quotation_index_end-1)
349 remove_string_quotation=string_value
352 remove_string_quotation=string_value
Generic add interface for adding different types of data to the databases.
logical function parse_global_configuration_if_available(options_database)
Parses the global configuration file if it is available and calls on to add all of this to the option...
subroutine process_configuration_array(options_database, config_key, config_value, mode)
Will process a configuration array of values such as v1,v2,v3,v4.
integer function, public options_get_array_size(options_database, key)
Gets the size of the array held in the options database corresponding to a specific key...
logical function is_key_array_index_specifier(config_key)
Determines whether a configuration key represents a specific array element, i.e. is of the form k(n) ...
integer, parameter, public log_error
Only log ERROR messages.
character(len=string_length) function, public options_get_string(options_database, key, index)
Retrieves a string value from the database that matches the provided key.
subroutine, public log_master_log(level, message)
Will log just from the master process.
A hashmap structure, the same as a map but uses hashing for greatly improved performance when storing...
Conversion between common inbuilt FORTRAN data types.
subroutine, public options_remove_key(options_database, key)
Removes a specific key from the options database, if it is an array then the entire array is removed...
integer, parameter global_file_id
recursive subroutine process_configuration_line(options_database, raw_line, is_user_file, found_global)
Processes a line from the configuration file, breaks it up into its key and value and depending upon ...
Converts data types to logical.
character(len=len(string_value)) function remove_string_quotation(string_value)
Removes quotations from a string if these are included, regardless of before it will return the conte...
Determines whether a data item can be represented as a logical or not.
subroutine get_mode_and_split_points_from_line(raw_line, mode, start_split, end_split)
Processes a line to determine the mode (replace or additive) and where the split point is between the...
Collection data structures.
Determines whether a data item can be represented as an integer or not.
Converts data types to real.
subroutine handle_array_element_set(options_database, config_key, config_value, mode)
Handles setting a specific array element, when the key has something like k(n) - n being the index to...
recursive subroutine process_configuration_file(options_database, filename, is_user_file, file_id)
Will actually open a specific file and read it in line by line, parsing this and storing the configur...
logical function has_multiple_values(configuration_value)
Determines if a specific string contains multiple values such as str1, str2, str3.
Determines whether a data item can be represented as a real or not.
Manages the options database. Contains administration functions and deduce runtime options from the c...
subroutine, public parse_configuration_file(options_database, user_configuration_file)
Parses a specific configuration and adds the contents into the options database.
Parses a configuration file and loads the contents into the options database which can then be intero...
integer function get_key_array_index(config_key)
Given a configuration key of the form k(n), this returns the n.
Converts data types to integers.
subroutine store_configuration(options_database, config_key, config_value, array_index)
Stores a specific configuration by determining the type of a value and calling on to the options data...
integer, parameter user_file_id
logical function, public options_has_key(options_database, key)
Determines whether a specific key is in the database.
real(kind=double_precision) function, public conv_single_real_to_double(input_real)
Converts from a single to double precision real. This applies some rounding to a certain number of de...