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

MONC component registry. More...

Data Types

type  group_descriptor_type
 Descriptor of a group. More...
 
type  pointer_wrapper_type
 Private helper type which wraps a procedure pointer. This is needed for storage in our collections_mod and allows us to associate additional information, such as number of times called, performance etc in future if we wanted to. More...
 

Functions/Subroutines

subroutine, public init_registry (options_database)
 Initialises the registry with the provided configuration file. More...
 
subroutine, public free_registry ()
 Will deregister all components and free up the registry data structures. This can either be called at the end of execution to clean memory up or used to clear the registry. More...
 
subroutine, public register_component (options_database, descriptor)
 Will register a component and install the nescesary callback hooks. More...
 
logical function, public is_component_field_available (name)
 Determines whether a specific published field is available or not. More...
 
type(component_field_value_type) function, public get_component_field_value (current_state, name)
 Retrieves the value wrapper of a components published field. More...
 
type(component_field_information_type) function, public get_component_field_information (current_state, name)
 Retrieves information about a components published field which includes its type and size. More...
 
type(list_type) function, public get_all_component_published_fields ()
 Retrieves all of the published field information. More...
 
subroutine load_published_fields (descriptor)
 Loads the published fields information for an entire component into the registry's definition list. More...
 
subroutine, public deregister_component (name)
 Will deregister a component, remove all callback hooks and free registry specific memory allocated to the component. More...
 
type(component_descriptor_type) function, pointer, public get_component_info (name)
 Retrieves detailed information about a specific component. More...
 
type(map_type) function, public get_all_registered_components ()
 Returns a brief summary of all registered components. More...
 
subroutine, public execute_initialisation_callbacks (current_state)
 Calls all initialisation callbacks with the specified state. More...
 
subroutine, public execute_timestep_callbacks (current_state, group_id)
 Calls all timestep callbacks with the specified state. More...
 
subroutine, public execute_finalisation_callbacks (current_state)
 Calls all finalisation callbacks with the specified state. More...
 
subroutine, public order_all_callbacks ()
 Orders all callbacks in the prospective stages based upon the priorities of each descriptor. More...
 
type(map_type) function order_grouped_timstep_callbacks (group_id)
 
logical function, public is_component_enabled (options_database, component_name)
 Determines whether or not a specific component is registered and enabled. More...
 
subroutine, public display_callbacks_in_order_at_each_stage ()
 Displays the registered callbacks of each stage in the order that they will be called. More...
 
subroutine, public get_ordered_groups (ordered_groups)
 Orders all the groups (in the order that they will be called in) and returns an array with these in order. This is useful for prefetching the groups in order so that per timestep we can just iterate through the array which is O(n) More...
 
integer function get_group_id (group_name)
 Given a group name this returns the id (i.e. order) of that group. More...
 
type(group_descriptor_type) function get_group_descriptor_from_name (group_name)
 Given a group name this returns the group descriptor corresponding to that or an error if none is found. More...
 
type(group_descriptor_type) function get_group_descriptor_from_id (group_id)
 Given the id of a group this will return the corresponding descriptor. More...
 
subroutine display_callbacks_in_order (stage_callbacks, stagetitle)
 Displays the registered callbacks of a specific stage in the order that they will be called. More...
 
subroutine read_initialisation_and_finalisation_orders (options_database)
 
subroutine read_specific_orders (options_database, key, data_structure)
 
subroutine read_group_configurations (options_database)
 
subroutine remove_descriptor (descriptor)
 Will remove a specific descriptor from the registry table and uninstall the corresponding callback hooks for each state. More...
 
subroutine unload_callback_hooks (descriptor, group_name)
 Will unload the callback hooks that have been installed for each state. More...
 
subroutine load_callback_hooks (descriptor, group_name)
 Will install the callback hooks for each state. More...
 
subroutine rebalance_callbacks (callbacks, priorities, stage_name)
 
integer function get_highest_callback_priority (callbacks, priorities)
 
subroutine execute_callbacks (callback_map, current_state)
 Will execute the appropriate callbacks in a specific map_type given the current state. More...
 
subroutine add_callback (callback_map, name, procedure_pointer)
 Will install a specific callback hook into the specified map_type of existing hooks. More...
 

Variables

integer, parameter, public group_type_whole =0
 Execute the callbacks in this group once per timestep. More...
 
integer, parameter, public group_type_column =1
 Execute the callbacks in this group for each column per timestep. More...
 
type(list_type), save field_information
 
integer, dimension(:), allocatable group_types
 Group types. More...
 
character(len=string_length), dimension(:), allocatable enabled_component_input_keys
 Temporary read array of component enable names. More...
 
character(len=string_length), dimension(:), allocatable group_locations
 Provides an id to each group. More...
 
type(map_type), save init_callbacks
 Callback hooks for the initialisation stage. More...
 
