MONC
localreduce-operator.F90
Go to the documentation of this file.
1 
7  implicit none
8 
9 #ifndef TEST_MODE
10  private
11 #endif
12 
14 contains
15 
23  subroutine perform_localreduce_operator(io_configuration, field_values, action_attributes, source_monc_location, &
24  source_monc, operator_result_values)
25  type(io_configuration_type), intent(inout) :: io_configuration
26  type(hashmap_type), intent(inout) :: field_values
27  type(map_type), intent(inout) :: action_attributes
28  integer, intent(in) :: source_monc_location, source_monc
29  real(kind=DEFAULT_PRECISION), dimension(:), allocatable, intent(inout) :: operator_result_values
30 
31  character(len=STRING_LENGTH) :: field_to_reduce, reduction_operator
32  type(data_values_type), pointer :: field_local_values
33 
34  allocate(operator_result_values(1))
35 
36  field_to_reduce=get_action_attribute_string(action_attributes, "field")
37  reduction_operator=get_action_attribute_string(action_attributes, "operator")
38  field_local_values=>get_data_value_by_field_name(field_values, field_to_reduce)
39  operator_result_values=do_local_reduction(field_local_values%values, reduction_operator)
40  end subroutine perform_localreduce_operator
41 
46  real(kind=DEFAULT_PRECISION) function do_local_reduction(data, reduction_operator)
47  real(kind=DEFAULT_PRECISION), dimension(:), intent(in) :: data
48  character(len=STRING_LENGTH), intent(in) :: reduction_operator
49 
50  if (reduction_operator .eq. "max") then
51  do_local_reduction=maxval(data)
52  else if (reduction_operator .eq. "min") then
53  do_local_reduction=minval(data)
54  else if (reduction_operator .eq. "sum") then
55  do_local_reduction=sum(data)
56  else if (reduction_operator .eq. "mean") then
57  do_local_reduction=sum(data)/size(data)
58  end if
59  end function do_local_reduction
60 
64  type(list_type) function localreduce_operator_get_required_fields(action_attributes)
65  type(map_type), intent(inout) :: action_attributes
66 
67  character(len=STRING_LENGTH) :: field_to_reduce
68 
69  field_to_reduce=get_action_attribute_string(action_attributes, "field")
70  call c_add_string(localreduce_operator_get_required_fields, field_to_reduce)
72 end module localreduce_operator_mod
Contains functionality for managing and extracting data from the raw data dumps that the IO server re...
Definition: datautils.F90:3
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
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.
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
real(kind=default_precision) function do_local_reduction(data, reduction_operator)
Does the actual local reduction, translating the array into a vector based upon the operator...
Collection data structures.
Definition: collections.F90:7
integer, parameter, public string_length
Default length of strings.
Definition: datadefn.F90:10
character(len=string_length) function, public get_action_attribute_string(action_attributes, field_name)
Retrieves the name of a field from the attributes specified in the configuration. ...
Definition: datautils.F90:101
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
Adds a string to the end of the list.
Parses the XML configuration file to produce the io configuration description which contains the data...