88 type(model_state_type),
target,
intent(inout) :: current_state
89 character(len=*),
intent(in) :: name
90 type(component_field_information_type),
intent(out) :: field_information
94 field_information%field_type=component_array_field_type
95 field_information%data_type=component_double_data_type
96 if (name .eq.
"q_diffusion")
then
97 field_information%number_dimensions=2
99 field_information%number_dimensions=1
101 field_information%dimension_sizes(1)=current_state%local_grid%size(z_index)
102 if (name .eq.
"q_diffusion") field_information%dimension_sizes(2)=current_state%number_q_fields
103 field_information%enabled=.true.
106 strcomp=index(name,
"diffusion_3d_local")
107 if (strcomp .ne. 0)
then
108 field_information%field_type=component_array_field_type
109 field_information%number_dimensions=3
110 field_information%dimension_sizes(1)=current_state%local_grid%size(z_index)
111 field_information%dimension_sizes(2)=current_state%local_grid%size(y_index)
112 field_information%dimension_sizes(3)=current_state%local_grid%size(x_index)
113 field_information%data_type=component_double_data_type
115 if (name .eq.
"tend_th_diffusion_3d_local")
then
117 else if (name .eq.
"tend_qv_diffusion_3d_local")
then
119 else if (name .eq.
"tend_ql_diffusion_3d_local")
then
121 else if (name .eq.
"tend_qi_diffusion_3d_local")
then
123 else if (name .eq.
"tend_qr_diffusion_3d_local")
then
125 else if (name .eq.
"tend_qs_diffusion_3d_local")
then
127 else if (name .eq.
"tend_qg_diffusion_3d_local")
then
129 else if (name .eq.
"tend_tabs_diffusion_3d_local")
then
132 field_information%enabled=.true.
138 strcomp=index(name,
"diffusion_profile_total_local")
139 if (strcomp .ne. 0)
then
140 field_information%field_type=component_array_field_type
141 field_information%number_dimensions=1
142 field_information%dimension_sizes(1)=current_state%local_grid%size(z_index)
143 field_information%data_type=component_double_data_type
145 if (name .eq.
"tend_th_diffusion_profile_total_local")
then
147 else if (name .eq.
"tend_qv_diffusion_profile_total_local")
then
149 else if (name .eq.
"tend_ql_diffusion_profile_total_local")
then
151 else if (name .eq.
"tend_qi_diffusion_profile_total_local")
then
153 else if (name .eq.
"tend_qr_diffusion_profile_total_local")
then
155 else if (name .eq.
"tend_qs_diffusion_profile_total_local")
then
157 else if (name .eq.
"tend_qg_diffusion_profile_total_local")
then
159 else if (name .eq.
"tend_tabs_diffusion_profile_total_local")
then
162 field_information%enabled=.true.
174 type(model_state_type),
target,
intent(inout) :: current_state
175 character(len=*),
intent(in) :: name
176 type(component_field_value_type),
intent(out) :: field_value
178 if (name .eq.
"th_diffusion")
then
180 else if (name .eq.
"q_diffusion")
then
184 else if (name .eq.
"tend_th_diffusion_3d_local" .and.
allocated(
tend_3d_th))
then
186 else if (name .eq.
"tend_qv_diffusion_3d_local" .and.
allocated(
tend_3d_qv))
then
188 else if (name .eq.
"tend_ql_diffusion_3d_local" .and.
allocated(
tend_3d_ql))
then
190 else if (name .eq.
"tend_qi_diffusion_3d_local" .and.
allocated(
tend_3d_qi))
then
192 else if (name .eq.
"tend_qr_diffusion_3d_local" .and.
allocated(
tend_3d_qr))
then
194 else if (name .eq.
"tend_qs_diffusion_3d_local" .and.
allocated(
tend_3d_qs))
then
196 else if (name .eq.
"tend_qg_diffusion_3d_local" .and.
allocated(
tend_3d_qg))
then
198 else if (name .eq.
"tend_tabs_diffusion_3d_local" .and.
allocated(
tend_3d_tabs))
then
202 else if (name .eq.
"tend_th_diffusion_profile_total_local" .and.
allocated(
tend_pr_tot_th))
then
204 else if (name .eq.
"tend_qv_diffusion_profile_total_local" .and.
allocated(
tend_pr_tot_qv))
then
206 else if (name .eq.
"tend_ql_diffusion_profile_total_local" .and.
allocated(
tend_pr_tot_ql))
then
208 else if (name .eq.
"tend_qi_diffusion_profile_total_local" .and.
allocated(
tend_pr_tot_qi))
then
210 else if (name .eq.
"tend_qr_diffusion_profile_total_local" .and.
allocated(
tend_pr_tot_qr))
then
212 else if (name .eq.
"tend_qs_diffusion_profile_total_local" .and.
allocated(
tend_pr_tot_qs))
then
214 else if (name .eq.
"tend_qg_diffusion_profile_total_local" .and.
allocated(
tend_pr_tot_qg))
then
216 else if (name .eq.
"tend_tabs_diffusion_profile_total_local" .and.
allocated(
tend_pr_tot_tabs))
then
225 type(model_state_type),
target,
intent(inout) :: current_state
227 integer :: z_size, y_size, x_size
230 z_size=current_state%local_grid%size(z_index) + current_state%local_grid%halo_size(z_index) * 2
231 y_size=current_state%local_grid%size(y_index) + current_state%local_grid%halo_size(y_index) * 2
232 x_size=current_state%local_grid%size(x_index) + current_state%local_grid%halo_size(x_index) * 2
233 allocate(current_state%diff_coefficient%data(z_size, y_size, x_size))
235 z_size=current_state%global_grid%size(z_index)
237 allocate(
q_diffusion(z_size, current_state%number_q_fields))
242 l_qdiag = (.not. current_state%passive_q .and. current_state%number_q_fields .gt. 0)
264 allocate(
tend_3d_th(current_state%local_grid%size(z_index), &
265 current_state%local_grid%size(y_index), &
266 current_state%local_grid%size(x_index) ) )
269 iqv=get_q_index(standard_q_names%VAPOUR,
'diffusion')
270 allocate(
tend_3d_qv(current_state%local_grid%size(z_index), &
271 current_state%local_grid%size(y_index), &
272 current_state%local_grid%size(x_index) ) )
275 iql=get_q_index(standard_q_names%CLOUD_LIQUID_MASS,
'diffusion')
276 allocate(
tend_3d_ql(current_state%local_grid%size(z_index), &
277 current_state%local_grid%size(y_index), &
278 current_state%local_grid%size(x_index) ) )
281 iqi=get_q_index(standard_q_names%ICE_MASS,
'diffusion')
282 allocate(
tend_3d_qi(current_state%local_grid%size(z_index), &
283 current_state%local_grid%size(y_index), &
284 current_state%local_grid%size(x_index) ) )
287 iqr=get_q_index(standard_q_names%RAIN_MASS,
'diffusion')
288 allocate(
tend_3d_qr(current_state%local_grid%size(z_index), &
289 current_state%local_grid%size(y_index), &
290 current_state%local_grid%size(x_index) ) )
293 iqs=get_q_index(standard_q_names%SNOW_MASS,
'diffusion')
294 allocate(
tend_3d_qs(current_state%local_grid%size(z_index), &
295 current_state%local_grid%size(y_index), &
296 current_state%local_grid%size(x_index) ) )
299 iqg=get_q_index(standard_q_names%GRAUPEL_MASS,
'diffusion')
300 allocate(
tend_3d_qg(current_state%local_grid%size(z_index), &
301 current_state%local_grid%size(y_index), &
302 current_state%local_grid%size(x_index) ) )
305 allocate(
tend_3d_tabs(current_state%local_grid%size(z_index), &
306 current_state%local_grid%size(y_index), &
307 current_state%local_grid%size(x_index) ) )
312 allocate(
tend_pr_tot_th(current_state%local_grid%size(z_index)) )
315 allocate(
tend_pr_tot_qv(current_state%local_grid%size(z_index)) )
318 allocate(
tend_pr_tot_ql(current_state%local_grid%size(z_index)) )
321 allocate(
tend_pr_tot_qi(current_state%local_grid%size(z_index)) )
324 allocate(
tend_pr_tot_qr(current_state%local_grid%size(z_index)) )
327 allocate(
tend_pr_tot_qs(current_state%local_grid%size(z_index)) )
330 allocate(
tend_pr_tot_qg(current_state%local_grid%size(z_index)) )
343 type(model_state_type),
target,
intent(inout) :: current_state
371 type(model_state_type),
target,
intent(inout) :: current_state
373 integer :: local_y, local_x, target_x_index, target_y_index
375 local_y=current_state%column_local_y
376 local_x=current_state%column_local_x
377 target_y_index=local_y-current_state%local_grid%halo_size(y_index)
378 target_x_index=local_x-current_state%local_grid%halo_size(x_index)
381 if (current_state%first_timestep_column)
then
408 if (.not. current_state%use_viscosity_and_diffusion .or. current_state%halo_column)
return
410 if (current_state%diffusion_halo_swap_state%swap_in_progress)
then
412 call complete_nonblocking_halo_swap(current_state, current_state%diffusion_halo_swap_state, &
421 if (current_state%number_q_fields .gt. 0)
call perform_q_diffusion(current_state, local_y, local_x)
434 type(model_state_type),
target,
intent(inout) :: current_state
435 integer,
intent(in) :: local_y, local_x
439 do n=1, current_state%number_q_fields
449 type(model_state_type),
target,
intent(inout) :: current_state
450 integer,
intent(in) :: local_y, local_x
453 real(kind=default_precision) :: adjustment
457 if (current_state%use_anelastic_equations)
then
459 do k=2, current_state%local_grid%size(z_index)
460 adjustment=(current_state%global_grid%configuration%vertical%cza(k)*&
461 current_state%global_grid%configuration%vertical%dthref(k)*&
462 current_state%diff_coefficient%data(k, local_y, local_x) - current_state%global_grid%configuration%vertical%czb(k)*&
463 current_state%global_grid%configuration%vertical%dthref(k-1)*&
464 current_state%diff_coefficient%data(k-1, local_y, local_x))
465 current_state%sth%data(k, local_y, local_x)=current_state%sth%data(k, local_y, local_x)+adjustment
478 type(model_state_type),
target,
intent(inout) :: current_state
479 type(prognostic_field_type),
intent(inout) :: field, source_field
480 integer,
intent(in) :: local_y, local_x
481 real(kind=default_precision),
dimension(:),
intent(inout),
optional :: diagnostics
483 real(kind=default_precision) :: term
486 do k=2, current_state%local_grid%size(z_index)
487 term=current_state%global_grid%configuration%horizontal%cx2*0.25_default_precision*&
488 (((current_state%diff_coefficient%data(k, local_y, local_x)+&
489 current_state%diff_coefficient%data(k, local_y, local_x-1))+&
490 (current_state%diff_coefficient%data(k-1, local_y, local_x)+&
491 current_state%diff_coefficient%data(k-1, local_y, local_x-1)))&
492 *(field%data(k, local_y, local_x-1)-field%data(k, local_y, local_x)) -&
493 ((current_state%diff_coefficient%data(k, local_y, local_x+1)+&
494 current_state%diff_coefficient%data(k, local_y, local_x))+&
495 (current_state%diff_coefficient%data(k-1, local_y, local_x+1)+&
496 current_state%diff_coefficient%data(k-1, local_y, local_x)))&
497 *(field%data(k, local_y, local_x)-field%data(k, local_y, local_x+1)) )&
498 +current_state%global_grid%configuration%horizontal%cy2*0.25_default_precision*(&
499 ((current_state%diff_coefficient%data(k, local_y, local_x)+&
500 current_state%diff_coefficient%data(k, local_y-1, local_x))+&
501 (current_state%diff_coefficient%data(k-1, local_y, local_x)+&
502 current_state%diff_coefficient%data(k-1, local_y-1, local_x)))&
503 *(field%data(k, local_y-1, local_x)-field%data(k, local_y, local_x)) -&
504 ((current_state%diff_coefficient%data(k, local_y+1, local_x)+&
505 current_state%diff_coefficient%data(k, local_y, local_x))+&
506 (current_state%diff_coefficient%data(k-1, local_y+1, local_x)+&
507 current_state%diff_coefficient%data(k-1, local_y, local_x)))&
508 *(field%data(k, local_y, local_x)-field%data(k, local_y+1, local_x)) )&
509 +( current_state%global_grid%configuration%vertical%czb(k)*&
510 current_state%diff_coefficient%data(k-1, local_y, local_x)*&
511 (field%data(k-1, local_y, local_x)-field%data(k, local_y, local_x)))
513 if (k .lt. current_state%local_grid%size(z_index))
then
514 term=term - current_state%global_grid%configuration%vertical%cza(k)*&
515 current_state%diff_coefficient%data(k, local_y, local_x)*&
516 (field%data(k, local_y, local_x)-field%data(k+1, local_y, local_x))
518 source_field%data(k, local_y, local_x)=source_field%data(k, local_y, local_x)+term
519 if (
present(diagnostics)) diagnostics(k)=term
527 type(model_state_type),
intent(inout) :: current_state
528 integer,
intent(in) :: halo_depth
529 logical,
intent(in) :: involve_corners
530 type(field_data_wrapper_type),
dimension(:),
intent(in),
optional :: source_data
532 call perform_local_data_copy_for_field(current_state%diff_coefficient%data, current_state%local_grid, &
533 current_state%parallel%my_rank, halo_depth, involve_corners)
545 neighbour_location, current_page, source_data)
546 type(model_state_type),
intent(inout) :: current_state
547 integer,
intent(in) :: dim, target_index, neighbour_location
548 integer,
intent(inout) :: current_page(:)
549 type(neighbour_description_type),
intent(inout) :: neighbour_description
550 type(field_data_wrapper_type),
dimension(:),
intent(in),
optional :: source_data
552 call copy_buffer_to_field(current_state%local_grid, neighbour_description%recv_halo_buffer, &
553 current_state%diff_coefficient%data, dim, target_index, current_page(neighbour_location))
555 current_page(neighbour_location)=current_page(neighbour_location)+1
568 y_target_index, neighbour_location, current_page, source_data)
569 type(model_state_type),
intent(inout) :: current_state
570 integer,
intent(in) :: corner_loc, x_target_index, y_target_index, neighbour_location
571 integer,
intent(inout) :: current_page(:)
572 type(neighbour_description_type),
intent(inout) :: neighbour_description
573 type(field_data_wrapper_type),
dimension(:),
intent(in),
optional :: source_data
575 call copy_buffer_to_corner(current_state%local_grid, neighbour_description%recv_corner_buffer, &
576 current_state%diff_coefficient%data, corner_loc, x_target_index, y_target_index, current_page(neighbour_location))
578 current_page(neighbour_location)=current_page(neighbour_location)+1
588 type(model_state_type),
target,
intent(in) :: current_state
589 integer,
intent(in) :: cxn, cyn, txn, tyn
593 tend_3d_th(:,tyn,txn)=current_state%sth%data(:,cyn,cxn)
614 tend_3d_tabs(:,tyn,txn)=current_state%sth%data(:,cyn,cxn) * current_state%global_grid%configuration%vertical%rprefrcp(:)
627 type(model_state_type),
target,
intent(inout) :: current_state
628 integer,
intent(in) :: cxn, cyn, txn, tyn
654 current_state%sth%data(:,cyn,cxn) * current_state%global_grid%configuration%vertical%rprefrcp(:) &
692 type(component_field_value_type),
intent(inout) :: field_value
693 real(kind=default_precision),
dimension(:),
optional :: real_1d_field
694 real(kind=default_precision),
dimension(:,:),
optional :: real_2d_field
695 real(kind=default_precision),
dimension(:,:,:),
optional :: real_3d_field
697 if (
present(real_1d_field))
then
698 allocate(field_value%real_1d_array(
size(real_1d_field)), source=real_1d_field)
699 else if (
present(real_2d_field))
then
700 allocate(field_value%real_2d_array(
size(real_2d_field, 1),
size(real_2d_field, 2)), source=real_2d_field)
701 else if (
present(real_3d_field))
then
702 allocate(field_value%real_3d_array(
size(real_3d_field, 1),
size(real_3d_field, 2),
size(real_3d_field, 3)), &
703 source=real_3d_field)