20 real(kind=DEFAULT_PRECISION),
dimension(:),
allocatable ::
th_diffusion 21 real(kind=DEFAULT_PRECISION),
dimension(:,:),
allocatable ::
q_diffusion 48 type(model_state_type),
target,
intent(inout) :: current_state
49 character(len=*),
intent(in) :: name
50 type(component_field_information_type),
intent(out) :: field_information
53 field_information%field_type=component_array_field_type
54 field_information%data_type=component_double_data_type
55 if (name .eq.
"q_diffusion")
then 56 field_information%number_dimensions=2
58 field_information%number_dimensions=1
60 field_information%dimension_sizes(1)=current_state%local_grid%size(z_index)
61 if (name .eq.
"q_diffusion") field_information%dimension_sizes(2)=current_state%number_q_fields
62 field_information%enabled=.true.
70 type(model_state_type),
target,
intent(inout) :: current_state
71 character(len=*),
intent(in) :: name
72 type(component_field_value_type),
intent(out) :: field_value
74 if (name .eq.
"th_diffusion")
then 76 else if (name .eq.
"q_diffusion")
then 84 type(model_state_type),
target,
intent(inout) :: current_state
86 integer :: z_size, y_size, x_size
88 z_size=current_state%local_grid%size(z_index) + current_state%local_grid%halo_size(z_index) * 2
89 y_size=current_state%local_grid%size(y_index) + current_state%local_grid%halo_size(y_index) * 2
90 x_size=current_state%local_grid%size(x_index) + current_state%local_grid%halo_size(x_index) * 2
91 allocate(current_state%diff_coefficient%data(z_size, y_size, x_size))
93 z_size=current_state%global_grid%size(z_index)
95 allocate(
q_diffusion(z_size, current_state%number_q_fields))
100 type(model_state_type),
target,
intent(inout) :: current_state
109 type(model_state_type),
target,
intent(inout) :: current_state
111 integer :: local_y, local_x
113 if (.not. current_state%use_viscosity_and_diffusion .or. current_state%halo_column)
return 114 if (current_state%diffusion_halo_swap_state%swap_in_progress)
then 116 call complete_nonblocking_halo_swap(current_state, current_state%diffusion_halo_swap_state, &
120 local_y=current_state%column_local_y
121 local_x=current_state%column_local_x
124 if (current_state%number_q_fields .gt. 0)
call perform_q_diffusion(current_state, local_y, local_x)
132 type(model_state_type),
target,
intent(inout) :: current_state
133 integer,
intent(in) :: local_y, local_x
137 do n=1, current_state%number_q_fields
147 type(model_state_type),
target,
intent(inout) :: current_state
148 integer,
intent(in) :: local_y, local_x
151 real(kind=DEFAULT_PRECISION) :: adjustment
155 if (current_state%use_anelastic_equations)
then 157 do k=2, current_state%local_grid%size(z_index)
158 adjustment=(current_state%global_grid%configuration%vertical%cza(k)*&
159 current_state%global_grid%configuration%vertical%dthref(k)*&
160 current_state%diff_coefficient%data(k, local_y, local_x) - current_state%global_grid%configuration%vertical%czb(k)*&
161 current_state%global_grid%configuration%vertical%dthref(k-1)*&
162 current_state%diff_coefficient%data(k-1, local_y, local_x))
163 current_state%sth%data(k, local_y, local_x)=current_state%sth%data(k, local_y, local_x)+adjustment
175 subroutine general_diffusion(current_state, field, source_field, local_y, local_x, diagnostics)
176 type(model_state_type),
target,
intent(inout) :: current_state
177 type(prognostic_field_type),
intent(inout) :: field, source_field
178 integer,
intent(in) :: local_y, local_x
179 real(kind=DEFAULT_PRECISION),
dimension(:),
intent(inout),
optional :: diagnostics
181 real(kind=DEFAULT_PRECISION) :: term
184 do k=2, current_state%local_grid%size(z_index)
185 term=current_state%global_grid%configuration%horizontal%cx2*0.25_default_precision*&
186 (((current_state%diff_coefficient%data(k, local_y, local_x)+&
187 current_state%diff_coefficient%data(k, local_y, local_x-1))+&
188 (current_state%diff_coefficient%data(k-1, local_y, local_x)+&
189 current_state%diff_coefficient%data(k-1, local_y, local_x-1)))&
190 *(field%data(k, local_y, local_x-1)-field%data(k, local_y, local_x)) -&
191 ((current_state%diff_coefficient%data(k, local_y, local_x+1)+&
192 current_state%diff_coefficient%data(k, local_y, local_x))+&
193 (current_state%diff_coefficient%data(k-1, local_y, local_x+1)+&
194 current_state%diff_coefficient%data(k-1, local_y, local_x)))&
195 *(field%data(k, local_y, local_x)-field%data(k, local_y, local_x+1)) )&
196 +current_state%global_grid%configuration%horizontal%cy2*0.25_default_precision*(&
197 ((current_state%diff_coefficient%data(k, local_y, local_x)+&
198 current_state%diff_coefficient%data(k, local_y-1, local_x))+&
199 (current_state%diff_coefficient%data(k-1, local_y, local_x)+&
200 current_state%diff_coefficient%data(k-1, local_y-1, local_x)))&
201 *(field%data(k, local_y-1, local_x)-field%data(k, local_y, local_x)) -&
202 ((current_state%diff_coefficient%data(k, local_y+1, local_x)+&
203 current_state%diff_coefficient%data(k, local_y, local_x))+&
204 (current_state%diff_coefficient%data(k-1, local_y+1, local_x)+&
205 current_state%diff_coefficient%data(k-1, local_y, local_x)))&
206 *(field%data(k, local_y, local_x)-field%data(k, local_y+1, local_x)) )&
207 +( current_state%global_grid%configuration%vertical%czb(k)*&
208 current_state%diff_coefficient%data(k-1, local_y, local_x)*&
209 (field%data(k-1, local_y, local_x)-field%data(k, local_y, local_x)))
211 if (k .lt. current_state%local_grid%size(z_index))
then 212 term=term - current_state%global_grid%configuration%vertical%cza(k)*&
213 current_state%diff_coefficient%data(k, local_y, local_x)*&
214 (field%data(k, local_y, local_x)-field%data(k+1, local_y, local_x))
216 source_field%data(k, local_y, local_x)=source_field%data(k, local_y, local_x)+term
217 if (
present(diagnostics)) diagnostics(k)=term
225 type(model_state_type),
intent(inout) :: current_state
226 integer,
intent(in) :: halo_depth
227 logical,
intent(in) :: involve_corners
228 type(field_data_wrapper_type),
dimension(:),
intent(in),
optional :: source_data
230 call perform_local_data_copy_for_field(current_state%diff_coefficient%data, current_state%local_grid, &
231 current_state%parallel%my_rank, halo_depth, involve_corners)
243 neighbour_location, current_page, source_data)
244 type(model_state_type),
intent(inout) :: current_state
245 integer,
intent(in) :: dim, target_index, neighbour_location
246 integer,
intent(inout) :: current_page(:)
247 type(neighbour_description_type),
intent(inout) :: neighbour_description
248 type(field_data_wrapper_type),
dimension(:),
intent(in),
optional :: source_data
250 call copy_buffer_to_field(current_state%local_grid, neighbour_description%recv_halo_buffer, &
251 current_state%diff_coefficient%data, dim, target_index, current_page(neighbour_location))
253 current_page(neighbour_location)=current_page(neighbour_location)+1
266 y_target_index, neighbour_location, current_page, source_data)
267 type(model_state_type),
intent(inout) :: current_state
268 integer,
intent(in) :: corner_loc, x_target_index, y_target_index, neighbour_location
269 integer,
intent(inout) :: current_page(:)
270 type(neighbour_description_type),
intent(inout) :: neighbour_description
271 type(field_data_wrapper_type),
dimension(:),
intent(in),
optional :: source_data
273 call copy_buffer_to_corner(current_state%local_grid, neighbour_description%recv_corner_buffer, &
274 current_state%diff_coefficient%data, corner_loc, x_target_index, y_target_index, current_page(neighbour_location))
276 current_page(neighbour_location)=current_page(neighbour_location)+1
subroutine copy_halo_buffer_to_diff(current_state, neighbour_description, dim, target_index, neighbour_location, current_page, source_data)
Copies the halo buffer to halo location for the diffusion coefficient field.
real(kind=default_precision), dimension(:,:), allocatable q_diffusion
Wrapper type for the value returned for a published field from a component.
integer, parameter, public forward_stepping
subroutine, public perform_local_data_copy_for_field(field_data, local_grid, my_rank, halo_depth, involve_corners)
Will perform a a local copy for the halo data of a field.
subroutine timestep_callback(current_state)
At each timestep will compute the diffusion source terms for TH and Q fields per column if these fiel...
subroutine perform_th_diffusion(current_state, local_y, local_x)
Computes the diffusion source terms for the theta field.
integer, parameter, public log_error
Only log ERROR messages.
Contains the types used for communication, holding the state of communications and supporting activit...
subroutine copy_halo_buffer_to_diff_corners(current_state, neighbour_description, corner_loc, x_target_index, y_target_index, neighbour_location, current_page, source_data)
Copies the corner halo buffer to the diffusion coefficient field corners.
Contains prognostic field definitions and functions.
A prognostic field which is assumed to be 3D.
integer, parameter, public default_precision
MPI communication type which we use for the prognostic and calculation data.
integer, parameter, public z_index
Grid index parameters.
subroutine, public complete_nonblocking_halo_swap(current_state, halo_swap_state, perform_local_data_copy, copy_from_halo_buffer, copy_from_halo_buffer_to_corner, source_data)
This completes a nonblocking halo swap and it is only during this call that the data fields themselve...
Contains common definitions for the data and datatypes used by MONC.
The ModelState which represents the current state of a run.
subroutine perform_local_data_copy_for_diff(current_state, halo_depth, involve_corners, source_data)
Does local data copying for diffusion coefficient variable halo swap.
logical function, public is_component_enabled(options_database, component_name)
Determines whether or not a specific component is registered and enabled.
subroutine, public log_master_log(level, message)
Will log just from the master process.
subroutine general_diffusion(current_state, field, source_field, local_y, local_x, diagnostics)
General diffusion computation for any field which is provided as arguments. Works in a column...
subroutine, public copy_buffer_to_corner(local_grid, halo_buffer, field_data, corner_loc, x_target_index, y_target_index, halo_page)
Copies the received buffer for a specific field to the corresponding corner of that field...
subroutine initialisation_callback(current_state)
Sets up the stencil_mod (used in interpolation) and allocates data for the flux fields.
subroutine perform_q_diffusion(current_state, local_y, local_x)
Computes the diffusion source terms for each Q field.
Description of a component.
subroutine, public copy_buffer_to_field(local_grid, halo_buffer, field_data, dim, target_index, halo_page)
Copies the received buffer for a specific field to the corresponding halo data of that prognostic fie...
subroutine field_value_retrieval_callback(current_state, name, field_value)
Field value retrieval callback, this returns the value of a specific published field.
integer, parameter, public component_array_field_type
Maintains the state of a halo swap and contains buffers, neighbours etc.
Diffusion on the TH and Q fields.
Interfaces and types that MONC components must specify.
subroutine finalisation_callback(current_state)
Provides the mechanism for halo swapping. This module contains the functionality required to determin...
integer, parameter, public log_warn
Log WARNING and ERROR messages.
Describes the neighbours of a process in a specific dimension and contains the communication buffers ...
subroutine field_information_retrieval_callback(current_state, name, field_information)
Field information retrieval callback, this returns information for a specific components published fi...
real(kind=default_precision), dimension(:), allocatable th_diffusion
Functionality to support the different types of grid and abstraction between global grids and local o...
type(component_descriptor_type) function, public diffusion_get_descriptor()
Provides the descriptor back to the caller and is used in component registration. ...
The model state which represents the current state of a run.
integer, parameter, public y_index
integer, parameter, public x_index
integer, parameter, public component_double_data_type