3 use fruit
, only : assert_equals, add_fail, assert_true, assert_false, set_unit_name
25 class(*),
pointer :: data
28 call set_unit_name(
'test_register')
31 descriptor%version=100-i
32 descriptor%name=
"Test "//
str(i)
37 call assert_equals(10,
c_size(component_info),
"Number of registered components after registrations")
40 call assert_equals(
"Test "//
str(i),
c_key_at(component_info, i))
41 data => c_value_at(component_info, i)
44 call assert_equals(
real(100-i), data,
"Version number of component at i correct")
46 call add_fail(
"Unknown type")
60 descriptor%version=100-i
61 descriptor%name=
"Test "//
str(i)
66 call assert_equals(10,
c_size(component_info),
"Number of registered components after registrations")
71 call assert_equals(10-i,
c_size(component_info),
"Component at i has de-registered")
81 integer :: init_callbacks, timestep_callbacks, consolidation_callbacks, modeldump_callbacks,&
82 finalisation_callbacks, i
86 modeldump_callbacks, finalisation_callbacks)
91 call assert_true(
associated(data),
"Testing there is some component information if less than 100")
92 call assert_equals(
"Test "//
str(i), data%name,
"Compare registered and expected name")
93 call assert_equals(
real(100-i), data%version,
"Compare registered and expected version")
95 call assert_equals(merge(.true., .false., i .le. init_callbacks),
associated(data%initialisation), &
96 "Consistency of initialisation call-back")
97 call assert_equals(merge(.true., .false., i .le. timestep_callbacks),
associated(data%timestep), &
98 "Consistency of timestep call-back")
99 call assert_equals(merge(.true., .false., i .le. consolidation_callbacks),
associated(data%consolidation), &
100 "Consistency of consolidation call-back")
101 call assert_equals(merge(.true., .false., i .le. modeldump_callbacks),
associated(data%modeldump), &
102 "Consistency of model dump call-back")
103 call assert_equals(merge(.true., .false., i .le. finalisation_callbacks),
associated(data%finalisation), &
104 "Consistency of finalisation all-back")
106 call assert_false(
associated(data),
"No component if greater than 100")
117 integer :: init_callbacks, timestep_callbacks, consolidation_callbacks, modeldump_callbacks,&
118 finalisation_callbacks, i
123 modeldump_callbacks, finalisation_callbacks)
140 call execute_consolidation_callbacks(testing_state)
141 call execute_modeldump_callbacks(testing_state)
145 call assert_equals(init_callbacks,
init_calls,
"Number of initialisation call-backs post removal")
146 call assert_equals(timestep_callbacks,
timestep_calls,
"Number of timestep call-backs post removal")
147 call assert_equals(consolidation_callbacks,
consolidation_calls,
"Number of consolidation call-backs post removal")
148 call assert_equals(modeldump_callbacks,
modeldump_calls,
"Number of model dump call-backs post removal")
149 call assert_equals(finalisation_callbacks,
finalisation_calls,
"Number of finalisation call-backs post removal")
157 integer :: init_callbacks, timestep_callbacks, consolidation_callbacks, modeldump_callbacks, finalisation_callbacks
162 modeldump_callbacks, finalisation_callbacks)
167 call execute_consolidation_callbacks(testing_state)
168 call execute_modeldump_callbacks(testing_state)
172 call assert_equals(init_callbacks,
init_calls,
"Number of initialisation call-backs")
173 call assert_equals(timestep_callbacks,
timestep_calls,
"Number of timestep call-backs")
174 call assert_equals(consolidation_callbacks,
consolidation_calls,
"Number of consolidation call-backs")
175 call assert_equals(modeldump_callbacks,
modeldump_calls,
"Number of model dump call-backs")
176 call assert_equals(finalisation_callbacks,
finalisation_calls,
"Number of finalisation call-backs")
183 integer :: init_callbacks, timestep_callbacks, consolidation_callbacks, modeldump_callbacks, finalisation_callbacks
188 modeldump_callbacks, finalisation_callbacks)
191 modeldump_callbacks, finalisation_callbacks)
196 call execute_consolidation_callbacks(testing_state)
197 call execute_modeldump_callbacks(testing_state)
201 call assert_equals(init_callbacks,
init_calls,
"Number of initialisation call-backs post replacement")
202 call assert_equals(timestep_callbacks,
timestep_calls,
"Number of timestep call-backs post replacement")
203 call assert_equals(consolidation_callbacks,
consolidation_calls,
"Number of consolidation call-backs post replacement")
204 call assert_equals(modeldump_callbacks,
modeldump_calls,
"Number of model dump call-backs post replacement")
205 call assert_equals(finalisation_callbacks,
finalisation_calls,
"Number of finalisation call-backs post replacement")
211 integer,
intent(in) :: orig_value, a, b
213 if (orig_value .ge. a)
then 223 modelDump_callbacks, finalisation_callbacks)
225 integer,
intent(out) :: init_callbacks, timestep_callbacks, consolidation_callbacks, &
226 modelDump_callbacks, finalisation_callbacks
231 call random_number(r)
232 init_callbacks = int(r*99)+1
233 call random_number(r)
234 timestep_callbacks = int(r*99)+1
235 call random_number(r)
236 consolidation_callbacks = int(r*99)+1
237 call random_number(r)
238 modeldump_callbacks = int(r*99)+1
239 call random_number(r)
240 finalisation_callbacks = int(r*99)+1
243 modeldump_callbacks, finalisation_callbacks)
248 modelDump_callbacks, finalisation_callbacks)
250 integer,
intent(in) :: init_callbacks, timestep_callbacks, consolidation_callbacks, &
251 modelDump_callbacks, finalisation_callbacks
257 descriptor%name=
"Test "//
str(i)
258 descriptor%version=100-i
304 character(len=15) function str(k)
305 integer,
intent(in) :: k
312 integer :: i, n, clock
313 integer,
dimension(:),
allocatable :: seed
315 call random_seed(
size = n)
318 call system_clock(count=clock)
320 seed = clock + 37 * (/ (i - 1, i = 1, n) /)
321 call random_seed(put = seed)
339 use fruit
, only : init_fruit, run_test_case, fruit_summary
subroutine test_deregister()
Retrieves the key currently being held at a specific index in the map or "" if the index > map elemen...
type(component_descriptor_type) function, pointer, public get_component_info(name)
Retrieves detailed information about a specific component.
subroutine test_component_information()
integer function calculate_remaining_calls(orig_value, a, b)
subroutine test_register()
subroutine test_component_replacement_callbacks()
subroutine, public free_registry()
Will deregister all components and free up the registry data structures. This can either be called at...
subroutine internal_test_init(current_state)
subroutine internal_test_modeldump(current_state)
type(map_type) function, public get_all_registered_components()
Returns a brief summary of all registered components.
character(len=15) function str(k)
subroutine, public execute_timestep_callbacks(current_state, group_id)
Calls all timestep callbacks with the specified state.
The ModelState which represents the current state of a run.
subroutine generate_dummy_callbacks(init_callbacks, timestep_callbacks, consolidation_callbacks, modelDump_callbacks, finalisation_callbacks)
Description of a component.
Map data structure that holds string (length 20 maximum) key value pairs.
subroutine internal_test_finalisation(current_state)
subroutine test_component_removal_callbacks()
Returns the number of elements in the collection.
Interfaces and types that MONC components must specify.
subroutine internal_test_consolidation(current_state)
subroutine clear_counters()
Collection data structures.
subroutine internal_test_timestep(current_state)
subroutine init_random_seed()
program test_registry_driver
subroutine, public execute_initialisation_callbacks(current_state)
Calls all initialisation callbacks with the specified state.
integer consolidation_calls
subroutine, public deregister_component(name)
Will deregister a component, remove all callback hooks and free registry specific memory allocated to...
subroutine, public register_component(options_database, descriptor)
Will register a component and install the nescesary callback hooks.
The model state which represents the current state of a run.
subroutine insert_component_callbacks(init_callbacks, timestep_callbacks, consolidation_callbacks, modelDump_callbacks, finalisation_callbacks)
subroutine, public execute_finalisation_callbacks(current_state)
Calls all finalisation callbacks with the specified state.
subroutine test_component_callbacks()
integer finalisation_calls