MONC
operator.F90
Go to the documentation of this file.
1 
14  use logging_mod, only : log_error, log_log
15  implicit none
16 
17 #ifndef TEST_MODE
18  private
19 #endif
20 
21  abstract interface
22  type(list_type) function get_operator_required_fields_interface(action_attributes)
23  import :: list_type, map_type
24  type(map_type), intent(inout) :: action_attributes
26  subroutine perform_activity(io_configuration, field_values, action_attributes, source_monc_location, &
27  source_monc, operator_result_values)
29  type(io_configuration_type), intent(inout) :: io_configuration
30  type(hashmap_type), intent(inout) :: field_values
31  type(map_type), intent(inout) :: action_attributes
32  integer, intent(in) :: source_monc_location, source_monc
33  real(kind=DEFAULT_PRECISION), dimension(:), allocatable, intent(inout) :: operator_result_values
34  end subroutine perform_activity
35  end interface
36 
39 contains
40 
42  subroutine initialise_operators()
43  call initialise_arithmetic_operator()
44  end subroutine initialise_operators
45 
47  subroutine finalise_operators()
48  call finalise_arithmetic_operator()
49  end subroutine finalise_operators
50 
54  function get_operator_perform_procedure(operator_name)
55  character(len=*), intent(in) :: operator_name
56  procedure(perform_activity), pointer :: get_operator_perform_procedure
57 
58  if (trim(operator_name) .eq. "arithmetic") then
59  get_operator_perform_procedure=>perform_arithmetic_operator
60  else if (trim(operator_name) .eq. "localreduce") then
61  get_operator_perform_procedure=>perform_localreduce_operator
62  else if (trim(operator_name) .eq. "reductionlocation") then
63  get_operator_perform_procedure=>perform_reductionlocation_operator
64  else if (trim(operator_name) .eq. "field_slicer") then
65  get_operator_perform_procedure=>perform_fieldslicer_operator
66  else if (trim(operator_name) .eq. "field_coarsener") then
67  get_operator_perform_procedure=>perform_fieldcoarsener_operator
68  else
69  call log_log(log_error, "Operator '"//trim(operator_name)//"' not found so ignoring")
70  end if
71  end function get_operator_perform_procedure
72 
76  type(list_type) function get_operator_required_fields(operator_name, action_attributes)
77  character(len=*), intent(in) :: operator_name
78  type(map_type), intent(inout) :: action_attributes
79 
80  if (trim(operator_name) .eq. "arithmetic") then
81  get_operator_required_fields=arithmetic_operator_get_required_fields(action_attributes)
82  else if (trim(operator_name) .eq. "localreduce") then
83  get_operator_required_fields=localreduce_operator_get_required_fields(action_attributes)
84  else if (trim(operator_name) .eq. "reductionlocation") then
85  get_operator_required_fields=reductionlocation_operator_get_required_fields(action_attributes)
86  else if (trim(operator_name) .eq. "field_slicer") then
87  get_operator_required_fields=fieldslicer_operator_get_required_fields(action_attributes)
88  else if (trim(operator_name) .eq. "field_coarsener") then
89  get_operator_required_fields=fieldcoarsener_operator_get_required_fields(action_attributes)
90  else
91  call log_log(log_error, "Operator '"//trim(operator_name)//"' not found so ignoring")
92  end if
93  end function get_operator_required_fields
94 
95  integer function get_operator_auto_size(io_configuration, operator_name, auto_dimension, action_attributes)
96  type(io_configuration_type), intent(inout) :: io_configuration
97  character(len=*), intent(in) :: operator_name, auto_dimension
98  type(map_type), intent(inout) :: action_attributes
99 
100  if (trim(operator_name) .eq. "field_coarsener") then
101  get_operator_auto_size=fieldcoarsener_operator_get_auto_size(io_configuration, auto_dimension, action_attributes)
102  else
104  end if
105  end function get_operator_auto_size
106 end module operator_mod
Slices a field based upon the selected dimension and index.
subroutine, public perform_arithmetic_operator(io_configuration, field_values, action_attributes, source_monc_location, source_monc, operator_result_values)
Executes this arithmetic operator by attempting to retrieved the cached equation (and creates one if ...
integer, parameter, public log_error
Only log ERROR messages.
Definition: logging.F90:11
subroutine, public perform_fieldslicer_operator(io_configuration, field_values, action_attributes, source_monc_location, source_monc, operator_result_values)
Performs the actual field slicing.
type(list_type) function, public get_operator_required_fields(operator_name, action_attributes)
Retrieves the list of fields required by an operator before it can run.
Definition: operator.F90:77
Logging utility.
Definition: logging.F90:2
The arithmetic operator which allows the user to define arithmetic formulas based on fields and const...
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
subroutine, public initialise_arithmetic_operator()
Initialises this operator.
A hashmap structure, the same as a map but uses hashing for greatly improved performance when storing...
Definition: collections.F90:94
Performs a local reduction, reducing a local array into a single scalar value.
Operator federator which manages the different operators which are available. Operators take in any n...
Definition: operator.F90:3
subroutine, public log_log(level, message, str)
Logs a message at the specified level. If the level is above the current level then the message is ig...
Definition: logging.F90:75
type(list_type) function, public localreduce_operator_get_required_fields(action_attributes)
Retrieves the list of fields needed by this operator for a specific configuration.
Map data structure that holds string (length 20 maximum) key value pairs.
Definition: collections.F90:86
subroutine, public finalise_arithmetic_operator()
Finalises this opertor.
subroutine, public finalise_operators()
Finalises any operators that require finalisation.
Definition: operator.F90:48
Collection data structures.
Definition: collections.F90:7
procedure(perform_activity) function, pointer, public get_operator_perform_procedure(operator_name)
Retrieves the operator execution procedure of an operator with a specific name.
Definition: operator.F90:55
type(list_type) function, public fieldslicer_operator_get_required_fields(action_attributes)
Retrieves a list of the required fields for running this operator.
type(list_type) function, public fieldcoarsener_operator_get_required_fields(action_attributes)
Retrieves a list of the required fields for running this operator.
type(list_type) function, public arithmetic_operator_get_required_fields(action_attributes)
Retrieves the list of fields needed by this operator for a specific configuration.
subroutine, public perform_localreduce_operator(io_configuration, field_values, action_attributes, source_monc_location, source_monc, operator_result_values)
Executes this local reduction operator.
List data structure which implements a doubly linked list. This list will preserve its order...
Definition: collections.F90:60
subroutine, public perform_fieldcoarsener_operator(io_configuration, field_values, action_attributes, source_monc_location, source_monc, operator_result_values)
Performs the field coarsener operator on a specific field.
integer function, public fieldcoarsener_operator_get_auto_size(io_configuration, auto_dimension, action_attributes)
Retrieves the size of an auto dimension based upon the work that will be completed here...
subroutine, public perform_reductionlocation_operator(io_configuration, field_values, action_attributes, source_monc_location, source_monc, operator_result_values)
Coarsens a field by selecting data with a specific period in any number of dimensions.
type(list_type) function, public reductionlocation_operator_get_required_fields(action_attributes)
integer function, public get_operator_auto_size(io_configuration, operator_name, auto_dimension, action_attributes)
Definition: operator.F90:96
Parses the XML configuration file to produce the io configuration description which contains the data...
subroutine, public initialise_operators()
Initialises any operators that require initialisation.
Definition: operator.F90:43