MONC
Data Types | Functions/Subroutines | Variables
optionsdatabase_mod Module Reference

Manages the options database. Contains administration functions and deduce runtime options from the command line. More...

Data Types

interface  options_add
 Generic add interface for adding different types of data to the databases. More...
 

Functions/Subroutines

integer function, public options_size (options_database)
 Returns the number of entries in the options database. More...
 
character(len=string_length) function, public options_key_at (options_database, i)
 Returns the ith key in the options database. More...
 
class(*) function, pointer, public options_value_at (options_database, i)
 Returns the value at index in the database. More...
 
logical function, public options_has_key (options_database, key)
 Determines whether a specific key is in the database. More...
 
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. More...
 
subroutine, public options_get_real_array (options_database, key, array_data, from, to)
 Retrieves an entire (or subset) real array. More...
 
logical function, public options_get_logical (options_database, key, index)
 Retrieves a logical value from the database that matches the provided key. More...
 
subroutine, public options_get_logical_array (options_database, key, array_data, from, to)
 Retrieves an entire (or subset) logical array. More...
 
integer function, public options_get_integer (options_database, key, index)
 Retrieves an integer value from the database that matches the provided key. More...
 
subroutine, public options_get_integer_array (options_database, key, array_data, from, to)
 Retrieves an entire (or subset) integer array. More...
 
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. More...
 
subroutine, public options_get_string_array (options_database, key, array_data, from, to)
 Retrieves an entire (or subset) string array. More...
 
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. More...
 
subroutine, public load_command_line_into_options_database (options_database)
 Loads in the command line arguments and stores them in the options database. More...
 
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. More...
 
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 results in a log error being issued. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
character(len=string_length) function get_options_array_key (key, index)
 Gets a key corresponding to the correct options key and index combination. More...
 
integer function get_argument_value_type (specific_value)
 Given a specific value this will determine the type of data. More...
 
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. More...
 
subroutine set_options_logical_value (optionhashmap_type, key, logical_value)
 A helper procedure to set a specific logical value. More...
 
subroutine set_options_real_value (optionhashmap_type, key, real_value)
 A helper procedure to set a specific real value. More...
 
subroutine set_options_integer_value (optionhashmap_type, key, int_value)
 A helper procedure to set a specific integer value. More...
 
subroutine set_options_string_value (optionhashmap_type, key, str_value)
 A helper procedure to set a specific string value. More...
 

Variables

integer, parameter logical_type =0
 Type of logical value data. More...
 
integer, parameter integer_type =1
 Type of integer value data. More...
 
integer, parameter real_type =2
 Type of real value data. More...
 
integer, parameter string_type =3
 Type of string value data. More...
 
integer, parameter array_append_size = 10
 

Detailed Description

Manages the options database. Contains administration functions and deduce runtime options from the command line.

The key-value character length limit for each option is 64 characters, the value length limit is 44 characters and key length 20 characters. Note that the options database should be entirely agnostic of where or now the database is stored (in our case in the state.)

Function/Subroutine Documentation

◆ add_specific_option_key_value_pair()

subroutine optionsdatabase_mod::add_specific_option_key_value_pair ( integer, intent(in)  type_of_config,
type(hashmap_type), intent(inout)  parse_options,
character(len=*), intent(in)  specific_arg 
)
private

This will add a specific option key value pair to the options hashmap_type.

As per the hashmap_type semantics, if the user supplies an option then this will override any existing default value.

Parameters
type_of_configThe type of value to add to the configuration hashmap_type
parse_optionsThe key-value pairs of configuration options
specific_argThe argument string (key=value or just key)

Definition at line 640 of file optionsdatabase.F90.

