MONC
test_monc.F90
Go to the documentation of this file.
1 ! Tests the logging_mod utility functions
3  use fruit, only : assert_equals, assert_not_equals, assert_true
4  use state_mod, only : model_state_type
11  use collections_mod, only : list_type, c_add, map_type, c_size, c_key_at,&
12  c_value_at, c_get
14  implicit none
15 
16 contains
17 
18  subroutine add_component(component_descriptions, single_description)
19  type(list_type), intent(inout) :: component_descriptions
20  type(component_descriptor_type), intent(in) :: single_description
21 
22  class(*), pointer :: raw_data
23  allocate(raw_data, source=single_description)
24  call c_add(component_descriptions, raw_data)
25  end subroutine add_component
26 
27 
28  ! Test random produces a non zero value
29  subroutine test_load_model
30  type(model_state_type) :: current_state
31  real :: z0
32 
33  call load_model_configuration(current_state%options_database)
34  z0 = options_get_real(current_state%options_database, "z0")
35  call assert_equals(2.0e-3,z0,"Test z0 has been read properly")
36  end subroutine test_load_model
37 
38  ! Test random produces a non zero value
40  type(model_state_type) :: current_state
41  type(list_type) :: component_descriptions
42  type(map_type) :: registered_components
43 
44  registered_components = get_all_registered_components()
45  call assert_equals(0,c_size(registered_components),"Test there are not components in the registry")
46  ! add the component to the database
47  call add_component(component_descriptions, fftsolver_get_descriptor())
48  call fill_registry_with_components(current_state%options_database, component_descriptions)
49 
50  registered_components = get_all_registered_components()
51  call assert_equals(1,c_size(registered_components),"Test there is only 1 component in the registry")
52  end subroutine test_fill_registry_components
53 
54 end module test_monc_mod
55 
56 
57 
58  ! Driver for maths_mod utility tests
60  use fruit, only : init_fruit, run_test_case, fruit_summary
62 
63  implicit none
64 
65  call init_fruit
66  call run_test_case(test_load_model, "Test loading the configuration model to options_database")
67  call run_test_case(test_fill_registry_components, "Test filling registry with components")
68  call fruit_summary
69 end program test_monc_driver
70 
Retrieves the key currently being held at a specific index in the map or "" if the index > map elemen...
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.
type(map_type) function, public get_all_registered_components()
Returns a brief summary of all registered components.
Definition: registry.F90:258
Pressure solver which uses a tridiagonal algorithm operating on the pressure terms in Fourier space...
Definition: fftsolver.F90:3
integer, parameter, public default_precision
MPI communication type which we use for the prognostic and calculation data.
Definition: datadefn.F90:17
Contains common definitions for the data and datatypes used by MONC.
Definition: datadefn.F90:2
The ModelState which represents the current state of a run.
Definition: state.F90:39
subroutine load_model_configuration(state, options_database)
Loads the configuration into the options database, either from a file or checkpoint.
Definition: monc.F90:115
Main core entry point to the rest of the model, this is called by the program main.
Definition: monc.F90:2
subroutine test_fill_registry_components
Definition: test_monc.F90:40
Map data structure that holds string (length 20 maximum) key value pairs.
Definition: collections.F90:86
Returns the number of elements in the collection.
subroutine display_registed_components()
Displays the registered components and their version numbers.
Definition: monc.F90:276
Interfaces and types that MONC components must specify.
Collection data structures.
Definition: collections.F90:7
program test_monc_driver
Definition: test_monc.F90:59
subroutine add_component(component_descriptions, single_description)
Called by each component to add itself to the registration list_type.
Definition: monc_driver.F90:39
List data structure which implements a doubly linked list. This list will preserve its order...
Definition: collections.F90:60
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.
Manages the options database. Contains administration functions and deduce runtime options from the c...
type(component_descriptor_type) function, public fftsolver_get_descriptor()
Descriptor of this component for registration.
Definition: fftsolver.F90:33
subroutine fill_registry_with_components(options_database, component_descriptions)
Registers each supplied component description.
Definition: monc.F90:240
The model state which represents the current state of a run.
Definition: state.F90:2
subroutine, public init_registry(options_database)
Initialises the registry with the provided configuration file.
Definition: registry.F90:67
MONC component registry.
Definition: registry.F90:5
subroutine test_load_model
Definition: test_monc.F90:30