MONC
registry.F90
Go to the documentation of this file.
1 
6  use datadefn_mod, only : string_length
13  use state_mod, only : model_state_type
16  implicit none
17 
18 #ifndef TEST_MODE
19  private
20 #endif
21 
22  integer, parameter :: group_type_whole=0, & !< Execute the callbacks in this group once per timestep
24 
26 
27  integer, dimension(:), allocatable :: group_types
28  character(len=STRING_LENGTH), dimension(:), allocatable :: enabled_component_input_keys,& !< Temporary read array of component enable names
30 
35  procedure(), nopass, pointer :: ptr
36  end type pointer_wrapper_type
37 
40  character(len=STRING_LENGTH) :: name
41  character(len=STRING_LENGTH), dimension(30) :: group_members
42  integer :: type, & !< Type (execute once per timestep or per column)
43  id, & !< Id number of the group which is also the order executed
44  number_of_members
45  end type group_descriptor_type
46 
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
53 
54  type(map_type), dimension(:), allocatable :: timestep_callbacks
55 
62 contains
63 
66  subroutine init_registry(options_database)
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)
72  end subroutine init_registry
73 
76  subroutine free_registry()
77  integer :: i, entries
78 
80  do i=1, entries
81  ! Key de registering key at element one as each deregister removes elements from map_type
83  end do
84 
86  do i=1,size(timestep_callbacks)
87  call c_free(timestep_callbacks(i))
88  end do
89  deallocate(timestep_callbacks)
95  end subroutine free_registry
96 
99  subroutine register_component(options_database, descriptor)
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.)
129  end subroutine register_component
130 
134  logical function is_component_field_available(name)
135  character(len=*), intent(in) :: name
136 
138  end function is_component_field_available
139 
143  function get_component_field_value(current_state, name)
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
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
159  end function get_component_field_value
160 
164  function get_component_field_information(current_state, name)
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
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
180  end function get_component_field_information
181 
185  type(list_type) :: get_all_component_published_fields
186 
187  get_all_component_published_fields=field_information
189 
192  subroutine load_published_fields(descriptor)
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
220  end subroutine load_published_fields
221 
225  subroutine deregister_component(name)
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
235  end subroutine deregister_component
236 
240  function get_component_info(name)
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
253  end function get_component_info
254 
257  type(map_type) function get_all_registered_components()
258  integer :: i, number_of_components
259  class(*), pointer :: description_data
260  type(iterator_type) :: iterator
261 
263  do while (c_has_next(iterator))
264  description_data=>c_get_generic(c_next_mapentry(iterator))
265  select type(description_data)
267  call c_put_real(get_all_registered_components, description_data%name, description_data%version)
268  end select
269  end do
270  end function get_all_registered_components
271 
274  subroutine execute_initialisation_callbacks(current_state)
275  type(model_state_type), intent(inout) :: current_state
276 
277  call execute_callbacks(init_callbacks, current_state)
278  end subroutine execute_initialisation_callbacks
279 
282  subroutine execute_timestep_callbacks(current_state, group_id)
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
289  end subroutine execute_timestep_callbacks
290 
293  subroutine execute_finalisation_callbacks(current_state)
294  type(model_state_type), intent(inout) :: current_state
295 
296  call execute_callbacks(finalisation_callbacks, current_state)
297  end subroutine execute_finalisation_callbacks
298 
304  subroutine order_all_callbacks()
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
315  end subroutine order_all_callbacks
316 
317  type(map_type) function order_grouped_timstep_callbacks(group_id)
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
330 
333  logical function is_component_enabled(options_database, component_name)
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.
344  end function is_component_enabled
345 
348  integer :: i
349  type(group_descriptor_type) :: group_descriptor
350 
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
358 
362  subroutine get_ordered_groups(ordered_groups)
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
371  end subroutine get_ordered_groups
372 
373  !--------------------------------------------------------------------------
374  ! Private procedures acting as helpers to the functionality of the registry
375  !--------------------------------------------------------------------------
376 
380  integer function get_group_id(group_name)
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
387  end function get_group_id
388 
392  type(group_descriptor_type) function get_group_descriptor_from_name(group_name)
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
406  end function get_group_descriptor_from_name
407 
411  type(group_descriptor_type) function get_group_descriptor_from_id(group_id)
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
430  end function get_group_descriptor_from_id
431 
435  subroutine display_callbacks_in_order(stage_callbacks, stagetitle)
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
445  end subroutine display_callbacks_in_order
446 
447  subroutine read_initialisation_and_finalisation_orders(options_database)
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)
453 
454  subroutine read_specific_orders(options_database, key, data_structure)
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
467  end subroutine read_specific_orders
468 
469  subroutine read_group_configurations(options_database)
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
522  end subroutine read_group_configurations
523 
527  subroutine remove_descriptor(descriptor)
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)
539  end subroutine remove_descriptor
540 
543  subroutine unload_callback_hooks(descriptor, group_name)
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)
551  end subroutine unload_callback_hooks
552 
555  subroutine load_callback_hooks(descriptor, group_name)
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)
569  end subroutine load_callback_hooks
570 
571  subroutine rebalance_callbacks(callbacks, priorities, stage_name)
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
597  end subroutine rebalance_callbacks
598 
599  integer function get_highest_callback_priority(callbacks, priorities)
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
620  end function get_highest_callback_priority
621 
625  subroutine execute_callbacks(callback_map, current_state)
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
640  end subroutine execute_callbacks
641 
646  subroutine add_callback(callback_map, name, procedure_pointer)
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.)
658  end subroutine add_callback
659 end module registry_mod
subroutine display_callbacks_in_order(stage_callbacks, stagetitle)
Displays the registered callbacks of a specific stage in the order that they will be called...
Definition: registry.F90:436
type(map_type), save finalisation_callbacks
Callback hooks for the finalisation stage.
Definition: registry.F90:47
integer, dimension(:), allocatable group_types
Group types.
Definition: registry.F90:27
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...
Retrieves the key currently being held at a specific index in the map or "" if the index > map elemen...
Gets a specific generic element out of the list, stack, queue or map with the corresponding key...
type(component_descriptor_type) function, pointer, public get_component_info(name)
Retrieves detailed information about a specific component.
Definition: registry.F90:241
Wrapper type for the value returned for a published field from a component.
Returns whether a collection is empty.
Puts an integer key-value pair into the map.
type(group_descriptor_type) function get_group_descriptor_from_id(group_id)
Given the id of a group this will return the corresponding descriptor.
Definition: registry.F90:412
subroutine load_callback_hooks(descriptor, group_name)
Will install the callback hooks for each state.
Definition: registry.F90:556
type(map_type), save group_descriptors
Group descriptors for each group, name->descriptor.
Definition: registry.F90:47
subroutine, public display_callbacks_in_order_at_each_stage()
Displays the registered callbacks of each stage in the order that they will be called.
Definition: registry.F90:348
subroutine, public free_registry()
Will deregister all components and free up the registry data structures. This can either be called at...
Definition: registry.F90:77
subroutine unload_callback_hooks(descriptor, group_name)
Will unload the callback hooks that have been installed for each state.
Definition: registry.F90:544
integer, parameter, public log_error
Only log ERROR messages.
Definition: logging.F90:11
subroutine load_published_fields(descriptor)
Loads the published fields information for an entire component into the registry&#39;s definition list...
Definition: registry.F90:193
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.
Logging utility.
Definition: logging.F90:2
type(map_type) function, public get_all_registered_components()
Returns a brief summary of all registered components.
Definition: registry.F90:258
Private helper type which wraps a procedure pointer. This is needed for storage in our collections_mo...
Definition: registry.F90:34
subroutine rebalance_callbacks(callbacks, priorities, stage_name)
Definition: registry.F90:572
Descriptor of a group.
Definition: registry.F90:39
logical function, public is_component_field_available(name)
Determines whether a specific published field is available or not.
Definition: registry.F90:135
character(len=string_length), dimension(:), allocatable group_locations
Provides an id to each group.
Definition: registry.F90:28
subroutine, public execute_timestep_callbacks(current_state, group_id)
Calls all timestep callbacks with the specified state.
Definition: registry.F90:283
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 o...
Definition: registry.F90:363
Contains common definitions for the data and datatypes used by MONC.
Definition: datadefn.F90:2
type(map_type), dimension(:), allocatable timestep_callbacks
Callback hooks for the timestep stage.
Definition: registry.F90:54
The ModelState which represents the current state of a run.
Definition: state.F90:39
logical function, public is_component_enabled(options_database, component_name)
Determines whether or not a specific component is registered and enabled.
Definition: registry.F90:334
subroutine, public log_master_log(level, message)
Will log just from the master process.
Definition: logging.F90:47
A hashmap structure, the same as a map but uses hashing for greatly improved performance when storing...
Definition: collections.F90:94
Gets a specific integer element out of the list, stack, queue or map with the corresponding key...
Conversion between common inbuilt FORTRAN data types.
Definition: conversions.F90:5
Converts data types to strings.
Definition: conversions.F90:36
Puts a string key-value pair into the map.
subroutine read_initialisation_and_finalisation_orders(options_database)
Definition: registry.F90:448
integer function get_group_id(group_name)
Given a group name this returns the id (i.e. order) of that group.
Definition: registry.F90:381
type(map_type), save finalisation_orderings
Definition: registry.F90:47
type(component_field_value_type) function, public get_component_field_value(current_state, name)
Retrieves the value wrapper of a components published field.
Definition: registry.F90:144
type(hashmap_type), save field_procedure_retrievals
Definition: registry.F90:52
Map data structure that holds string (length 20 maximum) key value pairs.
Definition: collections.F90:86
subroutine, public order_all_callbacks()
Orders all callbacks in the prospective stages based upon the priorities of each descriptor.
Definition: registry.F90:305
Returns the number of elements in the collection.
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...
Definition: registry.F90:165
Interfaces and types that MONC components must specify.
subroutine remove_descriptor(descriptor)
Will remove a specific descriptor from the registry table and uninstall the corresponding callback ho...
Definition: registry.F90:528
integer, parameter, public timestep_priority_index
type(map_type), save component_groups
Definition: registry.F90:47
Collection data structures.
Definition: collections.F90:7
integer, parameter, public group_type_whole
Execute the callbacks in this group once per timestep.
Definition: registry.F90:22
integer, parameter, public log_warn
Log WARNING and ERROR messages.
Definition: logging.F90:12
type(map_type), save init_callbacks
Callback hooks for the initialisation stage.
Definition: registry.F90:47
integer, parameter, public string_length
Default length of strings.
Definition: datadefn.F90:10
integer, parameter, public finalisation_priority_index
subroutine add_callback(callback_map, name, procedure_pointer)
Will install a specific callback hook into the specified map_type of existing hooks.
Definition: registry.F90:647
integer function get_highest_callback_priority(callbacks, priorities)
Definition: registry.F90:600
integer, parameter, public init_priority_index
Index of each priority value in the descriptor.
List data structure which implements a doubly linked list. This list will preserve its order...
Definition: collections.F90:60
subroutine read_group_configurations(options_database)
Definition: registry.F90:470
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 fou...
Definition: registry.F90:393
Adds a generic element to the end of the list.
subroutine read_specific_orders(options_database, key, data_structure)
Definition: registry.F90:455
type(list_type) function, public get_all_component_published_fields()
Retrieves all of the published field information.
Definition: registry.F90:185
integer, parameter, public group_type_column
Execute the callbacks in this group for each column per timestep.
Definition: registry.F90:22
type(hashmap_type), save field_procedure_sizings
Definition: registry.F90:52
Manages the options database. Contains administration functions and deduce runtime options from the c...
integer, parameter, public log_info
Log INFO, WARNING and ERROR messages.
Definition: logging.F90:13
logical function, public options_get_logical(options_database, key, index)
Retrieves a logical value from the database that matches the provided key.
subroutine, public execute_initialisation_callbacks(current_state)
Calls all initialisation callbacks with the specified state.
Definition: registry.F90:275
Frees up all the allocatable, heap, memory associated with a list, stack, queue or map...
Puts a generic key-value pair into the map.
Retrieves the generic value held at the specific map index or null if index > map elements...
character(len=string_length), dimension(:), allocatable enabled_component_input_keys
Temporary read array of component enable names.
Definition: registry.F90:28
subroutine, public deregister_component(name)
Will deregister a component, remove all callback hooks and free registry specific memory allocated to...
Definition: registry.F90:226
subroutine, public register_component(options_database, descriptor)
Will register a component and install the nescesary callback hooks.
Definition: registry.F90:100
subroutine execute_callbacks(callback_map, current_state)
Will execute the appropriate callbacks in a specific map_type given the current state.
Definition: registry.F90:626
type(map_type) function order_grouped_timstep_callbacks(group_id)
Definition: registry.F90:318
Determines whether or not a map contains a specific key.
Adds a string to the end of the list.
logical function, public options_has_key(options_database, key)
Determines whether a specific key is in the database.
type(map_type), save init_orderings
Definition: registry.F90:47
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
subroutine, public execute_finalisation_callbacks(current_state)
Calls all finalisation callbacks with the specified state.
Definition: registry.F90:294
Gets a specific string element out of the list, stack, queue or map with the corresponding key...
type(map_type), save component_descriptions
Copies of component descriptors.
Definition: registry.F90:47
type(list_type), save field_information
Definition: registry.F90:25
Puts a double precision real key-value pair into the map.
Removes a specific element from the list or map.
MONC component registry.
Definition: registry.F90:5