641  integer, intent(in) :: type_of_config
642  character(len=*), intent(in) :: specific_arg
643  type(hashmap_type), intent(inout) :: parse_options
644 
645  integer :: equals_posn
646  equals_posn=index(specific_arg, "=") ! Get the position of the equals character
647 
648  if (type_of_config == logical_type) then
649  if (equals_posn .gt. 0) then
650  call set_options_logical_value(parse_options, specific_arg(3:equals_posn-1), &
651  conv_to_logical(specific_arg(equals_posn+1:len(specific_arg))))
652  else
653  ! Handle the case where there is just a key (no value)
654  call set_options_logical_value(parse_options, specific_arg(3:len(specific_arg)), .true.)
655  end if
656  else if (type_of_config == integer_type) then
657  call set_options_integer_value(parse_options, specific_arg(3:equals_posn-1), &
658  conv_to_integer(specific_arg(equals_posn+1:len(specific_arg))))
659  else if (type_of_config == real_type) then
660  call set_options_real_value(parse_options, specific_arg(3:equals_posn-1), &
661  conv_single_real_to_double(conv_to_real(specific_arg(equals_posn+1:len(specific_arg)))))
662  else if (type_of_config == string_type) then
663  call set_options_string_value(parse_options, specific_arg(3:equals_posn-1), specific_arg(equals_posn+1:len(specific_arg)))
664  end if
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_options_key_exists()

subroutine optionsdatabase_mod::check_options_key_exists ( type(hashmap_type), intent(inout)  options_database,
character(len=*), intent(in)  key 
)
private

Determines whether a specific options key exists in the database or not, if it doesn't then this results in a log error being issued.

Parameters
options_databaseThe options database
keyThe key to search for and return the matching value

Definition at line 412 of file optionsdatabase.F90.

