MONC
conditional_diagnostics_whole.F90
Go to the documentation of this file.
1 
2 ! Using the totalled values from Part 1, averages the results over the horizontal domain,
3 ! creating profiles of the requested diagnostics under the requested conditions and .not. conditions.
4 ! The "area" diagnostic is a special case, recording the fraction of the domain meeting the associated
5 ! condition and .not. condition.
8  use state_mod, only : model_state_type
9 
11  use grids_mod, only : z_index
13  use mpi, only : mpi_sum, mpi_in_place, mpi_int, mpi_real, mpi_double, mpi_comm
14  use missing_data_mod, only: rmdi
16 
17 
18  implicit none
19 
20 #ifndef TEST_MODE
21  private
22 #endif
23 
25 
27 
28 contains
29 
30 
34  conditional_diagnostics_whole_get_descriptor%name="conditional_diagnostics_whole"
40 
41 
44  subroutine initialisation_callback(current_state)
45  type(model_state_type), target, intent(inout) :: current_state
46 
47  ! Save the sampling_frequency to force diagnostic calculation on select time steps
48  diagnostic_generation_frequency=options_get_integer(current_state%options_database, "sampling_frequency")
49 
50  end subroutine initialisation_callback
51 
52 
55  subroutine timestep_callback(current_state)
56  type(model_state_type), target, intent(inout) :: current_state
57  integer :: k,cnc,dnc,ierr
58  real(kind=default_precision) :: temp
59 
61  if (.not. mod(current_state%timestep, diagnostic_generation_frequency) == 0) return
62 
65  if (current_state%parallel%my_rank == 0) then
66  call mpi_reduce(mpi_in_place , conddiags_tot, ncond*2*ndiag*current_state%local_grid%size(z_index), &
67  precision_type, mpi_sum, 0, current_state%parallel%monc_communicator, ierr)
68  else
69  call mpi_reduce(conddiags_tot, conddiags_tot, ncond*2*ndiag*current_state%local_grid%size(z_index), &
70  precision_type, mpi_sum, 0, current_state%parallel%monc_communicator, ierr)
71  end if
72 
77  do dnc = 1, ndiag
78  if (dnc /= requested_area) then
79  do cnc = 1, ncond
80  do k = 2, current_state%local_grid%size(z_index) - 1
81  temp = conddiags_tot(k,cnc,requested_area)
82  if (temp .gt. 0) then
83  conddiags_tot(k,cnc,dnc) = conddiags_tot(k,cnc,dnc) / temp
84  else
85  conddiags_tot(k,cnc,dnc) = rmdi
86  end if
87  end do ! k
88  end do ! cnc over ncond*2
89  end if ! check requested_area
90  end do ! dnc over ndiag
91 
93  conddiags_tot(:,:,requested_area) = conddiags_tot(:,:,requested_area) / gpts_total
94 
96  conddiags_tot(1,:,:) = rmdi
97  conddiags_tot(current_state%local_grid%size(z_index),:,:) = rmdi
98 
101  conddiags_tot = conddiags_tot / current_state%parallel%processes
102 
104  call mpi_bcast(conddiags_tot, ncond*2*ndiag*current_state%local_grid%size(z_index), &
105  precision_type, 0, current_state%parallel%monc_communicator, ierr)
106 
107  end subroutine timestep_callback
108 
109 
112  subroutine finalisation_callback(current_state)
113  type(model_state_type), target, intent(inout) :: current_state
114 
115  end subroutine finalisation_callback
116 
conditional_diagnostics_whole_mod::diagnostic_generation_frequency
integer diagnostic_generation_frequency
Definition: conditional_diagnostics_whole.F90:24
conditional_diagnostics_column_mod::requested_area
integer, public requested_area
Definition: conditional_diagnostics_column.F90:56
optionsdatabase_mod::options_get_integer
integer function, public options_get_integer(options_database, key, index)
Retrieves an integer value from the database that matches the provided key.
Definition: optionsdatabase.F90:217
conditional_diagnostics_whole_mod
Conditionally averaged diagnostics, Part 2 of 2.
Definition: conditional_diagnostics_whole.F90:6
missing_data_mod::rmdi
real, parameter rmdi
Definition: missing_data_mod.F90:29
datadefn_mod::precision_type
integer, public precision_type
Definition: datadefn.F90:19
conditional_diagnostics_column_mod::ndiag
integer, public ndiag
Definition: conditional_diagnostics_column.F90:40
monc_component_mod
Interfaces and types that MONC components must specify.
Definition: monc_component.F90:6
grids_mod::z_index
integer, parameter, public z_index
Grid index parameters.
Definition: grids.F90:14
conditional_diagnostics_whole_mod::timestep_callback
subroutine timestep_callback(current_state)
The timestep hook will perform averaging of the conditional diagnostics.
Definition: conditional_diagnostics_whole.F90:56
conditional_diagnostics_column_mod::ncond
integer, public ncond
Definition: conditional_diagnostics_column.F90:39
state_mod::model_state_type
The ModelState which represents the current state of a run.
Definition: state.F90:39
conditional_diagnostics_whole_mod::conditional_diagnostics_whole_get_descriptor
type(component_descriptor_type) function, public conditional_diagnostics_whole_get_descriptor()
Provides registry information for the component.
Definition: conditional_diagnostics_whole.F90:34
conditional_diagnostics_whole_mod::finalisation_callback
subroutine finalisation_callback(current_state)
Called on termination: currently doesn't need to do anything.
Definition: conditional_diagnostics_whole.F90:113
conditional_diagnostics_column_mod::conddiags_tot
real(kind=default_precision), dimension(:,:,:), allocatable, public conddiags_tot
Definition: conditional_diagnostics_column.F90:27
datadefn_mod
Contains common definitions for the data and datatypes used by MONC.
Definition: datadefn.F90:2
conditional_diagnostics_column_mod
Conditionally averaged diagnostics, Part 1 of 2.
Definition: conditional_diagnostics_column.F90:4
missing_data_mod
Definition: missing_data_mod.F90:18
grids_mod
Functionality to support the different types of grid and abstraction between global grids and local o...
Definition: grids.F90:5
optionsdatabase_mod
Manages the options database. Contains administration functions and deduce runtime options from the c...
Definition: optionsdatabase.F90:7
conditional_diagnostics_column_mod::gpts_total
real(kind=default_precision), public gpts_total
Definition: conditional_diagnostics_column.F90:44
conditional_diagnostics_whole_mod::initialisation_callback
subroutine initialisation_callback(current_state)
Initialisation hook: currently doesn't need to do anything.
Definition: conditional_diagnostics_whole.F90:45
monc_component_mod::component_descriptor_type
Description of a component.
Definition: monc_component.F90:42
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
state_mod
The model state which represents the current state of a run.
Definition: state.F90:2