type(map_type), save finalisation_callbacks
 Callback hooks for the finalisation stage. More...
 
type(map_type), save component_descriptions
 Copies of component descriptors. More...
 
type(map_type), save group_descriptors
 Group descriptors for each group, name->descriptor. More...
 
type(map_type), save component_groups
 
type(map_type), save init_orderings
 
type(map_type), save finalisation_orderings
 
type(hashmap_type), save field_procedure_retrievals
 
type(hashmap_type), save field_procedure_sizings
 
type(map_type), dimension(:), allocatable timestep_callbacks
 Callback hooks for the timestep stage. More...
 

Detailed Description

MONC component registry.

Supports management of components. Each stage is called via the registry which will execute the installed callback hooks for that stage in order.

Function/Subroutine Documentation

◆ add_callback()

subroutine registry_mod::add_callback ( type(map_type), intent(inout)  callback_map,
character(len=*), intent(in)  name,
procedure(), pointer  procedure_pointer 
)
private

Will install a specific callback hook into the specified map_type of existing hooks.

Parameters
callbackmap_typeThe map_type of existing callbacks which we are going to install this one into
nameThe name of the callback that we are installing
procedurePointerPointer to the procedure which implements the callback

Definition at line 646 of file registry.F90.

647  type(map_type), intent(inout) :: callback_map
648  procedure(), pointer :: procedure_pointer
649  character(len=*), intent(in) :: name
650 
651  type(pointer_wrapper_type), pointer :: wrapper
652  class(*), pointer :: genericwrapper
653 
654  allocate(wrapper) ! We allocate our own copy of the descriptor here to ensure the consistency of registry information
655  wrapper%ptr => procedure_pointer
656  genericwrapper=>wrapper
657  call c_put_generic(callback_map, name, genericwrapper, .false.)
Here is the caller graph for this function:

◆ deregister_component()

subroutine, public registry_mod::deregister_component ( character(len=*), intent(in)  name)

Will deregister a component, remove all callback hooks and free registry specific memory allocated to the component.

Parameters
nameThe name of the component to de-register

Definition at line 225 of file registry.F90.

226  character(len=*), intent(in) :: name
227  class(*), pointer :: description_data
228 
229  description_data=>c_get_generic(component_descriptions, name)
230  select type(description_data)
231  type is (component_descriptor_type)
232  call remove_descriptor(description_data)
233  end select
234  deallocate(description_data) ! Is added as a clone of the original so free the memory
Here is the call graph for this function:
Here is the caller graph for this function:

◆ display_callbacks_in_order()

subroutine registry_mod::display_callbacks_in_order ( type(map_type), intent(inout)  stage_callbacks,
character(len=*), intent(in)  stagetitle 
)
private

Displays the registered callbacks of a specific stage in the order that they will be called.

Parameters
stageCallbacksThe registered callbacks for a stage
stagetitleThe title of the stage - used for printing out information

Definition at line 435 of file registry.F90.