413  type(hashmap_type), intent(inout) :: options_database
414  character(len=*), intent(in) :: key
415 
416  if (.not. options_has_key(options_database, key)) then
417  call log_log(log_error, "No configuration option with key "//trim(key)//" present")
418  end if
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_argument_value_type()

integer function optionsdatabase_mod::get_argument_value_type ( character(len=*), intent(in)  specific_value)
private

Given a specific value this will determine the type of data.

It basically wraps around the conversion test utilities, but will select a real if the string contains a dot and an integer if not. If no conversions_mod can be achieved then the value is assumed to be of type string

Parameters
specific_valueString value to deduce the type of
Returns
Integer representing the type as per the module parameter type integers

Definition at line 605 of file optionsdatabase.F90.

606  character(len=*), intent(in) :: specific_value
607  integer :: dot_posn, exponent_posn
608 
609  if (conv_is_logical(specific_value)) then
610  get_argument_value_type = logical_type
611  return
612  else
613  end if
614 
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
618  ! No dot, therefore an integer or string
619  if (conv_is_integer(specific_value)) then
620  get_argument_value_type = integer_type
621  return
622  end if
623  else
624  ! A dot is present, therefore a real or string
625  if (conv_is_real(specific_value)) then
626  get_argument_value_type = real_type
627  return
628  end if
629  end if
630  get_argument_value_type = string_type ! Default string type
Here is the caller graph for this function:

◆ get_options_array_key()

character(len=string_length) function optionsdatabase_mod::get_options_array_key ( character(len=*), intent(in)  key,
integer, intent(in)  index 
)
private

Gets a key corresponding to the correct options key and index combination.

Parameters
keyThe key
indexThe index
Returns
The key to store the indexed item in

Definition at line 591 of file optionsdatabase.F90.

592  character(len=*), intent(in) :: key
593  integer, intent(in) :: index
594 
595  get_options_array_key=trim(key)//"a_"//trim(conv_to_string(index))
Here is the caller graph for this function:

◆ load_command_line_into_options_database()

subroutine, public optionsdatabase_mod::load_command_line_into_options_database ( type(hashmap_type), intent(inout)  options_database)

Loads in the command line arguments and stores them in the options database.

Returns
hashmap_type of option-value pairs

Definition at line 356 of file optionsdatabase.F90.

357  type(hashmap_type), intent(inout) :: options_database
358 
359  integer :: i, arguments, equals_posn, type_of_config
360  character(len=LONG_STRING_LENGTH) :: specific_arg
361 
362  arguments = command_argument_count()
363 
364  do i=1,arguments
365  call get_command_argument(i, value = specific_arg)
366  specific_arg = trim(specific_arg)
367  equals_posn=index(specific_arg, "=") ! Get the position of the equals character
368  if (index(specific_arg, "--") .eq. 1) then
369  if (equals_posn .gt. 0) then
370  type_of_config = get_argument_value_type(specific_arg(equals_posn+1 : len(specific_arg)))
371  else
372  ! If no equals then it is a logical switch (to true)
373  type_of_config = logical_type
374  end if
375  call add_specific_option_key_value_pair(type_of_config, options_database, specific_arg)
376  end if
377  end do
Here is the call graph for this function:
Here is the caller graph for this function:

◆ options_add_integer()

recursive subroutine optionsdatabase_mod::options_add_integer ( type(hashmap_type), intent(inout)  options_database,
character(len=*), intent(in)  key,
integer, intent(in)  int_value,
logical, intent(in), optional  do_not_replace,
integer, intent(in), optional  array_index 
)
private

Adds an integer value to the options database with a specific key.

Parameters
options_databaseThe options database
keyThe key to use
valueThe integer value to add to the database
do_not_replaceOptional flag whether to ignore existing values or replace them
array_indexOptional array index which specifies which location in the array to write to

Definition at line 552 of file optionsdatabase.F90.

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
558 
559  integer :: temp_size
560  character(len=len(key)+ARRAY_APPEND_SIZE) :: lookup_key
561 
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
566  else
567  if (options_has_key(options_database, key)) return
568  end if
569  end if
570  end if
571 
572  if (present(array_index)) then
573  if (options_has_key(options_database, trim(key)//"a_size")) then
574  temp_size=options_get_integer(options_database, trim(key)//"a_size")
575  if (temp_size .lt. array_index) temp_size=temp_size+1
576  else
577  temp_size=1
578  end if
579  call options_add(options_database, trim(key)//"a_size", temp_size)
580  lookup_key=get_options_array_key(key, array_index)
581  else
582  lookup_key=key
583  end if
584  call c_put_integer(options_database, lookup_key, int_value)
Here is the call graph for this function:

◆ options_add_logical()

subroutine optionsdatabase_mod::options_add_logical ( type(hashmap_type), intent(inout)  options_database,
character(len=*), intent(in)  key,
logical, intent(in)  logical_value,
logical, intent(in), optional  do_not_replace,
integer, intent(in), optional  array_index 
)
private

Adds a logical value to the options database with a specific key.

Parameters
options_databaseThe options database
keyThe key to use
valueThe logical value to add to the database
do_not_replaceOptional flag whether to ignore existing values or replace them
array_indexOptional array index which specifies which location in the array to write to

Definition at line 468 of file optionsdatabase.F90.

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
474 
475  integer :: temp_size
476  character(len=len(key)+ARRAY_APPEND_SIZE) :: lookup_key
477 
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
482  else
483  if (options_has_key(options_database, key)) return
484  end if
485  end if
486  end if
487 
488  if (present(array_index)) then
489  if (options_has_key(options_database, trim(key)//"a_size")) then
490  temp_size=options_get_integer(options_database, trim(key)//"a_size")
491  if (temp_size .lt. array_index) temp_size=temp_size+1
492  else
493  temp_size=1
494  end if
495  call options_add(options_database, trim(key)//"a_size", temp_size)
496  lookup_key=get_options_array_key(key, array_index)
497  else
498  lookup_key=key
499  end if
500  call c_put_logical(options_database, lookup_key, logical_value)
Here is the call graph for this function:

◆ options_add_real()

subroutine optionsdatabase_mod::options_add_real ( type(hashmap_type), intent(inout)  options_database,
character(len=*), intent(in)  key,
real(kind=default_precision), intent(in)  real_value,
logical, intent(in), optional  do_not_replace,
integer, intent(in), optional  array_index 
)
private

Adds a real value to the options database with a specific key.

Parameters
options_databaseThe options database
keyThe key to use
valueThe real value to add to the database
do_not_replaceOptional flag whether to ignore existing values or replace them
array_indexOptional array index which specifies which location in the array to write to

Definition at line 427 of file optionsdatabase.F90.

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
433 
434  integer :: temp_size
435  character(len=len(key)+ARRAY_APPEND_SIZE) :: lookup_key
436 
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
441  else
442  if (options_has_key(options_database, key)) return
443  end if
444  end if
445  end if
446 
447  if (present(array_index)) then
448  if (options_has_key(options_database, trim(key)//"a_size")) then
449  temp_size=options_get_integer(options_database, trim(key)//"a_size")
450  if (temp_size .lt. array_index) temp_size=temp_size+1
451  else
452  temp_size=1
453  end if
454  call options_add(options_database, trim(key)//"a_size", temp_size)
455  lookup_key=get_options_array_key(key, array_index)
456  else
457  lookup_key=key
458  end if
459  call c_put_real(options_database, lookup_key, real_value)
Here is the call graph for this function:

◆ options_add_string()

subroutine optionsdatabase_mod::options_add_string ( type(hashmap_type), intent(inout)  options_database,
character(len=*), intent(in)  key,
character(len=*), intent(in)  string_value,
logical, intent(in), optional  do_not_replace,
integer, intent(in), optional  array_index 
)
private

Adds a string value to the options database with a specific key.

Parameters
options_databaseThe options database
keyThe key to use
valueThe string value to add to the database
do_not_replaceOptional flag whether to ignore existing values or replace them
array_indexOptional array index which specifies which location in the array to write to

Definition at line 509 of file optionsdatabase.F90.

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
514 
515  character(len=STRING_LENGTH) :: value_to_store
516  integer :: temp_size
517  character(len=len(key)+ARRAY_APPEND_SIZE) :: lookup_key
518 
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
523  else
524  if (options_has_key(options_database, key)) return
525  end if
526  end if
527  end if
528 
529  value_to_store=string_value
530 
531  if (present(array_index)) then
532  if (options_has_key(options_database, trim(key)//"a_size")) then
533  temp_size=options_get_integer(options_database, trim(key)//"a_size")
534  if (temp_size .lt. array_index) temp_size=temp_size+1
535  else
536  temp_size=1
537  end if
538  call options_add(options_database, trim(key)//"a_size", temp_size)
539  lookup_key=get_options_array_key(key, array_index)
540  else
541  lookup_key=key
542  end if
543  call c_put_string(options_database, lookup_key, value_to_store)
Here is the call graph for this function:

◆ options_get_array_size()

integer function, public optionsdatabase_mod::options_get_array_size ( type(hashmap_type), intent(inout)  options_database,
character(len=*), intent(in)  key 
)

Gets the size of the array held in the options database corresponding to a specific key.

Parameters
options_databaseThe options database
keyThe key to look up
Returns
The number of elements in the array, 0 means zero elements (key is not in the database or corresponds to scalar.)

Definition at line 341 of file optionsdatabase.F90.

342  type(hashmap_type), intent(inout) :: options_database
343  character(len=*), intent(in) :: key
344 
345  if (options_has_key(options_database, trim(key)//"a_size")) then
346  options_get_array_size=options_get_integer(options_database, trim(key)//"a_size")
347  else if (options_has_key(options_database, trim(key))) then
348  options_get_array_size=1
349  else
350  options_get_array_size=0
351  end if
Here is the call graph for this function:
Here is the caller graph for this function:

◆ options_get_integer()

integer function, public optionsdatabase_mod::options_get_integer ( type(hashmap_type), intent(inout)  options_database,
character(len=*), intent(in)  key,
integer, intent(in), optional  index 
)

Retrieves an integer value from the database that matches the provided key.

Parameters
options_databaseThe options database
keyThe key to search for and return the matching value
indexOptional array index to look up an array value
Returns
The matching integer value

Definition at line 216 of file optionsdatabase.F90.

217  type(hashmap_type), intent(inout) :: options_database
218  character(len=*), intent(in) :: key
219  integer, intent(in), optional :: index
220 
221  character(len=len(key)+ARRAY_APPEND_SIZE) :: lookup_key
222 
223  if (present(index)) then
224  lookup_key=get_options_array_key(key, index)
225  else
226  lookup_key=key
227  end if
228  call check_options_key_exists(options_database, lookup_key)
229  options_get_integer=c_get_integer(options_database, lookup_key)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ options_get_integer_array()

subroutine, public optionsdatabase_mod::options_get_integer_array ( type(hashmap_type), intent(inout)  options_database,
character(len=*), intent(in)  key,
integer, dimension(:), intent(inout)  array_data,
integer, intent(in), optional  from,
integer, intent(in), optional  to 
)

Retrieves an entire (or subset) integer array.

Parameters
options_databaseThe options database
keyThe key to search for
array_dataThe array data to write into
fromOptional starting index
toOptional end index

Definition at line 238 of file optionsdatabase.F90.

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
243 
244  integer :: num_elements, i, start, end
245 
246  num_elements=options_get_array_size(options_database, key)
247  if (num_elements .gt. 0 .and. options_has_key(options_database, trim(key)//"a_size")) then
248  if (present(from)) then
249  start=from
250  else
251  start=1
252  end if
253  if (present(to)) then
254  end=to
255  else
256  end=num_elements
257  end if
258  do i=start, num_elements
259  array_data((i-start)+1)=options_get_integer(options_database, key, i)
260  end do
261  else
262  if (options_has_key(options_database, key)) then
263  if (present(from)) then
264  if (from .gt. 1) return
265  end if
266  if (present(to)) then
267  if (to .lt. 1) return
268  end if
269  array_data(1)=options_get_integer(options_database, key)
270  end if
271  end if
Here is the call graph for this function:

◆ options_get_logical()

logical function, public optionsdatabase_mod::options_get_logical ( type(hashmap_type), intent(inout)  options_database,
character(len=*), intent(in)  key,
integer, intent(in), optional  index 
)

Retrieves a logical value from the database that matches the provided key.

Parameters
options_databaseThe options database
keyThe key to search for and return the matching value
indexOptional array index to look up an array value
Returns
The matching logical value

Definition at line 153 of file optionsdatabase.F90.

154  type(hashmap_type), intent(inout) :: options_database
155  character(len=*), intent(in) :: key
156  integer, intent(in), optional :: index
157 
158  character(len=len(key)+ARRAY_APPEND_SIZE) :: lookup_key
159 
160  if (present(index)) then
161  lookup_key=get_options_array_key(key, index)
162  else
163  lookup_key=key
164  end if
165  call check_options_key_exists(options_database, lookup_key)
166  options_get_logical=c_get_logical(options_database, lookup_key)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ options_get_logical_array()

subroutine, public optionsdatabase_mod::options_get_logical_array ( type(hashmap_type), intent(inout)  options_database,
character(len=*), intent(in)  key,
logical, dimension(:), intent(inout)  array_data,
integer, intent(in), optional  from,
integer, intent(in), optional  to 
)

Retrieves an entire (or subset) logical array.

Parameters
options_databaseThe options database
keyThe key to search for
array_dataThe array data to write into
fromOptional starting index
toOptional end index

Definition at line 175 of file optionsdatabase.F90.

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
180 
181  integer :: num_elements, i, start, end
182 
183  num_elements=options_get_array_size(options_database, key)
184  if (num_elements .gt. 0 .and. options_has_key(options_database, trim(key)//"a_size")) then
185  if (present(from)) then
186  start=from
187  else
188  start=1
189  end if
190  if (present(to)) then
191  end=to
192  else
193  end=num_elements
194  end if
195  do i=start, num_elements
196  array_data((i-start)+1)=options_get_logical(options_database, key, i)
197  end do
198  else
199  if (options_has_key(options_database, key)) then
200  if (present(from)) then
201  if (from .gt. 1) return
202  end if
203  if (present(to)) then
204  if (to .lt. 1) return
205  end if
206  array_data(1)=options_get_logical(options_database, key)
207  end if
208  end if
Here is the call graph for this function:

◆ options_get_real()

real(kind=default_precision) function, public optionsdatabase_mod::options_get_real ( type(hashmap_type), intent(inout)  options_database,
character(len=*), intent(in)  key,
integer, intent(in), optional  index 
)

Retrieves a real value from the database that matches the provided key.

Parameters
options_databaseThe options database
keyThe key to search for and return the matching value
indexOptional array index to look up an array value
Returns
The matching real value

Definition at line 90 of file optionsdatabase.F90.

91  type(hashmap_type), intent(inout) :: options_database
92  character(len=*), intent(in) :: key
93  integer, intent(in), optional :: index
94 
95  character(len=len(key)+ARRAY_APPEND_SIZE) :: lookup_key
96 
97  if (present(index)) then
98  lookup_key=get_options_array_key(key, index)
99  else
100  lookup_key=key
101  end if
102  call check_options_key_exists(options_database, lookup_key)
103  options_get_real=c_get_real(options_database, lookup_key)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ options_get_real_array()

subroutine, public optionsdatabase_mod::options_get_real_array ( type(hashmap_type), intent(inout)  options_database,
character(len=*), intent(in)  key,
real(kind=default_precision), dimension(:), intent(inout)  array_data,
integer, intent(in), optional  from,
integer, intent(in), optional  to 
)

Retrieves an entire (or subset) real array.

Parameters
options_databaseThe options database
keyThe key to search for
array_dataThe array data to write into
fromOptional starting index
toOptional end index

Definition at line 112 of file optionsdatabase.F90.

113  type(hashmap_type), intent(inout) :: options_database
114  character(len=*), intent(in) :: key
115  real(kind=default_precision), dimension(:), intent(inout) :: array_data
116  integer, intent(in), optional :: from, to
117 
118  integer :: num_elements, i, start, end
119 
120  num_elements=options_get_array_size(options_database, key)
121  if (num_elements .gt. 0 .and. options_has_key(options_database, trim(key)//"a_size")) then
122  if (present(from)) then
123  start=from
124  else
125  start=1
126  end if
127  if (present(to)) then
128  end=to
129  else
130  end=num_elements
131  end if
132  do i=start, num_elements
133  array_data((i-start)+1)=options_get_real(options_database, key, i)
134  end do
135  else
136  if (options_has_key(options_database, key)) then
137  if (present(from)) then
138  if (from .gt. 1) return
139  end if
140  if (present(to)) then
141  if (to .lt. 1) return
142  end if
143  array_data(1)=options_get_real(options_database, key)
144  end if
145  end if
Here is the call graph for this function:

◆ options_get_string()

character(len=string_length) function, public optionsdatabase_mod::options_get_string ( type(hashmap_type), intent(inout)  options_database,
character(len=*), intent(in)  key,
integer, intent(in), optional  index 
)

Retrieves a string value from the database that matches the provided key.

Parameters
options_databaseThe options database
keyThe key to search for and return the matching value
indexOptional array index to look up an array value
Returns
The matching string value

Definition at line 279 of file optionsdatabase.F90.

280  type(hashmap_type), intent(inout) :: options_database
281  character(len=*), intent(in) :: key
282  integer, intent(in), optional :: index
283 
284  character(len=len(key)+ARRAY_APPEND_SIZE) :: lookup_key
285 
286  if (present(index)) then
287  lookup_key=get_options_array_key(key, index)
288  else
289  lookup_key=key
290  end if
291  call check_options_key_exists(options_database, lookup_key)
292  options_get_string=c_get_string(options_database, lookup_key)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ options_get_string_array()

subroutine, public optionsdatabase_mod::options_get_string_array ( type(hashmap_type), intent(inout)  options_database,
character(len=*), intent(in)  key,
character(len=string_length), dimension(:), intent(inout)  array_data,
integer, intent(in), optional  from,
integer, intent(in), optional  to 
)

Retrieves an entire (or subset) string array.

Parameters
options_databaseThe options database
keyThe key to search for
array_dataThe array data to write into
fromOptional starting index
toOptional end index

Definition at line 301 of file optionsdatabase.F90.

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
306 
307  integer :: num_elements, i, start, end
308 
309  num_elements=options_get_array_size(options_database, key)
310  if (num_elements .gt. 0 .and. options_has_key(options_database, trim(key)//"a_size")) then
311  if (present(from)) then
312  start=from
313  else
314  start=1
315  end if
316  if (present(to)) then
317  end=to
318  else
319  end=num_elements
320  end if
321  do i=start, num_elements
322  array_data((i-start)+1)=options_get_string(options_database, key, i)
323  end do
324  else
325  if (options_has_key(options_database, key)) then
326  if (present(from)) then
327  if (from .gt. 1) return
328  end if
329  if (present(to)) then
330  if (to .lt. 1) return
331  end if
332  array_data(1)=options_get_string(options_database, key)
333  end if
334  end if
Here is the call graph for this function:

◆ options_has_key()

logical function, public optionsdatabase_mod::options_has_key ( type(hashmap_type), intent(inout)  options_database,
character(len=*), intent(in)  key 
)

Determines whether a specific key is in the database.

Parameters
options_databaseThe options database
keyThe key to find
Returns
Whether they key is in the database or not

Definition at line 75 of file optionsdatabase.F90.

76  type(hashmap_type), intent(inout) :: options_database
77  character(len=*), intent(in) :: key
78 
79  options_has_key = c_contains(options_database, trim(key))
80  if (.not. options_has_key) then
81  options_has_key = c_contains(options_database, trim(key)//"a_size")
82  end if
Here is the caller graph for this function:

◆ options_key_at()

character(len=string_length) function, public optionsdatabase_mod::options_key_at ( type(hashmap_type), intent(inout)  options_database,
integer, intent(in)  i 
)

Returns the ith key in the options database.

Parameters
options_databaseThe options database
iThe index to retrieve the key at
Returns
The key at index i

Definition at line 52 of file optionsdatabase.F90.

53  type(hashmap_type), intent(inout) :: options_database
54  integer, intent(in) :: i
55 
56  options_key_at = c_key_at(options_database, i)
Here is the caller graph for this function:

◆ options_remove_key()

subroutine, public optionsdatabase_mod::options_remove_key ( type(hashmap_type), intent(inout)  options_database,
character(len=*), intent(in)  key 
)

Removes a specific key from the options database, if it is an array then the entire array is removed.

Parameters
options_databaseThe options database
keyThe key to locate and remove

Definition at line 383 of file optionsdatabase.F90.

384  type(hashmap_type), intent(inout) :: options_database
385  character(len=*), intent(in) :: key
386 
387  integer :: array_size, i
388 
389  if (options_has_key(options_database, key)) then
390  array_size=options_get_array_size(options_database, key)
391  if (array_size .gt. 0) then
392  do i=1,array_size
393  if (options_has_key(options_database, get_options_array_key(key, i))) then
394  call c_remove(options_database, get_options_array_key(key, i))
395  end if
396  end do
397  call c_remove(options_database, trim(key)//"a_size")
398  end if
399  else
400  call c_remove(options_database, key)
401  end if
Here is the call graph for this function:
Here is the caller graph for this function:

◆ options_size()

integer function, public optionsdatabase_mod::options_size ( type(hashmap_type), intent(inout)  options_database)

Returns the number of entries in the options database.

Parameters
options_databaseThe options database
Returns
The number of entries

Definition at line 42 of file optionsdatabase.F90.

43  type(hashmap_type), intent(inout) :: options_database
44 
45  options_size = c_size(options_database)
Here is the caller graph for this function:

◆ options_value_at()

class(*) function, pointer, public optionsdatabase_mod::options_value_at ( type(hashmap_type), intent(inout)  options_database,
integer, intent(in)  i 
)

Returns the value at index in the database.

Parameters
options_databaseThe options database
iThe index to retrieve the value at
Returns
The value at index i

Definition at line 63 of file optionsdatabase.F90.

64  type(hashmap_type), intent(inout) :: options_database
65  integer, intent(in) :: i
66  class(*), pointer :: options_value_at
67 
68  options_value_at=>c_generic_at(options_database, i)
Here is the caller graph for this function:

◆ set_options_integer_value()

subroutine optionsdatabase_mod::set_options_integer_value ( type(hashmap_type), intent(inout)  optionhashmap_type,
character(len=*), intent(in)  key,
integer, intent(in)  int_value 
)
private

A helper procedure to set a specific integer value.

Definition at line 686 of file optionsdatabase.F90.

687  type(hashmap_type), intent(inout) :: optionhashmap_type
688  character(len=*), intent(in) :: key
689  integer, intent(in) :: int_value
690 
691  call c_put_integer(optionhashmap_type, key, int_value)
Here is the caller graph for this function:

◆ set_options_logical_value()

subroutine optionsdatabase_mod::set_options_logical_value ( type(hashmap_type), intent(inout)  optionhashmap_type,
character(len=*), intent(in)  key,
logical, intent(in)  logical_value 
)
private

A helper procedure to set a specific logical value.

Definition at line 668 of file optionsdatabase.F90.

669  type(hashmap_type), intent(inout) :: optionhashmap_type
670  character(len=*), intent(in) :: key
671  logical, intent(in) :: logical_value
672 
673  call c_put_logical(optionhashmap_type, key, logical_value)
Here is the caller graph for this function:

◆ set_options_real_value()

subroutine optionsdatabase_mod::set_options_real_value ( type(hashmap_type), intent(inout)  optionhashmap_type,
character(len=*), intent(in)  key,
real(kind=default_precision), intent(in)  real_value 
)
private

A helper procedure to set a specific real value.

Definition at line 677 of file optionsdatabase.F90.

678  type(hashmap_type), intent(inout) :: optionhashmap_type
679  character(len=*), intent(in) :: key
680  real(kind=default_precision), intent(in) :: real_value
681 
682  call c_put_real(optionhashmap_type, key, real_value)
Here is the caller graph for this function:

◆ set_options_string_value()

subroutine optionsdatabase_mod::set_options_string_value ( type(hashmap_type), intent(inout)  optionhashmap_type,
character(len=*), intent(in)  key,
character(len=*), intent(in)  str_value 
)
private

A helper procedure to set a specific string value.

Definition at line 695 of file optionsdatabase.F90.

696  type(hashmap_type), intent(inout) :: optionhashmap_type
697  character(len=*), intent(in) :: key
698  character(len=*), intent(in) :: str_value
699 
700  character(len=STRING_LENGTH) :: write_value
701 
702  ! We do an assignment here to force the value to be default size, otherwise might underflow
703  write_value = str_value
704  call c_put_string(optionhashmap_type, key, write_value)
Here is the caller graph for this function:

Variable Documentation

◆ array_append_size

integer, parameter optionsdatabase_mod::array_append_size = 10
private

Definition at line 25 of file optionsdatabase.F90.

25  integer, parameter :: ARRAY_APPEND_SIZE = 10

◆ integer_type

integer, parameter optionsdatabase_mod::integer_type =1
private

Type of integer value data.

Definition at line 19 of file optionsdatabase.F90.

◆ logical_type

integer, parameter optionsdatabase_mod::logical_type =0
private

Type of logical value data.

Definition at line 19 of file optionsdatabase.F90.

19  integer, parameter :: LOGICAL_TYPE=0,& !< Type of logical value data
20  integer_type=1,&
21  real_type=2,&
22  string_type=3

◆ real_type

integer, parameter optionsdatabase_mod::real_type =2
private

Type of real value data.

Definition at line 19 of file optionsdatabase.F90.

◆ string_type

integer, parameter optionsdatabase_mod::string_type =3
private

Type of string value data.

Definition at line 19 of file optionsdatabase.F90.

logging_mod::log_error
integer, parameter, public log_error
Only log ERROR messages.
Definition: logging.F90:11
optionsdatabase_mod::options_get_integer
integer function, public options_get_integer(options_database, key, index)
Retrieves an integer value from the database that matches the provided key.
Definition: optionsdatabase.F90:217
logging_mod::log_log
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...
Definition: logging.F90:75
optionsdatabase_mod::options_add
Generic add interface for adding different types of data to the databases.
Definition: optionsdatabase.F90:28
optionsdatabase_mod::options_get_string
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.
Definition: optionsdatabase.F90:280
optionsdatabase_mod::options_get_logical
logical function, public options_get_logical(options_database, key, index)
Retrieves a logical value from the database that matches the provided key.
Definition: optionsdatabase.F90:154
optionsdatabase_mod::options_get_real
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.
Definition: optionsdatabase.F90:91
datadefn_mod::default_precision
integer, parameter, public default_precision
MPI communication type which we use for the prognostic and calculation data.
Definition: datadefn.F90:17