MONC
reductionlocation-operator.F90
Go to the documentation of this file.
6  implicit none
7 
8 #ifndef TEST_MODE
9  private
10 #endif
11 
13 contains
14 
15  subroutine perform_reductionlocation_operator(io_configuration, field_values, action_attributes, source_monc_location, &
16  source_monc, operator_result_values)
17  type(io_configuration_type), intent(inout) :: io_configuration
18  type(hashmap_type), intent(inout) :: field_values
19  type(map_type), intent(inout) :: action_attributes
20  integer, intent(in) :: source_monc_location, source_monc
21  real(kind=DEFAULT_PRECISION), dimension(:), allocatable, intent(inout) :: operator_result_values
22 
23  character(len=STRING_LENGTH) :: location_local, val, val_local
24  type(data_values_type), pointer :: val_local_values, val_values, location_local_values
25  integer :: i
26 
27  call extract_tripplet_variables(get_action_attribute_string(action_attributes, "input"), location_local, val, val_local)
28 
29  val_local_values=>get_data_value_by_field_name(field_values, val_local)
30  val_values=>get_data_value_by_field_name(field_values, val)
31  location_local_values=>get_data_value_by_field_name(field_values, location_local)
32 
33  allocate(operator_result_values(size(location_local_values%values)))
34  do i=1, size(val_local_values%values)
35  if (val_local_values%values(i) .eq. val_values%values(i)) then
36  operator_result_values(i)=location_local_values%values(i)
37  else
38  operator_result_values(i)=-1.0_default_precision
39  end if
40  end do
42 
43  type(list_type) function reductionlocation_operator_get_required_fields(action_attributes)
44  type(map_type), intent(inout) :: action_attributes
45 
46  character(len=STRING_LENGTH) :: location_local, val, val_local
47 
48  call extract_tripplet_variables(get_action_attribute_string(action_attributes, "input"), location_local, val, val_local)
49 
50  call c_add_string(reductionlocation_operator_get_required_fields, location_local)
51  call c_add_string(reductionlocation_operator_get_required_fields, val)
52  call c_add_string(reductionlocation_operator_get_required_fields, val_local)
54 
55  subroutine extract_tripplet_variables(field_str, location_local, val, val_local)
56  character(len=*), intent(in) :: field_str
57  character(len=*), intent(out) :: location_local, val, val_local
58 
59  character :: c
60  character(len=STRING_LENGTH) :: artefacts(3)
61  integer :: i, field_length, start_point, index_loc
62 
63  field_length=len(trim(field_str))
64 
65  start_point=1
66  index_loc=1
67  do i=1, field_length
68  c=field_str(i:i)
69  if (c .eq. ",") then
70  artefacts(index_loc)=trim(adjustl(field_str(start_point: i-1)))
71  start_point=i+1
72  index_loc=index_loc+1
73  end if
74  end do
75  if (start_point .lt. i) artefacts(index_loc)=trim(adjustl(field_str(start_point: i-1)))
76  location_local=artefacts(1)
77  val=artefacts(2)
78  val_local=artefacts(3)
79  end subroutine extract_tripplet_variables
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
subroutine extract_tripplet_variables(field_str, location_local, val, val_local)
Map data structure that holds string (length 20 maximum) key value pairs.
Definition: collections.F90:86
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
List data structure which implements a doubly linked list. This list will preserve its order...
Definition: collections.F90:60
subroutine, public perform_reductionlocation_operator(io_configuration, field_values, action_attributes, source_monc_location, source_monc, operator_result_values)
Adds a string to the end of the list.
type(list_type) function, public reductionlocation_operator_get_required_fields(action_attributes)
Parses the XML configuration file to produce the io configuration description which contains the data...