436  type(map_type), intent(inout) :: stage_callbacks
437  character(len=*), intent(in) :: stagetitle
438 
439  integer :: i, entries
440 
441  entries = c_size(stage_callbacks)
442  do i=1,entries
443  call log_master_log(log_info, "Stage: "//stagetitle//" at: "//trim(conv_to_string(i))//" "//c_key_at(stage_callbacks, i))
444  end do
Here is the caller graph for this function:

◆ display_callbacks_in_order_at_each_stage()

subroutine, public registry_mod::display_callbacks_in_order_at_each_stage

Displays the registered callbacks of each stage in the order that they will be called.

Definition at line 347 of file registry.F90.

348  integer :: i
349  type(group_descriptor_type) :: group_descriptor
350 
351  call display_callbacks_in_order(init_callbacks, "init")
352  do i=1,size(timestep_callbacks)
353  group_descriptor=get_group_descriptor_from_id(i)
354  call display_callbacks_in_order(timestep_callbacks(i), "timestep group '"//trim(group_descriptor%name)//"'")
355  end do
356  call display_callbacks_in_order(finalisation_callbacks, "finalisation")
Here is the call graph for this function:
Here is the caller graph for this function:

◆ execute_callbacks()

subroutine registry_mod::execute_callbacks ( type(map_type), intent(inout)  callback_map,
type(model_state_type), intent(inout)  current_state 
)
private

Will execute the appropriate callbacks in a specific map_type given the current state.

Parameters
callbackmap_typeThe map_type of callback hooks to execute
currentStateThe model state which may be (and likely is) modified in callbacks

Definition at line 625 of file registry.F90.

626  type(map_type), intent(inout) :: callback_map
627  type(model_state_type), intent(inout) :: current_state
628 
629  class(*), pointer :: data
630  type(iterator_type) :: iterator
631 
632  iterator=c_get_iterator(callback_map)
633  do while (c_has_next(iterator))
634  data=>c_get_generic(c_next_mapentry(iterator))
635  select type(data)
636  type is (pointer_wrapper_type)
637  call data%ptr(current_state)
638  end select
639  end do
Here is the caller graph for this function:

◆ execute_finalisation_callbacks()

subroutine, public registry_mod::execute_finalisation_callbacks ( type(model_state_type), intent(inout)  current_state)

Calls all finalisation callbacks with the specified state.

Parameters
currentStateThe current model state which may (and often is) modified

Definition at line 293 of file registry.F90.

294  type(model_state_type), intent(inout) :: current_state
295 
296  call execute_callbacks(finalisation_callbacks, current_state)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ execute_initialisation_callbacks()

subroutine, public registry_mod::execute_initialisation_callbacks ( type(model_state_type), intent(inout)  current_state)

Calls all initialisation callbacks with the specified state.

Parameters
currentStateThe current model state which may (and often is) modified

Definition at line 274 of file registry.F90.

275  type(model_state_type), intent(inout) :: current_state
276 
277  call execute_callbacks(init_callbacks, current_state)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ execute_timestep_callbacks()

subroutine, public registry_mod::execute_timestep_callbacks ( type(model_state_type), intent(inout)  current_state,
integer  group_id 
)

Calls all timestep callbacks with the specified state.

Parameters
currentStateThe current model state which may (and often is) modified

Definition at line 282 of file registry.F90.

283  type(model_state_type), intent(inout) :: current_state
284  integer :: group_id
285 
286  if (.not. c_is_empty(timestep_callbacks(group_id))) then
287  call execute_callbacks(timestep_callbacks(group_id), current_state)
288  end if
Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_registry()

subroutine, public registry_mod::free_registry

Will deregister all components and free up the registry data structures. This can either be called at the end of execution to clean memory up or used to clear the registry.

Definition at line 76 of file registry.F90.

77  integer :: i, entries
78 
79  entries = c_size(component_descriptions)
80  do i=1, entries
81  ! Key de registering key at element one as each deregister removes elements from map_type
82  call deregister_component(c_key_at(component_descriptions, 1))
83  end do
84 
85  call c_free(init_callbacks)
86  do i=1,size(timestep_callbacks)
87  call c_free(timestep_callbacks(i))
88  end do
89  deallocate(timestep_callbacks)
90  call c_free(finalisation_callbacks)
91  call c_free(component_descriptions)
92  call c_free(component_groups)
93  call c_free(init_orderings)
94  call c_free(finalisation_orderings)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_all_component_published_fields()

type(list_type) function, public registry_mod::get_all_component_published_fields

Retrieves all of the published field information.

Returns
The list of published fields

Definition at line 184 of file registry.F90.

185  type(list_type) :: get_all_component_published_fields
186 
187  get_all_component_published_fields=field_information

◆ get_all_registered_components()

type(map_type) function, public registry_mod::get_all_registered_components

Returns a brief summary of all registered components.

Returns
A map_type where the keys are the component names and value the corresponding version number

Definition at line 257 of file registry.F90.

258  integer :: i, number_of_components
259  class(*), pointer :: description_data
260  type(iterator_type) :: iterator
261 
262  iterator=c_get_iterator(component_descriptions)
263  do while (c_has_next(iterator))
264  description_data=>c_get_generic(c_next_mapentry(iterator))
265  select type(description_data)
266  type is(component_descriptor_type)
267  call c_put_real(get_all_registered_components, description_data%name, description_data%version)
268  end select
269  end do
Here is the caller graph for this function:

◆ get_component_field_information()

type(component_field_information_type) function, public registry_mod::get_component_field_information ( type(model_state_type), intent(inout), target  current_state,
character(len=*), intent(in)  name 
)

Retrieves information about a components published field which includes its type and size.

Parameters
nameThe name of the field to look up
Returns
The value wrapper that is associated with this field

Definition at line 164 of file registry.F90.

165  type(model_state_type), target, intent(inout) :: current_state
166  character(len=*), intent(in) :: name
167  type(component_field_information_type) :: get_component_field_information
168 
169  class(*), pointer :: data
170 
171  if (c_contains(field_procedure_retrievals, name)) then
172  data=>c_get_generic(field_procedure_sizings, name)
173  select type(data)
174  type is (pointer_wrapper_type)
175  call data%ptr(current_state, name, get_component_field_information)
176  end select
177  else
178  call log_master_log(log_error, "Published field '"//trim(name)//"' is not found in any enabled components")
179  end if
Here is the call graph for this function:

◆ get_component_field_value()

type(component_field_value_type) function, public registry_mod::get_component_field_value ( type(model_state_type), intent(inout), target  current_state,
character(len=*), intent(in)  name 
)

Retrieves the value wrapper of a components published field.

Parameters
nameThe name of the field to look up
Returns
The value wrapper that is associated with this field

Definition at line 143 of file registry.F90.

144  type(model_state_type), target, intent(inout) :: current_state
145  character(len=*), intent(in) :: name
146  type(component_field_value_type) :: get_component_field_value
147 
148  class(*), pointer :: data
149 
150  if (c_contains(field_procedure_retrievals, name)) then
151  data=>c_get_generic(field_procedure_retrievals, name)
152  select type(data)
153  type is (pointer_wrapper_type)
154  call data%ptr(current_state, name, get_component_field_value)
155  end select
156  else
157  call log_master_log(log_error, "Published field '"//trim(name)//"' is not found in any enabled components")
158  end if
Here is the call graph for this function:

◆ get_component_info()

type(component_descriptor_type) function, pointer, public registry_mod::get_component_info ( character(len=*), intent(in)  name)

Retrieves detailed information about a specific component.

Parameters
nameThe name of the component to retrieve information for
Returns
The registry's copy of the component descriptor or null if it does not exist

Definition at line 240 of file registry.F90.

241  character(len=*), intent(in) :: name
242  type(component_descriptor_type), pointer :: get_component_info
243  class(*), pointer :: description_data
244 
245  get_component_info => null()
246  description_data => c_get_generic(component_descriptions, name)
247  if (associated(description_data)) then
248  select type(description_data)
249  type is (component_descriptor_type)
250  get_component_info => description_data
251  end select
252  end if
Here is the caller graph for this function:

◆ get_group_descriptor_from_id()

type(group_descriptor_type) function registry_mod::get_group_descriptor_from_id ( integer, intent(in)  group_id)
private

Given the id of a group this will return the corresponding descriptor.

Parameters
group_idId of the group to find
Returns
The descriptor that has the correct id number

Definition at line 411 of file registry.F90.

412  integer, intent(in) :: group_id
413 
414  type(iterator_type) :: iterator
415  class(*), pointer :: generic
416 
417  iterator=c_get_iterator(group_descriptors)
418  do while (c_has_next(iterator))
419  generic=>c_get_generic(c_next_mapentry(iterator))
420  if (associated(generic)) then
421  select type(generic)
422  type is(group_descriptor_type)
423  if (generic%id == group_id) then
424  get_group_descriptor_from_id=generic
425  return
426  end if
427  end select
428  end if
429  end do
Here is the caller graph for this function:

◆ get_group_descriptor_from_name()

type(group_descriptor_type) function registry_mod::get_group_descriptor_from_name ( character(len=*), intent(in)  group_name)
private

Given a group name this returns the group descriptor corresponding to that or an error if none is found.

Parameters
group_nameName of the group to look up
Returns
Descriptor of the corresponding group

Definition at line 392 of file registry.F90.

393  character(len=*), intent(in) :: group_name
394 
395  class(*), pointer :: generic
396 
397  generic=>c_get_generic(group_descriptors, group_name)
398  if (associated(generic)) then
399  select type(generic)
400  type is(group_descriptor_type)
401  get_group_descriptor_from_name=generic
402  end select
403  else
404  call log_master_log(log_error, "No configuration specified for group "//group_name)
405  end if
Here is the caller graph for this function:

◆ get_group_id()

integer function registry_mod::get_group_id ( character(len=*), intent(in)  group_name)
private

Given a group name this returns the id (i.e. order) of that group.

Parameters
group_nameThe group name to look up
Returns
The id (also order) of the group

Definition at line 380 of file registry.F90.

381  character(len=*), intent(in) :: group_name
382 
383  type(group_descriptor_type) :: descriptor
384 
385  descriptor=get_group_descriptor_from_name(group_name)
386  get_group_id=descriptor%id
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_highest_callback_priority()

integer function registry_mod::get_highest_callback_priority ( type(map_type), intent(inout)  callbacks,
type(map_type), intent(inout)  priorities 
)
private

Definition at line 599 of file registry.F90.

600  type(map_type), intent(inout) :: callbacks, priorities
601 
602  integer :: i, entries_in_list, min_priority, min_location, priority
603  character(len=STRING_LENGTH) :: key
604 
605  min_location=0
606  min_priority=1000
607 
608  entries_in_list=c_size(callbacks)
609  do i=1, entries_in_list
610  key=c_key_at(callbacks, i)
611  if (c_contains(priorities, key)) then
612  priority=c_get_integer(priorities, key)
613  if (priority .lt. min_priority) then
614  min_priority=priority
615  min_location=i
616  end if
617  end if
618  end do
619  get_highest_callback_priority=min_location
Here is the caller graph for this function:

◆ get_ordered_groups()

subroutine, public registry_mod::get_ordered_groups ( type(group_descriptor_type), dimension(:), allocatable  ordered_groups)

Orders all the groups (in the order that they will be called in) and returns an array with these in order. This is useful for prefetching the groups in order so that per timestep we can just iterate through the array which is O(n)

Returns
An array of groups in the order that they will be executed in

Definition at line 362 of file registry.F90.

363  type(group_descriptor_type), dimension(:), allocatable :: ordered_groups
364 
365  integer :: i
366 
367  allocate(ordered_groups(c_size(group_descriptors)))
368  do i=1,c_size(group_descriptors)
369  ordered_groups(i)=get_group_descriptor_from_id(i)
370  end do
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_registry()

subroutine, public registry_mod::init_registry ( type(hashmap_type), intent(inout)  options_database)

Initialises the registry with the provided configuration file.

Parameters
configurationFileNameThe filename of the configuration file to parse

Definition at line 66 of file registry.F90.

67  type(hashmap_type), intent(inout) :: options_database
68 
69  call read_group_configurations(options_database)
70  call read_initialisation_and_finalisation_orders(options_database)
71  allocate(timestep_callbacks(c_size(group_descriptors)))
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_component_enabled()

logical function, public registry_mod::is_component_enabled ( type(hashmap_type), intent(inout)  options_database,
character(len=*), intent(in)  component_name 
)

Determines whether or not a specific component is registered and enabled.

Parameters
component_nameThe name of the component to check for

Definition at line 333 of file registry.F90.

334  type(hashmap_type), intent(inout) :: options_database
335  character(len=*), intent(in) :: component_name
336 
337  if (c_contains(component_descriptions, component_name)) then
338  if (options_has_key(options_database, trim(component_name)//"_enabled")) then
339  is_component_enabled=options_get_logical(options_database, trim(component_name)//"_enabled")
340  return
341  end if
342  end if
343  is_component_enabled=.false.
Here is the caller graph for this function:

◆ is_component_field_available()

logical function, public registry_mod::is_component_field_available ( character(len=*), intent(in)  name)

Determines whether a specific published field is available or not.

Parameters
nameThe name of the field to search for
Returns
Whether this field is found

Definition at line 134 of file registry.F90.

135  character(len=*), intent(in) :: name
136 
137  is_component_field_available=c_contains(field_procedure_retrievals, name)

◆ load_callback_hooks()

subroutine registry_mod::load_callback_hooks ( type(component_descriptor_type), intent(in)  descriptor,
character(len=*), intent(in), optional  group_name 
)
private

Will install the callback hooks for each state.

Parameters
descriptorThe component descriptor which is to be installed

Definition at line 555 of file registry.F90.

556  type(component_descriptor_type), intent(in) :: descriptor
557  character(len=*), intent(in), optional :: group_name
558 
559  if (associated(descriptor%initialisation)) call add_callback(init_callbacks, descriptor%name, descriptor%initialisation)
560  if (associated(descriptor%timestep)) then
561  if (present(group_name)) then
562  call add_callback(timestep_callbacks(get_group_id(group_name)), descriptor%name, descriptor%timestep)
563  else
564  call log_master_log(log_error, "In the configuration you must provide a group for component "&
565  //trim(descriptor%name)//" which has a timestep callback")
566  end if
567  end if
568  if (associated(descriptor%finalisation)) call add_callback(finalisation_callbacks, descriptor%name, descriptor%finalisation)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_published_fields()

subroutine registry_mod::load_published_fields ( type(component_descriptor_type), intent(in)  descriptor)
private

Loads the published fields information for an entire component into the registry's definition list.

Parameters
descriptorThe field descriptor to load in

Definition at line 192 of file registry.F90.

193  type(component_descriptor_type), intent(in) :: descriptor
194 
195  integer :: i
196  class(*), pointer :: field_generic_description
197  type(pointer_wrapper_type), pointer :: wrapper
198  class(*), pointer :: genericwrapper
199 
200  if (associated(descriptor%published_fields) .and. associated(descriptor%field_value_retrieval) .and. &
201  associated(descriptor%field_information_retrieval)) then
202  do i=1, size(descriptor%published_fields)
203  field_generic_description=>descriptor%published_fields(i)
204  call c_add_generic(field_information, field_generic_description, .false.)
205  allocate(wrapper) ! We allocate our own copy of the descriptor here to ensure the consistency of registry information
206  wrapper%ptr => descriptor%field_value_retrieval
207  genericwrapper=>wrapper
208  call c_put_generic(field_procedure_retrievals, descriptor%published_fields(i), genericwrapper, .false.)
209  allocate(wrapper)
210  wrapper%ptr => descriptor%field_information_retrieval
211  genericwrapper=>wrapper
212  call c_put_generic(field_procedure_sizings, descriptor%published_fields(i), genericwrapper, .false.)
213  end do
214 
215  else if (associated(descriptor%published_fields) .or. associated(descriptor%field_value_retrieval) .or. &
216  associated(descriptor%field_information_retrieval)) then
217  call log_master_log(log_warn, "Component "//trim(descriptor%name)//&
218  " has provided incomplete configuration for published fields, therefore ignoring these")
219  end if
Here is the call graph for this function:
Here is the caller graph for this function:

◆ order_all_callbacks()

subroutine, public registry_mod::order_all_callbacks

Orders all callbacks in the prospective stages based upon the priorities of each descriptor.

Note that this is an expensive operation as it involves multiple searches of the component list_types so should be called sparingly. When two priorities are equal then the order depends upon which one was registered first.

Definition at line 304 of file registry.F90.

305  integer :: i
306  type(map_type) :: specific_ts
307 
308  call rebalance_callbacks(init_callbacks, init_orderings, "initialisation")
309  do i=1,size(timestep_callbacks)
310  specific_ts=order_grouped_timstep_callbacks(i)
311  call rebalance_callbacks(timestep_callbacks(i), specific_ts, "time stepping")
312  call c_free(specific_ts)
313  end do
314  call rebalance_callbacks(finalisation_callbacks, finalisation_orderings, "finalisation")
Here is the call graph for this function:
Here is the caller graph for this function:

◆ order_grouped_timstep_callbacks()

type(map_type) function registry_mod::order_grouped_timstep_callbacks ( integer, intent(in)  group_id)
private

Definition at line 317 of file registry.F90.

318  integer, intent(in) :: group_id
319 
320  integer :: group_size, i
321 
322  type(group_descriptor_type) :: descriptor
323 
324  descriptor=get_group_descriptor_from_id(group_id)
325  group_size=descriptor%number_of_members
326  do i=1, group_size
327  call c_put_integer(order_grouped_timstep_callbacks, trim(descriptor%group_members(i)), i)
328  end do
Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_group_configurations()

subroutine registry_mod::read_group_configurations ( type(hashmap_type), intent(inout)  options_database)
private

Definition at line 469 of file registry.F90.

470  type(hashmap_type), intent(inout) :: options_database
471 
472  integer :: group_elements, i, j
473  class(*), pointer :: generic_to_add
474  type(group_descriptor_type) :: group_description
475  character(len=STRING_LENGTH) :: group_type
476 
477  group_elements=options_get_array_size(options_database, "group_names")
478  if (group_elements .lt. 1) call log_master_log(log_error, "You must provide some group definitions")
479  do i=1, group_elements
480  group_description%name=trim(options_get_string(options_database, "group_names", i))
481  if (options_has_key(options_database, trim(group_description%name)//"_group_type")) then
482  group_type=trim(options_get_string(options_database, trim(group_description%name)//"_group_type"))
483  if (trim(group_type) .eq. "entire") then
484  group_description%type=0
485  else if (trim(group_type) .eq. "column") then
486  group_description%type=1
487  else if (trim(group_type) .eq. "slice") then
488  group_description%type=2
489  else
490  call log_master_log(log_error, "Group type "//trim(group_type)//" for group "&
491  //trim(group_description%name)//" not understood")
492  end if
493  else
494  call log_master_log(log_error, "No group type for group "//trim(group_description%name))
495  end if
496  group_description%id=i
497  if (.not. options_has_key(options_database, trim(group_description%name)//"_group_contents")) then
498  call log_master_log(log_error, "No component contents specified for group "//trim(group_description%name))
499  end if
500  group_description%number_of_members=options_get_array_size(options_database, &
501  trim(group_description%name)//"_group_contents")
502  if (group_description%number_of_members == 0 .or. .not. options_has_key(options_database, &
503  trim(group_description%name)//"_group_contentsa_size")) then
504  if (options_has_key(options_database, trim(group_description%name)//"_group_contents")) then
505  group_description%number_of_members=1
506  group_description%group_members(1)=trim(options_get_string(options_database, &
507  trim(group_description%name)//"_group_contents"))
508  call c_put_string(component_groups, trim(group_description%group_members(1)), group_description%name)
509  else
510  call log_master_log(log_error, "No contents specified for group "//trim(group_description%name))
511  end if
512  else
513  do j=1, group_description%number_of_members
514  group_description%group_members(j)=trim(options_get_string(options_database, &
515  trim(group_description%name)//"_group_contents", j))
516  call c_put_string(component_groups, trim(group_description%group_members(j)), group_description%name)
517  end do
518  end if
519  allocate(generic_to_add, source=group_description)
520  call c_put_generic(group_descriptors, group_description%name, generic_to_add, .false.)
521  end do
Here is the caller graph for this function:

◆ read_initialisation_and_finalisation_orders()

subroutine registry_mod::read_initialisation_and_finalisation_orders ( type(hashmap_type), intent(inout)  options_database)
private

Definition at line 447 of file registry.F90.

448  type(hashmap_type), intent(inout) :: options_database
449 
450  call read_specific_orders(options_database, "initialisation_stage_ordering", init_orderings)
451  call read_specific_orders(options_database, "finalisation_stage_ordering", finalisation_orderings)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_specific_orders()

subroutine registry_mod::read_specific_orders ( type(hashmap_type), intent(inout)  options_database,
character(len=*)  key,
type(map_type), intent(inout)  data_structure 
)
private

Definition at line 454 of file registry.F90.

455  type(hashmap_type), intent(inout) :: options_database
456  type(map_type), intent(inout) :: data_structure
457  character(len=*) :: key
458 
459  integer :: number_of_elements, i
460  character(len=STRING_LENGTH) :: component_name
461 
462  number_of_elements=options_get_array_size(options_database, key)
463  do i=1, number_of_elements
464  component_name=options_get_string(options_database, key, i)
465  call c_put_integer(data_structure, trim(component_name), i)
466  end do
Here is the caller graph for this function:

◆ rebalance_callbacks()

subroutine registry_mod::rebalance_callbacks ( type(map_type), intent(inout)  callbacks,
type(map_type), intent(inout)  priorities,
character(len=*), intent(in)  stage_name 
)
private

Definition at line 571 of file registry.F90.

572  type(map_type), intent(inout) :: callbacks, priorities
573  character(len=*), intent(in) :: stage_name
574 
575  type(map_type) :: ordered_callbacks
576  integer :: i, entries_in_list, current_item
577  class(*), pointer :: generic
578 
579  entries_in_list=c_size(callbacks)
580  do i=1, entries_in_list
581  current_item=get_highest_callback_priority(callbacks, priorities)
582  if (current_item .ge. 1) then
583  generic=>c_generic_at(callbacks, current_item)
584  call c_put_generic(ordered_callbacks, c_key_at(callbacks, current_item), generic, .false.)
585  call c_remove(callbacks, c_key_at(callbacks, current_item))
586  end if
587  end do
588 
589  entries_in_list=c_size(callbacks)
590  do i=1, entries_in_list
591  generic=>c_generic_at(callbacks, i)
592  call c_put_generic(ordered_callbacks, c_key_at(callbacks, i), generic, .false.)
593  call log_master_log(log_warn, "Run order callback for component "//trim(c_key_at(callbacks, i))//&
594  " at stage "//stage_name//" not specified")
595  end do
596  callbacks=ordered_callbacks
Here is the call graph for this function:
Here is the caller graph for this function:

◆ register_component()

subroutine, public registry_mod::register_component ( type(hashmap_type), intent(inout)  options_database,
type(component_descriptor_type), intent(in)  descriptor 
)

Will register a component and install the nescesary callback hooks.

Parameters
descriptorThe component descriptor and a separate copy of this it stored as reference

Definition at line 99 of file registry.F90.

100  type(hashmap_type), intent(inout) :: options_database
101  type(component_descriptor_type), intent(in) :: descriptor
102 
103  type(component_descriptor_type), pointer :: registry_descriptor
104  class(*), pointer :: description_data
105  character(len=STRING_LENGTH) :: group_name
106  logical :: component_enabled
107 
108  allocate(registry_descriptor, source=descriptor) ! Make copy of the descriptor (which registry might modify)
109 
110  if (options_has_key(options_database, trim(descriptor%name)//"_enabled")) then
111  component_enabled=options_get_logical(options_database, trim(descriptor%name)//"_enabled")
112  else
113  component_enabled=.false.
114  call log_master_log(log_warn, "No enabled configuration for component "//trim(descriptor%name)//" therefore disabling this")
115  end if
116 
117  if (component_enabled) then
118  if (c_contains(component_groups, trim(descriptor%name))) then
119  group_name=c_get_string(component_groups, trim(descriptor%name))
120  call load_callback_hooks(registry_descriptor, group_name)
121  else
122  call load_callback_hooks(registry_descriptor)
123  end if
124  call load_published_fields(descriptor)
125  end if
126 
127  description_data => registry_descriptor
128  call c_put_generic(component_descriptions, descriptor%name, description_data, .false.)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ remove_descriptor()

subroutine registry_mod::remove_descriptor ( type(component_descriptor_type), intent(inout)  descriptor)
private

Will remove a specific descriptor from the registry table and uninstall the corresponding callback hooks for each state.

Parameters
descriptorThe component descriptor which is to be removed

Definition at line 527 of file registry.F90.

528  type(component_descriptor_type), intent(inout) :: descriptor
529 
530  character(len=STRING_LENGTH) :: group_name
531 
532  if (c_contains(component_groups, trim(descriptor%name))) then
533  group_name=c_get_string(component_groups, trim(descriptor%name))
534  call unload_callback_hooks(descriptor, group_name)
535  else
536  call unload_callback_hooks(descriptor)
537  end if
538  call c_remove(component_descriptions, descriptor%name)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ unload_callback_hooks()

subroutine registry_mod::unload_callback_hooks ( type(component_descriptor_type), intent(in)  descriptor,
character(len=*), intent(in), optional  group_name 
)
private

Will unload the callback hooks that have been installed for each state.

Parameters
descriptorThe component descriptor which is to be unloaded

Definition at line 543 of file registry.F90.

544  type(component_descriptor_type), intent(in) :: descriptor
545  character(len=*), intent(in), optional :: group_name
546 
547  if (associated(descriptor%initialisation)) call c_remove(init_callbacks, descriptor%name)
548  if (associated(descriptor%timestep) .and. present(group_name)) &
549  call c_remove(timestep_callbacks(get_group_id(group_name)), descriptor%name)
550  if (associated(descriptor%finalisation)) call c_remove(finalisation_callbacks, descriptor%name)
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ component_descriptions

type(map_type), save registry_mod::component_descriptions
private

Copies of component descriptors.

Definition at line 47 of file registry.F90.

◆ component_groups

type(map_type), save registry_mod::component_groups
private

Definition at line 47 of file registry.F90.

◆ enabled_component_input_keys

character(len=string_length), dimension(:), allocatable registry_mod::enabled_component_input_keys
private

Temporary read array of component enable names.

Definition at line 28 of file registry.F90.

28  character(len=STRING_LENGTH), dimension(:), allocatable :: enabled_component_input_keys,& !< Temporary read array of component enable names
29  group_locations

◆ field_information

type(list_type), save registry_mod::field_information
private

Definition at line 25 of file registry.F90.

25  type(list_type), save :: field_information

◆ field_procedure_retrievals

type(hashmap_type), save registry_mod::field_procedure_retrievals
private

Definition at line 52 of file registry.F90.

52  type(hashmap_type), save :: field_procedure_retrievals, field_procedure_sizings

◆ field_procedure_sizings

type(hashmap_type), save registry_mod::field_procedure_sizings
private

Definition at line 52 of file registry.F90.

◆ finalisation_callbacks

type(map_type), save registry_mod::finalisation_callbacks
private

Callback hooks for the finalisation stage.

Definition at line 47 of file registry.F90.

◆ finalisation_orderings

type(map_type), save registry_mod::finalisation_orderings
private

Definition at line 47 of file registry.F90.

◆ group_descriptors

type(map_type), save registry_mod::group_descriptors
private

Group descriptors for each group, name->descriptor.

Definition at line 47 of file registry.F90.

◆ group_locations

character(len=string_length), dimension(:), allocatable registry_mod::group_locations
private

Provides an id to each group.

Definition at line 28 of file registry.F90.

◆ group_type_column

integer, parameter, public registry_mod::group_type_column =1

Execute the callbacks in this group for each column per timestep.

Definition at line 22 of file registry.F90.

◆ group_type_whole

integer, parameter, public registry_mod::group_type_whole =0

Execute the callbacks in this group once per timestep.

Definition at line 22 of file registry.F90.

22  integer, parameter :: GROUP_TYPE_WHOLE=0, & !< Execute the callbacks in this group once per timestep
23  group_type_column=1

◆ group_types

integer, dimension(:), allocatable registry_mod::group_types
private

Group types.

Definition at line 27 of file registry.F90.

27  integer, dimension(:), allocatable :: group_types

◆ init_callbacks

type(map_type), save registry_mod::init_callbacks
private

Callback hooks for the initialisation stage.

Definition at line 47 of file registry.F90.

47  type(map_type), save :: init_callbacks,& !< Callback hooks for the initialisation stage
48  finalisation_callbacks,& !< Callback hooks for the finalisation stage
49  component_descriptions,& !< Copies of component descriptors
50  group_descriptors,& !< Group descriptors for each group, name->descriptor
51  component_groups, init_orderings, finalisation_orderings

◆ init_orderings

type(map_type), save registry_mod::init_orderings
private

Definition at line 47 of file registry.F90.

◆ timestep_callbacks

type(map_type), dimension(:), allocatable registry_mod::timestep_callbacks
private

Callback hooks for the timestep stage.

Definition at line 54 of file registry.F90.

54  type(map_type), dimension(:), allocatable :: timestep_callbacks
logging_mod::log_error
integer, parameter, public log_error
Only log ERROR messages.
Definition: logging.F90:11
logging_mod::log_warn
integer, parameter, public log_warn
Log WARNING and ERROR messages.
Definition: logging.F90:12
logging_mod::log_info
integer, parameter, public log_info
Log INFO, WARNING and ERROR messages.
Definition: logging.F90:13
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
logging_mod::log_master_log
subroutine, public log_master_log(level, message)
Will log just from the master process.
Definition: logging.F90:47