MONC
diagnostics_3d.F90
Go to the documentation of this file.
1 
3  !!
4  !! module to derive 3-D fields which are not already stored
5  !! in current_state and output as a 3-D diagnostic
6  !!
10  use grids_mod, only : z_index, y_index, x_index
12  use state_mod, only : model_state_type
15  use saturation_mod, only: qsaturation
17 
18  implicit none
19 
20 #ifndef TEST_MODE
21  private
22 #endif
23 
24  integer :: total_points, iqv, iql, iqr
25  real(kind=default_precision), dimension(:,:,:), allocatable :: &
26  tdegk, & ! absolute temperature in kelvin
27  theta, & ! potential temperature in kelvin (th + thref)
28  liquid_ice_theta ! liquid-ice potential temperature in kelvin
29  real(kind=default_precision), dimension(:), allocatable :: &
31  real(kind=default_precision) :: qlcrit
32 
34 
35 contains
36 
40  diagnostics_3d_get_descriptor%name="diagnostics_3d"
44 
47  allocate(diagnostics_3d_get_descriptor%published_fields(3))
48 
49  diagnostics_3d_get_descriptor%published_fields(1)="temperature"
50  diagnostics_3d_get_descriptor%published_fields(2)="theta"
51  diagnostics_3d_get_descriptor%published_fields(3)="thetali"
52 
54 
55  subroutine initialisation_callback(current_state)
56  type(model_state_type), target, intent(inout) :: current_state
57 
58  if (current_state%th%active) then
59  allocate(tdegk(current_state%local_grid%size(z_index), &
60  current_state%local_grid%size(y_index), &
61  current_state%local_grid%size(x_index)))
62  allocate(theta(current_state%local_grid%size(z_index), &
63  current_state%local_grid%size(y_index), &
64  current_state%local_grid%size(x_index)))
65  allocate(liquid_ice_theta(current_state%local_grid%size(z_index), &
66  current_state%local_grid%size(y_index), &
67  current_state%local_grid%size(x_index)))
68  endif
69 
70  if (.not. current_state%passive_q .and. current_state%number_q_fields .gt. 0) then
71  allocate(total_condensate(current_state%local_grid%size(z_index)))
72  iqv=get_q_index(standard_q_names%VAPOUR, 'diagnostics_3d')
73  iql=get_q_index(standard_q_names%CLOUD_LIQUID_MASS, 'diagnostics_3d')
74  if (current_state%rain_water_mixing_ratio_index > 0) &
75  iqr = current_state%rain_water_mixing_ratio_index
76  endif
77 
78  end subroutine initialisation_callback
79 
80  subroutine timestep_callback(current_state)
81  type(model_state_type), target, intent(inout) :: current_state
82 
83  real(kind=default_precision) :: exner, pmb, qv, qs
84 
85  integer :: k
86  integer :: current_y_index, current_x_index, target_x_index, target_y_index
87 
88  if (current_state%halo_column) return
89 
90  current_y_index=current_state%column_local_y
91  current_x_index=current_state%column_local_x
92  target_y_index=current_y_index-current_state%local_grid%halo_size(y_index)
93  target_x_index=current_x_index-current_state%local_grid%halo_size(x_index)
94 
95  if (current_state%th%active) then
96  theta(:,target_y_index, target_x_index) = &
97  (current_state%th%data(:,current_y_index,current_x_index) &
98  + current_state%global_grid%configuration%vertical%thref(:))
99  liquid_ice_theta(:,target_y_index, target_x_index) = &
100  (current_state%th%data(:,current_y_index,current_x_index) &
101  + current_state%global_grid%configuration%vertical%thref(:))
102  ! test for the qfields
103  if (.not. current_state%passive_q .and. &
104  current_state%number_q_fields .gt. 0) then
105  total_condensate(:) = &
106  current_state%q(iql)%data(:,current_y_index,current_x_index) + &
107  current_state%q(iqr)%data(:,current_y_index,current_x_index)
108  liquid_ice_theta(:,target_y_index, target_x_index) = &
109  liquid_ice_theta(:,target_y_index, target_x_index) - &
110  ( total_condensate(:) * (rlvap_over_cp) )
111  endif
112  tdegk(:,target_y_index, target_x_index) = &
113  (current_state%th%data(:,current_y_index,current_x_index) &
114  + current_state%global_grid%configuration%vertical%thref(:) &
115  * current_state%global_grid%configuration%vertical%rprefrcp(:))
116  endif
117 
118  end subroutine timestep_callback
119 
124  subroutine field_information_retrieval_callback(current_state, name, field_information)
125  type(model_state_type), target, intent(inout) :: current_state
126  character(len=*), intent(in) :: name
127  type(component_field_information_type), intent(out) :: field_information
128 
129  field_information%field_type=component_array_field_type
130  field_information%number_dimensions=3
131  field_information%dimension_sizes(1)=current_state%local_grid%size(z_index)
132  field_information%dimension_sizes(2)=current_state%local_grid%size(y_index)
133  field_information%dimension_sizes(3)=current_state%local_grid%size(x_index)
134  field_information%data_type=component_double_data_type
135  if (name .eq. "temperature" .or. name .eq. "theta" &
136  .or. name .eq. "thetali") then
137  field_information%enabled=current_state%th%active
138  else
139  field_information%enabled=.true.
140  endif
142 
147  subroutine field_value_retrieval_callback(current_state, name, field_value)
148  type(model_state_type), target, intent(inout) :: current_state
149  character(len=*), intent(in) :: name
150  type(component_field_value_type), intent(out) :: field_value
151 
152  integer :: k
153 
154  if (name .eq. "temperature") then
155  allocate(field_value%real_3d_array(current_state%local_grid%size(z_index), &
156  current_state%local_grid%size(y_index), &
157  current_state%local_grid%size(x_index)))
158  field_value%real_3d_array(:,:,:) = tdegk(:,:,:)
159  elseif (name .eq. "theta") then
160  allocate(field_value%real_3d_array(current_state%local_grid%size(z_index), &
161  current_state%local_grid%size(y_index), &
162  current_state%local_grid%size(x_index)))
163  field_value%real_3d_array(:,:,:) = theta(:,:,:)
164  elseif (name .eq. "thetali") then
165  allocate(field_value%real_3d_array(current_state%local_grid%size(z_index), &
166  current_state%local_grid%size(y_index), &
167  current_state%local_grid%size(x_index)))
168  field_value%real_3d_array(:,:,:) = liquid_ice_theta(:,:,:)
169  end if
170 
171  end subroutine field_value_retrieval_callback
172 end module diagnostics_3d_mod
diagnostics_3d_mod::iqv
integer iqv
Definition: diagnostics_3d.F90:24
saturation_mod
Saturation physics functionality which is used throughout the code.
Definition: saturation.F90:2
diagnostics_3d_mod::tdegk
real(kind=default_precision), dimension(:,:,:), allocatable tdegk
Definition: diagnostics_3d.F90:25
grids_mod::x_index
integer, parameter, public x_index
Definition: grids.F90:14
saturation_mod::qsaturation
real(kind=default_precision) function, public qsaturation(temperature, pressure)
Function to return the saturation mixing ratio over water based on tetans formular QS=3....
Definition: saturation.F90:22
grids_mod::y_index
integer, parameter, public y_index
Definition: grids.F90:14
diagnostics_3d_mod::qlcrit
real(kind=default_precision) qlcrit
Definition: diagnostics_3d.F90:31
diagnostics_3d_mod
Derive 3-D diagnostic fields which are available in current_state.
Definition: diagnostics_3d.F90:2
monc_component_mod
Interfaces and types that MONC components must specify.
Definition: monc_component.F90:6
diagnostics_3d_mod::field_value_retrieval_callback
subroutine field_value_retrieval_callback(current_state, name, field_value)
Field value retrieval callback, this returns the value of a specific published field.
Definition: diagnostics_3d.F90:148
diagnostics_3d_mod::iqr
integer iqr
Definition: diagnostics_3d.F90:24
science_constants_mod
Scientific constant values used throughout simulations. Each has a default value and this can be over...
Definition: scienceconstants.F90:3
diagnostics_3d_mod::initialisation_callback
subroutine initialisation_callback(current_state)
Definition: diagnostics_3d.F90:56
grids_mod::z_index
integer, parameter, public z_index
Grid index parameters.
Definition: grids.F90:14
diagnostics_3d_mod::diagnostics_3d_get_descriptor
type(component_descriptor_type) function, public diagnostics_3d_get_descriptor()
Provides the component descriptor for the core to register.
Definition: diagnostics_3d.F90:40
diagnostics_3d_mod::total_condensate
real(kind=default_precision), dimension(:), allocatable total_condensate
Definition: diagnostics_3d.F90:29
q_indices_mod::standard_q_names
type(standard_q_names_type), public standard_q_names
Definition: q_indices.F90:59
monc_component_mod::component_field_value_type
Wrapper type for the value returned for a published field from a component.
Definition: monc_component.F90:22
state_mod::model_state_type
The ModelState which represents the current state of a run.
Definition: state.F90:39
diagnostics_3d_mod::theta
real(kind=default_precision), dimension(:,:,:), allocatable theta
Definition: diagnostics_3d.F90:25
monc_component_mod::component_field_information_type
Definition: monc_component.F90:31
monc_component_mod::component_scalar_field_type
integer, parameter, public component_scalar_field_type
Definition: monc_component.F90:15
q_indices_mod::get_q_index
integer function, public get_q_index(name, assigning_component)
Add in a new entry into the register if the name does not already exist or return the index of the pr...
Definition: q_indices.F90:112
datadefn_mod
Contains common definitions for the data and datatypes used by MONC.
Definition: datadefn.F90:2
diagnostics_3d_mod::iql
integer iql
Definition: diagnostics_3d.F90:24
q_indices_mod
This manages the Q variables and specifically the mapping between names and the index that they are s...
Definition: q_indices.F90:2
diagnostics_3d_mod::timestep_callback
subroutine timestep_callback(current_state)
Definition: diagnostics_3d.F90:81
diagnostics_3d_mod::field_information_retrieval_callback
subroutine field_information_retrieval_callback(current_state, name, field_information)
Field information retrieval callback, this returns information for a specific components published fi...
Definition: diagnostics_3d.F90:125
diagnostics_3d_mod::liquid_ice_theta
real(kind=default_precision), dimension(:,:,:), allocatable liquid_ice_theta
Definition: diagnostics_3d.F90:25
monc_component_mod::component_integer_data_type
integer, parameter, public component_integer_data_type
Definition: monc_component.F90:16
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
diagnostics_3d_mod::total_points
integer total_points
Definition: diagnostics_3d.F90:24
monc_component_mod::component_descriptor_type
Description of a component.
Definition: monc_component.F90:42
monc_component_mod::component_double_data_type
integer, parameter, public component_double_data_type
Definition: monc_component.F90:16
optionsdatabase_mod::options_get_real
real(kind=default_precision) function, public options_get_real(options_database, key, index)
Retrieves a real value from the database that matches the provided key.
Definition: optionsdatabase.F90:91
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
monc_component_mod::component_array_field_type
integer, parameter, public component_array_field_type
Definition: monc_component.F90:15
science_constants_mod::rlvap_over_cp
real(kind=default_precision), public rlvap_over_cp
Definition: scienceconstants.F90:13