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")
72 end module localreduce_operator_mod
collections_mod::map_type
Map data structure that holds string (length 20 maximum) key value pairs.
Definition: collections.F90:86
data_utils_mod
Contains functionality for managing and extracting data from the raw data dumps that the IO server re...
Definition: datautils.F90:3
collections_mod
Collection data structures.
Definition: collections.F90:7
collections_mod::hashmap_type
A hashmap structure, the same as a map but uses hashing for greatly improved performance when storing...
Definition: collections.F90:94
localreduce_operator_mod
Performs a local reduction, reducing a local array into a single scalar value.
Definition: localreduce-operator.F90:2
configuration_parser_mod::io_configuration_type
Overall IO configuration.
Definition: configurationparser.F90:104
localreduce_operator_mod::do_local_reduction
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.
Definition: localreduce-operator.F90:47
configuration_parser_mod::get_data_value_by_field_name
Definition: configurationparser.F90:30
datadefn_mod
Contains common definitions for the data and datatypes used by MONC.
Definition: datadefn.F90:2
configuration_parser_mod::data_values_type
Definition: configurationparser.F90:34
datadefn_mod::string_length
integer, parameter, public string_length
Default length of strings.
Definition: datadefn.F90:10
localreduce_operator_mod::perform_localreduce_operator
subroutine, public perform_localreduce_operator(io_configuration, field_values, action_attributes, source_monc_location, source_monc, operator_result_values)
Executes this local reduction operator.
Definition: localreduce-operator.F90:25
collections_mod::list_type
List data structure which implements a doubly linked list. This list will preserve its order.
Definition: collections.F90:60
collections_mod::c_add_string
Adds a string to the end of the list.
Definition: collections.F90:222
localreduce_operator_mod::localreduce_operator_get_required_fields
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.
Definition: localreduce-operator.F90:65
configuration_parser_mod
Parses the XML configuration file to produce the io configuration description which contains the data...
Definition: configurationparser.F90:3
data_utils_mod::get_action_attribute_string
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
datadefn_mod::default_precision
integer, parameter, public default_precision
MPI communication type which we use for the prognostic and calculation data.
Definition: datadefn.F90:17