19 integer,
parameter ::
logical_type=0,& !< Type of logical value data
52 character(len=STRING_LENGTH) function options_key_at(options_database, i)
54 integer,
intent(in) :: i
65 integer,
intent(in) :: i
66 class(*),
pointer :: options_value_at
77 character(len=*),
intent(in) :: key
90 real(kind=DEFAULT_PRECISION) function options_get_real(options_database, key, index)
92 character(len=*),
intent(in) :: key
93 integer,
intent(in),
optional :: index
95 character(len=len(key)+ARRAY_APPEND_SIZE) :: lookup_key
97 if (
present(index))
then 114 character(len=*),
intent(in) :: key
115 real(kind=DEFAULT_PRECISION),
dimension(:),
intent(inout) :: array_data
116 integer,
intent(in),
optional :: from, to
118 integer :: num_elements, i, start, end
121 if (num_elements .gt. 0 .and.
options_has_key(options_database, trim(key)//
"a_size"))
then 122 if (
present(from))
then 127 if (
present(to))
then 132 do i=start, num_elements
137 if (
present(from))
then 138 if (from .gt. 1)
return 140 if (
present(to))
then 141 if (to .lt. 1)
return 154 type(hashmap_type),
intent(inout) :: options_database
155 character(len=*),
intent(in) :: key
156 integer,
intent(in),
optional :: index
158 character(len=len(key)+ARRAY_APPEND_SIZE) :: lookup_key
160 if (
present(index))
then 176 type(hashmap_type),
intent(inout) :: options_database
177 character(len=*),
intent(in) :: key
178 logical,
dimension(:),
intent(inout) :: array_data
179 integer,
intent(in),
optional :: from, to
181 integer :: num_elements, i, start, end
184 if (num_elements .gt. 0 .and.
options_has_key(options_database, trim(key)//
"a_size"))
then 185 if (
present(from))
then 190 if (
present(to))
then 195 do i=start, num_elements
200 if (
present(from))
then 201 if (from .gt. 1)
return 203 if (
present(to))
then 204 if (to .lt. 1)
return 217 type(hashmap_type),
intent(inout) :: options_database
218 character(len=*),
intent(in) :: key
219 integer,
intent(in),
optional :: index
221 character(len=len(key)+ARRAY_APPEND_SIZE) :: lookup_key
223 if (
present(index))
then 239 type(hashmap_type),
intent(inout) :: options_database
240 character(len=*),
intent(in) :: key
241 integer,
dimension(:),
intent(inout) :: array_data
242 integer,
intent(in),
optional :: from, to
244 integer :: num_elements, i, start, end
247 if (num_elements .gt. 0 .and.
options_has_key(options_database, trim(key)//
"a_size"))
then 248 if (
present(from))
then 253 if (
present(to))
then 258 do i=start, num_elements
263 if (
present(from))
then 264 if (from .gt. 1)
return 266 if (
present(to))
then 267 if (to .lt. 1)
return 279 character(len=STRING_LENGTH) function options_get_string(options_database, key, index)
280 type(hashmap_type),
intent(inout) :: options_database
281 character(len=*),
intent(in) :: key
282 integer,
intent(in),
optional :: index
284 character(len=len(key)+ARRAY_APPEND_SIZE) :: lookup_key
286 if (
present(index))
then 302 type(hashmap_type),
intent(inout) :: options_database
303 character(len=*),
intent(in) :: key
304 character(len=STRING_LENGTH),
dimension(:),
intent(inout) :: array_data
305 integer,
intent(in),
optional :: from, to
307 integer :: num_elements, i, start, end
310 if (num_elements .gt. 0 .and.
options_has_key(options_database, trim(key)//
"a_size"))
then 311 if (
present(from))
then 316 if (
present(to))
then 321 do i=start, num_elements
326 if (
present(from))
then 327 if (from .gt. 1)
return 329 if (
present(to))
then 330 if (to .lt. 1)
return 342 type(hashmap_type),
intent(inout) :: options_database
343 character(len=*),
intent(in) :: key
357 type(hashmap_type),
intent(inout) :: options_database
359 integer :: i, arguments, equals_posn, type_of_config
360 character(len=LONG_STRING_LENGTH) :: specific_arg
362 arguments = command_argument_count()
365 call get_command_argument(i,
value = specific_arg)
366 specific_arg = trim(specific_arg)
367 equals_posn=index(specific_arg,
"=")
368 if (index(specific_arg,
"--") .eq. 1)
then 369 if (equals_posn .gt. 0)
then 384 type(hashmap_type),
intent(inout) :: options_database
385 character(len=*),
intent(in) :: key
387 integer :: array_size, i
391 if (array_size .gt. 0)
then 397 call c_remove(options_database, trim(key)//
"a_size")
400 call c_remove(options_database, key)
413 type(hashmap_type),
intent(inout) :: options_database
414 character(len=*),
intent(in) :: key
417 call log_log(log_error,
"No configuration option with key "//trim(key)//
" present")
427 subroutine options_add_real(options_database, key, real_value, do_not_replace, array_index)
428 type(hashmap_type),
intent(inout) :: options_database
429 character(len=*),
intent(in) :: key
430 real(kind=DEFAULT_PRECISION),
intent(in) :: real_value
431 integer,
intent(in),
optional :: array_index
432 logical,
intent(in),
optional :: do_not_replace
435 character(len=len(key)+ARRAY_APPEND_SIZE) :: lookup_key
437 if (
present(do_not_replace))
then 438 if (do_not_replace)
then 439 if (
present(array_index))
then 440 if (
options_has_key(options_database, trim(key)//
"a_"//conv_to_string(array_index)))
return 447 if (
present(array_index))
then 450 if (temp_size .lt. array_index) temp_size=temp_size+1
454 call options_add(options_database, trim(key)//
"a_size", temp_size)
459 call c_put_real(options_database, lookup_key, real_value)
468 subroutine options_add_logical(options_database, key, logical_value, do_not_replace, array_index)
469 type(hashmap_type),
intent(inout) :: options_database
470 character(len=*),
intent(in) :: key
471 logical,
intent(in) :: logical_value
472 integer,
intent(in),
optional :: array_index
473 logical,
intent(in),
optional :: do_not_replace
476 character(len=len(key)+ARRAY_APPEND_SIZE) :: lookup_key
478 if (
present(do_not_replace))
then 479 if (do_not_replace)
then 480 if (
present(array_index))
then 481 if (
options_has_key(options_database, trim(key)//
"a_"//conv_to_string(array_index)))
return 488 if (
present(array_index))
then 491 if (temp_size .lt. array_index) temp_size=temp_size+1
495 call options_add(options_database, trim(key)//
"a_size", temp_size)
500 call c_put_logical(options_database, lookup_key, logical_value)
509 subroutine options_add_string(options_database, key, string_value, do_not_replace, array_index)
510 type(hashmap_type),
intent(inout) :: options_database
511 character(len=*),
intent(in) :: key, string_value
512 integer,
intent(in),
optional :: array_index
513 logical,
intent(in),
optional :: do_not_replace
515 character(len=STRING_LENGTH) :: value_to_store
517 character(len=len(key)+ARRAY_APPEND_SIZE) :: lookup_key
519 if (
present(do_not_replace))
then 520 if (do_not_replace)
then 521 if (
present(array_index))
then 522 if (
options_has_key(options_database, trim(key)//
"a_"//conv_to_string(array_index)))
return 529 value_to_store=string_value
531 if (
present(array_index))
then 534 if (temp_size .lt. array_index) temp_size=temp_size+1
538 call options_add(options_database, trim(key)//
"a_size", temp_size)
543 call c_put_string(options_database, lookup_key, value_to_store)
552 recursive subroutine options_add_integer(options_database, key, int_value, do_not_replace, array_index)
553 type(hashmap_type),
intent(inout) :: options_database
554 character(len=*),
intent(in) :: key
555 integer,
intent(in) :: int_value
556 integer,
intent(in),
optional :: array_index
557 logical,
intent(in),
optional :: do_not_replace
560 character(len=len(key)+ARRAY_APPEND_SIZE) :: lookup_key
562 if (
present(do_not_replace))
then 563 if (do_not_replace)
then 564 if (
present(array_index))
then 565 if (
options_has_key(options_database, trim(key)//
"a_"//conv_to_string(array_index)))
return 572 if (
present(array_index))
then 575 if (temp_size .lt. array_index) temp_size=temp_size+1
579 call options_add(options_database, trim(key)//
"a_size", temp_size)
584 call c_put_integer(options_database, lookup_key, int_value)
592 character(len=*),
intent(in) :: key
593 integer,
intent(in) :: index
606 character(len=*),
intent(in) :: specific_value
607 integer :: dot_posn, exponent_posn
609 if (conv_is_logical(specific_value))
then 615 dot_posn = index(specific_value,
".")
616 exponent_posn = index(specific_value,
"e")
617 if (dot_posn .eq. 0 .and. exponent_posn .eq. 0)
then 619 if (conv_is_integer(specific_value))
then 625 if (conv_is_real(specific_value))
then 641 integer,
intent(in) :: type_of_config
642 character(len=*),
intent(in) :: specific_arg
643 type(hashmap_type),
intent(inout) :: parse_options
645 integer :: equals_posn
646 equals_posn=index(specific_arg,
"=")
649 if (equals_posn .gt. 0)
then 651 conv_to_logical(specific_arg(equals_posn+1:len(specific_arg))))
658 conv_to_integer(specific_arg(equals_posn+1:len(specific_arg))))
659 else if (type_of_config ==
real_type)
then 661 conv_single_real_to_double(conv_to_real(specific_arg(equals_posn+1:len(specific_arg)))))
663 call set_options_string_value(parse_options, specific_arg(3:equals_posn-1), specific_arg(equals_posn+1:len(specific_arg)))
669 type(hashmap_type),
intent(inout) :: optionhashmap_type
670 character(len=*),
intent(in) :: key
671 logical,
intent(in) :: logical_value
673 call c_put_logical(optionhashmap_type, key, logical_value)
678 type(hashmap_type),
intent(inout) :: optionhashmap_type
679 character(len=*),
intent(in) :: key
680 real(kind=DEFAULT_PRECISION),
intent(in) :: real_value
682 call c_put_real(optionhashmap_type, key, real_value)
687 type(hashmap_type),
intent(inout) :: optionhashmap_type
688 character(len=*),
intent(in) :: key
689 integer,
intent(in) :: int_value
691 call c_put_integer(optionhashmap_type, key, int_value)
696 type(hashmap_type),
intent(inout) :: optionhashmap_type
697 character(len=*),
intent(in) :: key
698 character(len=*),
intent(in) :: str_value
700 character(len=STRING_LENGTH) :: write_value
703 write_value = str_value
704 call c_put_string(optionhashmap_type, key, write_value)
Generic add interface for adding different types of data to the databases.
subroutine options_add_string(options_database, key, string_value, do_not_replace, array_index)
Adds a string value to the options database with a specific key.
Gets a specific logical element out of the list, stack, queue or map with the corresponding key...
integer, parameter, public long_string_length
Length of longer strings.
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...
Retrieves the key currently being held at a specific index in the map or "" if the index > map elemen...
Puts an integer key-value pair into the map.
subroutine set_options_logical_value(optionhashmap_type, key, logical_value)
A helper procedure to set a specific logical value.
subroutine, public load_command_line_into_options_database(options_database)
Loads in the command line arguments and stores them in the options database.
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.
integer, parameter array_append_size
integer, parameter, public default_precision
MPI communication type which we use for the prognostic and calculation data.
subroutine check_options_key_exists(options_database, key)
Determines whether a specific options key exists in the database or not, if it doesn't then this resu...
recursive subroutine options_add_integer(options_database, key, int_value, do_not_replace, array_index)
Adds an integer value to the options database with a specific key.
subroutine set_options_string_value(optionhashmap_type, key, str_value)
A helper procedure to set a specific string value.
Contains common definitions for the data and datatypes used by MONC.
character(len=string_length) function, public options_key_at(options_database, i)
Returns the ith key in the options database.
A hashmap structure, the same as a map but uses hashing for greatly improved performance when storing...
Gets a specific integer element out of the list, stack, queue or map with the corresponding key...
Conversion between common inbuilt FORTRAN data types.
subroutine, public options_get_integer_array(options_database, key, array_data, from, to)
Retrieves an entire (or subset) integer array.
Converts data types to strings.
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...
Puts a string key-value pair into the map.
subroutine add_specific_option_key_value_pair(type_of_config, parse_options, specific_arg)
This will add a specific option key value pair to the options hashmap_type.
subroutine, public log_log(level, message, str)
Logs a message at the specified level. If the level is above the current level then the message is ig...
Converts data types to logical.
Puts a logical key-value pair into the map.
integer, parameter string_type
Type of string value data.
integer, parameter integer_type
Type of integer value data.
Returns the number of elements in the collection.
Determines whether a data item can be represented as a logical or not.
Collection data structures.
subroutine set_options_real_value(optionhashmap_type, key, real_value)
A helper procedure to set a specific real value.
subroutine, public options_get_logical_array(options_database, key, array_data, from, to)
Retrieves an entire (or subset) logical array.
Determines whether a data item can be represented as an integer or not.
integer function get_argument_value_type(specific_value)
Given a specific value this will determine the type of data.
Converts data types to real.
integer, parameter, public string_length
Default length of strings.
List data structure which implements a doubly linked list. This list will preserve its order...
real(kind=default_precision) function, public options_get_real(options_database, key, index)
Retrieves a real value from the database that matches the provided key.
class(*) function, pointer, public options_value_at(options_database, i)
Returns the value at index in the database.
integer function, public options_size(options_database)
Returns the number of entries in the options database.
integer function, public options_get_integer(options_database, key, index)
Retrieves an integer value from the database that matches the provided key.
Determines whether a data item can be represented as a real or not.
subroutine options_add_logical(options_database, key, logical_value, do_not_replace, array_index)
Adds a logical value to the options database with a specific key.
integer, parameter logical_type
Type of logical value data.
Manages the options database. Contains administration functions and deduce runtime options from the c...
logical function, public options_get_logical(options_database, key, index)
Retrieves a logical value from the database that matches the provided key.
Retrieves the generic value held at the specific map index or null if index > map elements...
Converts data types to integers.
Determines whether or not a map contains a specific key.
Gets a specific double precision real element out of the list, stack, queue or map with the correspon...
subroutine, public options_get_string_array(options_database, key, array_data, from, to)
Retrieves an entire (or subset) string array.
subroutine, public options_get_real_array(options_database, key, array_data, from, to)
Retrieves an entire (or subset) real array.
logical function, public options_has_key(options_database, key)
Determines whether a specific key is in the database.
integer, parameter real_type
Type of real value data.
Gets a specific string element out of the list, stack, queue or map with the corresponding key...
subroutine set_options_integer_value(optionhashmap_type, key, int_value)
A helper procedure to set a specific integer value.
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...
Puts a double precision real key-value pair into the map.
Removes a specific element from the list or map.
character(len=string_length) function get_options_array_key(key, index)
Gets a key corresponding to the correct options key and index combination.
subroutine options_add_real(options_database, key, real_value, do_not_replace, array_index)
Adds a real value to the options database with a specific key.