MONC
test_configurationfileparser.F90
Go to the documentation of this file.
1 ! Unit tests for the options database functionality
3  use collections_mod, only : map_type, c_get
9  use fruit, only : assert_equals, assert_true, assert_false
10 
11  implicit none
12 
13 contains
14 
15  ! Test some modules are read correctly
17  type(map_type) :: options_database
18  class(*), pointer :: raw_data
19 
20  call parse_configuration_file(options_database, "user_config")
21 
22  raw_data=>c_get(options_database, "viscosity_enabled")
23  call assert_false(conv_to_logical(raw_data, .false.), "Test viscosity is not enable")
24 
25  raw_data=>c_get(options_database, "rhobous")
26  call assert_equals(1.0, conv_to_real(raw_data, .false.), "Test setup configuration values")
27 
28  raw_data=>c_get(options_database, "passive_q")
29  call assert_false(conv_to_logical(raw_data, .false.), "Test logical value is false when missing")
30 
31  raw_data=>c_get(options_database, "number_q_fields")
32  call assert_equals(5, conv_to_integer(raw_data, .false.), "Test integer values read")
33 
34  raw_data=>c_get(options_database, "checkpoint_enable_write")
35  call assert_true(conv_to_logical(raw_data, .false.), "Test result when entry is not defined in the user file but in the global file")
36 
37  end subroutine test_parse_configuration_file
38 
40 
42  use fruit, only : init_fruit, run_test_case, fruit_summary
44  implicit none
45 
46  call init_fruit
47  call run_test_case(test_parse_configuration_file, "Test values from user file")
48  call fruit_summary
Generic add interface for adding different types of data to the databases.
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...
program test_configuration_file_parser_driver
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.
Conversion between common inbuilt FORTRAN data types.
Definition: conversions.F90:5
Converts data types to strings.
Definition: conversions.F90:36
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...
Converts data types to logical.
Definition: conversions.F90:69
Map data structure that holds string (length 20 maximum) key value pairs.
Definition: collections.F90:86
Determines whether a data item can be represented as a logical or not.
Definition: conversions.F90:98
Collection data structures.
Definition: collections.F90:7
Determines whether a data item can be represented as an integer or not.
Definition: conversions.F90:79
Converts data types to real.
Definition: conversions.F90:58
Determines whether a data item can be represented as a real or not.
Definition: conversions.F90:89
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...
Converts data types to integers.
Definition: conversions.F90:47
logical function, public options_has_key(options_database, key)
Determines whether a specific key is in the database.