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 
collections_mod::map_type
Map data structure that holds string (length 20 maximum) key value pairs.
Definition: collections.F90:86
collections_mod::c_key_at
Retrieves the key currently being held at a specific index in the map or "" if the index > map elemen...
Definition: collections.F90:457
registry_mod::init_registry
subroutine, public init_registry(options_database)
Initialises the registry with the provided configuration file.
Definition: registry.F90:67
test_monc_mod
Definition: test_monc.F90:2
test_monc_mod::test_load_model
subroutine test_load_model
Definition: test_monc.F90:30
collections_mod
Collection data structures.
Definition: collections.F90:7
monc_mod::fill_registry_with_components
subroutine fill_registry_with_components(options_database, component_descriptions)
Registers each supplied component description.
Definition: monc.F90:265
collections_mod::c_size
Returns the number of elements in the collection.
Definition: collections.F90:428
registry_mod::get_all_registered_components
type(map_type) function, public get_all_registered_components()
Returns a brief summary of all registered components.
Definition: registry.F90:258
monc_component_mod
Interfaces and types that MONC components must specify.
Definition: monc_component.F90:6
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
state_mod::model_state_type
The ModelState which represents the current state of a run.
Definition: state.F90:39
datadefn_mod
Contains common definitions for the data and datatypes used by MONC.
Definition: datadefn.F90:2
test_monc_mod::test_fill_registry_components
subroutine test_fill_registry_components
Definition: test_monc.F90:40
monc_mod::load_model_configuration
subroutine load_model_configuration(state, options_database)
Loads the configuration into the options database, either from a file or checkpoint.
Definition: monc.F90:118
add_component
subroutine add_component(component_descriptions, single_description)
Called by each component to add itself to the registration list_type.
Definition: monc_driver.F90:39
collections_mod::list_type
List data structure which implements a doubly linked list. This list will preserve its order.
Definition: collections.F90:60
registry_mod
MONC component registry.
Definition: registry.F90:5
monc_mod::display_registed_components
subroutine display_registed_components()
Displays the registered components and their version numbers.
Definition: monc.F90:301
fftsolver_mod
Pressure solver which uses a tridiagonal algorithm operating on the pressure terms in Fourier space....
Definition: fftsolver.F90:3
monc_mod
Main core entry point to the rest of the model, this is called by the program main.
Definition: monc.F90:2
fftsolver_mod::fftsolver_get_descriptor
type(component_descriptor_type) function, public fftsolver_get_descriptor()
Descriptor of this component for registration.
Definition: fftsolver.F90:33
optionsdatabase_mod
Manages the options database. Contains administration functions and deduce runtime options from the c...
Definition: optionsdatabase.F90:7
monc_component_mod::component_descriptor_type
Description of a component.
Definition: monc_component.F90:42
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
state_mod
The model state which represents the current state of a run.
Definition: state.F90:2
test_monc_driver
program test_monc_driver
Definition: test_monc.F90:59