18 use netcdf,
only : nf90_noerr, nf90_global, nf90_nowrite, &
19 nf90_inquire_attribute, nf90_open, nf90_strerror, &
20 nf90_inq_dimid, nf90_inquire_dimension, nf90_inq_varid, &
21 nf90_get_var, nf90_inquire, nf90_close, nf90_get_att
29 character(len=*),
parameter :: &
30 time_key =
"time", & !< NetCDF data time key
182 type(model_state_type),
target,
intent(inout) :: current_state
183 character(len=*),
intent(in) :: name
184 type(component_field_information_type),
intent(out) :: field_information
187 field_information%field_type=component_array_field_type
188 field_information%data_type=component_double_data_type
189 field_information%number_dimensions=1
190 field_information%dimension_sizes(1)=current_state%local_grid%size(z_index)
192 if (name .eq.
"u_subsidence")
then
193 field_information%enabled=current_state%u%active .and.
l_subs_pl_theta .and. &
194 allocated(current_state%global_grid%configuration%vertical%olzubar)
195 else if (name .eq.
"v_subsidence")
then
196 field_information%enabled=current_state%v%active .and.
l_subs_pl_theta .and. &
197 allocated(current_state%global_grid%configuration%vertical%olzvbar)
198 else if (name .eq.
"th_subsidence")
then
199 field_information%enabled=current_state%th%active .and.
l_subs_pl_theta .and. &
200 allocated(current_state%global_grid%configuration%vertical%olzthbar)
201 else if (name .eq.
"vapour_mmr_subsidence" .or. name .eq.
"vapour_mmr_subsidence" .or. &
202 name .eq.
"cloud_mmr_subsidence" .or. name .eq.
"cloud_mmr_subsidence" )
then
203 field_information%enabled=.not. current_state%passive_q .and. &
204 current_state%number_q_fields .gt. 0 .and.
l_subs_pl_q .and. &
205 allocated(current_state%global_grid%configuration%vertical%olzqbar)
206 else if (name .eq.
"rain_mmr_subsidence" )
then
207 field_information%enabled=current_state%rain_water_mixing_ratio_index .gt. 0 .and. &
208 allocated(current_state%global_grid%configuration%vertical%olzqbar)
209 else if (name .eq.
"ice_mmr_subsidence" )
then
210 field_information%enabled= current_state%ice_water_mixing_ratio_index .gt. 0 .and. &
211 allocated(current_state%global_grid%configuration%vertical%olzqbar)
212 else if (name .eq.
"snow_mmr_subsidence" )
then
213 field_information%enabled= current_state%snow_water_mixing_ratio_index .gt. 0 .and. &
214 allocated(current_state%global_grid%configuration%vertical%olzqbar)
215 else if (name .eq.
"graupel_mmr_subsidence" )
then
216 field_information%enabled= current_state%graupel_water_mixing_ratio_index .gt. 0 .and. &
217 allocated(current_state%global_grid%configuration%vertical%olzqbar)
218 else if (name .eq.
"u_large_scale")
then
220 else if (name .eq.
"v_large_scale")
then
222 else if (name .eq.
"th_large_scale")
then
224 else if (name .eq.
"vapour_mmr_large_scale" .or. name .eq.
"vapour_mmr_large_scale" .or. &
225 name .eq.
"cloud_mmr_large_scale" .or. name .eq.
"cloud_mmr_large_scale" )
then
226 field_information%enabled=.not. current_state%passive_q .and. &
227 current_state%number_q_fields .gt. 0 .and.
l_subs_pl_q .and. &
228 allocated(current_state%global_grid%configuration%vertical%olzqbar)
229 else if (name .eq.
"rain_mmr_large_scale" )
then
230 field_information%enabled=current_state%rain_water_mixing_ratio_index .gt. 0 .and. &
231 allocated(current_state%global_grid%configuration%vertical%olzqbar)
232 else if (name .eq.
"ice_mmr_large_scale" )
then
233 field_information%enabled= current_state%ice_water_mixing_ratio_index .gt. 0 .and. &
234 allocated(current_state%global_grid%configuration%vertical%olzqbar)
235 else if (name .eq.
"snow_mmr_large_scale" )
then
236 field_information%enabled= current_state%snow_water_mixing_ratio_index .gt. 0 .and. &
237 allocated(current_state%global_grid%configuration%vertical%olzqbar)
238 else if (name .eq.
"graupel_mmr_large_scale" )
then
239 field_information%enabled= current_state%graupel_water_mixing_ratio_index .gt. 0 .and. &
240 allocated(current_state%global_grid%configuration%vertical%olzqbar)
244 strcomp=index(name,
"forcing_3d_local")
245 if (strcomp .ne. 0)
then
246 field_information%field_type=component_array_field_type
247 field_information%number_dimensions=3
248 field_information%dimension_sizes(1)=current_state%local_grid%size(z_index)
249 field_information%dimension_sizes(2)=current_state%local_grid%size(y_index)
250 field_information%dimension_sizes(3)=current_state%local_grid%size(x_index)
251 field_information%data_type=component_double_data_type
253 if (name .eq.
"tend_u_forcing_3d_local")
then
255 else if (name .eq.
"tend_v_forcing_3d_local")
then
257 else if (name .eq.
"tend_th_forcing_3d_local")
then
259 else if (name .eq.
"tend_qv_forcing_3d_local")
then
261 else if (name .eq.
"tend_ql_forcing_3d_local")
then
263 else if (name .eq.
"tend_qi_forcing_3d_local")
then
265 else if (name .eq.
"tend_qr_forcing_3d_local")
then
267 else if (name .eq.
"tend_qs_forcing_3d_local")
then
269 else if (name .eq.
"tend_qg_forcing_3d_local")
then
271 else if (name .eq.
"tend_tabs_forcing_3d_local")
then
274 field_information%enabled=.true.
280 strcomp=index(name,
"forcing_profile_total_local")
281 if (strcomp .ne. 0)
then
282 field_information%field_type=component_array_field_type
283 field_information%number_dimensions=1
284 field_information%dimension_sizes(1)=current_state%local_grid%size(z_index)
285 field_information%data_type=component_double_data_type
287 if (name .eq.
"tend_u_forcing_profile_total_local")
then
289 else if (name .eq.
"tend_v_forcing_profile_total_local")
then
291 else if (name .eq.
"tend_th_forcing_profile_total_local")
then
293 else if (name .eq.
"tend_qv_forcing_profile_total_local")
then
295 else if (name .eq.
"tend_ql_forcing_profile_total_local")
then
297 else if (name .eq.
"tend_qi_forcing_profile_total_local")
then
299 else if (name .eq.
"tend_qr_forcing_profile_total_local")
then
301 else if (name .eq.
"tend_qs_forcing_profile_total_local")
then
303 else if (name .eq.
"tend_qg_forcing_profile_total_local")
then
305 else if (name .eq.
"tend_tabs_forcing_profile_total_local")
then
308 field_information%enabled=.true.
320 type(model_state_type),
target,
intent(inout) :: current_state
321 character(len=*),
intent(in) :: name
322 type(component_field_value_type),
intent(out) :: field_value
324 integer :: k, n, column_size
326 column_size=current_state%local_grid%size(z_index)
329 if (name .eq.
"u_subsidence")
then
330 allocate(field_value%real_1d_array(column_size))
332 else if (name .eq.
"v_subsidence")
then
333 allocate(field_value%real_1d_array(column_size))
335 else if (name .eq.
"th_subsidence")
then
336 allocate(field_value%real_1d_array(column_size))
338 else if (name .eq.
"vapour_mmr_subsidence")
then
339 allocate(field_value%real_1d_array(column_size))
341 else if (name .eq.
"cloud_mmr_subsidence")
then
342 allocate(field_value%real_1d_array(column_size))
344 else if (name .eq.
"rain_mmr_subsidence")
then
345 allocate(field_value%real_1d_array(column_size))
347 else if (name .eq.
"ice_mmr_subsidence")
then
348 allocate(field_value%real_1d_array(column_size))
350 else if (name .eq.
"snow_mmr_subsidence")
then
351 allocate(field_value%real_1d_array(column_size))
353 else if (name .eq.
"graupel_mmr_subsidence")
then
354 allocate(field_value%real_1d_array(column_size))
357 else if (name .eq.
"u_large_scale")
then
358 allocate(field_value%real_1d_array(column_size))
360 else if (name .eq.
"v_large_scale")
then
361 allocate(field_value%real_1d_array(column_size))
363 else if (name .eq.
"th_large_scale")
then
364 allocate(field_value%real_1d_array(column_size))
366 else if (name .eq.
"vapour_mmr_large_scale")
then
367 allocate(field_value%real_1d_array(column_size))
369 else if (name .eq.
"cloud_mmr_large_scale")
then
370 allocate(field_value%real_1d_array(column_size))
372 else if (name .eq.
"rain_mmr_large_scale")
then
373 allocate(field_value%real_1d_array(column_size))
375 else if (name .eq.
"ice_mmr_large_scale")
then
376 allocate(field_value%real_1d_array(column_size))
378 else if (name .eq.
"snow_mmr_large_scale")
then
379 allocate(field_value%real_1d_array(column_size))
381 else if (name .eq.
"graupel_mmr_large_scale")
then
382 allocate(field_value%real_1d_array(column_size))
386 else if (name .eq.
"tend_u_forcing_3d_local" .and.
allocated(
tend_3d_u))
then
388 else if (name .eq.
"tend_v_forcing_3d_local" .and.
allocated(
tend_3d_v))
then
390 else if (name .eq.
"tend_th_forcing_3d_local" .and.
allocated(
tend_3d_th))
then
392 else if (name .eq.
"tend_qv_forcing_3d_local" .and.
allocated(
tend_3d_qv))
then
394 else if (name .eq.
"tend_ql_forcing_3d_local" .and.
allocated(
tend_3d_ql))
then
396 else if (name .eq.
"tend_qi_forcing_3d_local" .and.
allocated(
tend_3d_qi))
then
398 else if (name .eq.
"tend_qr_forcing_3d_local" .and.
allocated(
tend_3d_qr))
then
400 else if (name .eq.
"tend_qs_forcing_3d_local" .and.
allocated(
tend_3d_qs))
then
402 else if (name .eq.
"tend_qg_forcing_3d_local" .and.
allocated(
tend_3d_qg))
then
404 else if (name .eq.
"tend_tabs_forcing_3d_local" .and.
allocated(
tend_3d_tabs))
then
408 else if (name .eq.
"tend_u_forcing_profile_total_local" .and.
allocated(
tend_pr_tot_u))
then
410 else if (name .eq.
"tend_v_forcing_profile_total_local" .and.
allocated(
tend_pr_tot_v))
then
412 else if (name .eq.
"tend_th_forcing_profile_total_local" .and.
allocated(
tend_pr_tot_th))
then
414 else if (name .eq.
"tend_qv_forcing_profile_total_local" .and.
allocated(
tend_pr_tot_qv))
then
416 else if (name .eq.
"tend_ql_forcing_profile_total_local" .and.
allocated(
tend_pr_tot_ql))
then
418 else if (name .eq.
"tend_qi_forcing_profile_total_local" .and.
allocated(
tend_pr_tot_qi))
then
420 else if (name .eq.
"tend_qr_forcing_profile_total_local" .and.
allocated(
tend_pr_tot_qr))
then
422 else if (name .eq.
"tend_qs_forcing_profile_total_local" .and.
allocated(
tend_pr_tot_qs))
then
424 else if (name .eq.
"tend_qg_forcing_profile_total_local" .and.
allocated(
tend_pr_tot_qg))
then
426 else if (name .eq.
"tend_tabs_forcing_profile_total_local" .and.
allocated(
tend_pr_tot_tabs))
then
435 type(model_state_type),
target,
intent(inout) :: current_state
447 real(kind=default_precision),
dimension(:),
allocatable :: f_subs_pl
448 real(kind=default_precision),
dimension(:),
allocatable :: z_subs_pl
451 real(kind=default_precision),
dimension(:, :),
allocatable :: f_force_pl_q
452 real(kind=default_precision),
dimension(:),
allocatable :: z_force_pl_q
453 real(kind=default_precision),
dimension(:),
allocatable :: f_force_pl_theta
454 real(kind=default_precision),
dimension(:),
allocatable :: z_force_pl_theta
455 real(kind=default_precision),
dimension(:),
allocatable :: f_force_pl_u
456 real(kind=default_precision),
dimension(:),
allocatable :: z_force_pl_u
457 real(kind=default_precision),
dimension(:),
allocatable :: f_force_pl_v
458 real(kind=default_precision),
dimension(:),
allocatable :: z_force_pl_v
461 real(kind=default_precision),
dimension(:,:),
allocatable :: f_subs_2d
465 real(kind=default_precision),
allocatable :: f_force_pl_q_tmp(:)
466 real(kind=default_precision),
allocatable :: zgrid(:)
468 character(len=STRING_LENGTH),
dimension(:),
allocatable :: units_q_force
469 character(len=STRING_LENGTH) :: units_theta_force=
'unset'
470 character(len=STRING_LENGTH) :: units_u_force=
'unset'
471 character(len=STRING_LENGTH) :: units_v_force=
'unset'
473 logical :: convert_input_theta_from_temperature=.false.
479 allocate(
u_profile(current_state%local_grid%size(z_index)), &
480 v_profile(current_state%local_grid%size(z_index)), &
482 q_profile(current_state%local_grid%size(z_index)))
484 allocate(
dtheta_profile(current_state%local_grid%size(z_index)), &
485 dq_profile(current_state%local_grid%size(z_index)), &
486 du_profile(current_state%local_grid%size(z_index)), &
487 dv_profile(current_state%local_grid%size(z_index)))
492 dq_profile_diag(current_state%local_grid%size(z_index), current_state%number_q_fields))
499 allocate(zgrid(current_state%local_grid%size(z_index)))
502 if (.not. current_state%passive_q .and. current_state%number_q_fields .gt. 0)
then
503 iqv=get_q_index(standard_q_names%VAPOUR,
'forcing')
504 iql=get_q_index(standard_q_names%CLOUD_LIQUID_MASS,
'forcing')
506 if (current_state%rain_water_mixing_ratio_index > 0) &
507 iqr = current_state%rain_water_mixing_ratio_index
508 if (current_state%ice_water_mixing_ratio_index > 0) &
509 iqi = current_state%ice_water_mixing_ratio_index
510 if (current_state%snow_water_mixing_ratio_index > 0) &
511 iqs = current_state%snow_water_mixing_ratio_index
512 if (current_state%graupel_water_mixing_ratio_index > 0) &
513 iqg = current_state%graupel_water_mixing_ratio_index
518 options_get_logical(current_state%options_database,
"use_time_varying_subsidence")
519 l_subs_pl_theta=options_get_logical(current_state%options_database,
"l_subs_pl_theta")
520 l_subs_pl_q=options_get_logical(current_state%options_database,
"l_subs_pl_q")
521 subsidence_input_type=options_get_integer(current_state%options_database,
"subsidence_input_type")
522 l_subs_local_theta=options_get_logical(current_state%options_database,
"subsidence_local_theta")
523 l_subs_local_q=options_get_logical(current_state%options_database,
"subsidence_local_q")
525 input_file=options_get_string(current_state%options_database,
"forcing_file")
529 if (.not. is_component_enabled(current_state%options_database,
"mean_profiles"))
then
530 call log_master_log(log_error,
"subsidence requires the mean profiles component to be enabled")
538 allocate(z_subs_pl(options_get_array_size(current_state%options_database,
"z_subs_pl")), &
539 f_subs_pl(options_get_array_size(current_state%options_database,
"f_subs_pl")))
540 call options_get_real_array(current_state%options_database,
"z_subs_pl", z_subs_pl)
541 call options_get_real_array(current_state%options_database,
"f_subs_pl", f_subs_pl)
543 zgrid=current_state%global_grid%configuration%vertical%z(:)
544 call piecewise_linear_1d(z_subs_pl(1:
size(z_subs_pl)), f_subs_pl(1:
size(f_subs_pl)), zgrid, &
545 current_state%global_grid%configuration%vertical%w_subs)
547 current_state%global_grid%configuration%vertical%w_subs(:) = &
548 -1.0*current_state%global_grid%configuration%vertical%w_subs(:)*zgrid(:)
551 call log_master_log(log_error,
"timevarying forcing selected but no forcing file provided - STOP")
553 deallocate(z_subs_pl, f_subs_pl)
557 if (log_get_logging_level() .ge. log_debug)
then
558 call log_master_log(log_debug,
"Reading in subsidence velocity profile from:"//trim(
input_file) )
567 zgrid=current_state%global_grid%configuration%vertical%z(:)
569 allocate(current_state%global_grid%configuration%vertical%wsubs_time_vary(
size(zgrid), time_dim))
571 f_subs_2d(1:z_dim,1:time_dim), zgrid, &
572 current_state%global_grid%configuration%vertical%wsubs_time_vary)
574 call log_master_log(log_error,
"constant forcing from file selected but not coded - STOP")
581 if (.not.
allocated(current_state%l_forceq))
then
582 allocate(current_state%l_forceq(current_state%number_q_fields))
583 current_state%l_forceq=.false.
587 l_constant_forcing_q=options_get_logical(current_state%options_database,
"l_constant_forcing_q")
588 l_constant_forcing_u=options_get_logical(current_state%options_database,
"l_constant_forcing_u")
589 l_constant_forcing_v=options_get_logical(current_state%options_database,
"l_constant_forcing_v")
592 allocate(
names_force_pl_q(options_get_array_size(current_state%options_database,
"names_constant_forcing_q")))
593 call options_get_string_array(current_state%options_database,
"names_constant_forcing_q",
names_force_pl_q)
601 allocate(z_force_pl_theta(options_get_array_size(current_state%options_database,
"z_force_pl_theta")), &
602 f_force_pl_theta(options_get_array_size(current_state%options_database,
"f_force_pl_theta")))
603 call options_get_real_array(current_state%options_database,
"z_force_pl_theta", z_force_pl_theta)
604 call options_get_real_array(current_state%options_database,
"f_force_pl_theta", f_force_pl_theta)
608 current_state%global_grid%configuration%vertical%theta_force(:) = &
609 current_state%global_grid%configuration%vertical%theta_init(:)
612 zgrid=current_state%global_grid%configuration%vertical%zn(:)
614 zgrid=current_state%global_grid%configuration%vertical%prefn(:)
616 call piecewise_linear_1d(z_force_pl_theta(1:
size(z_force_pl_theta)), f_force_pl_theta(1:
size(f_force_pl_theta)), zgrid, &
617 current_state%global_grid%configuration%vertical%theta_force)
621 convert_input_theta_from_temperature=options_get_logical(current_state%options_database, &
622 "convert_input_theta_from_temperature")
623 if (convert_input_theta_from_temperature)
then
624 current_state%global_grid%configuration%vertical%theta_force(:) = &
625 current_state%global_grid%configuration%vertical%theta_force(:)* &
626 current_state%global_grid%configuration%vertical%prefrcp(:)
630 units_theta_force=options_get_string(current_state%options_database,
"units_theta_force")
631 select case(trim(units_theta_force))
633 current_state%global_grid%configuration%vertical%theta_force(:) = &
634 current_state%global_grid%configuration%vertical%theta_force(:)/seconds_in_a_day
638 deallocate(z_force_pl_theta, f_force_pl_theta)
644 forcing_timescale_u=options_get_real(current_state%options_database,
"forcing_timescale_u")
647 current_state%global_grid%configuration%vertical%u_force(:) = &
648 current_state%global_grid%configuration%vertical%u_init(:)
650 allocate(z_force_pl_u(options_get_array_size(current_state%options_database,
"z_force_pl_u")), &
651 f_force_pl_u(options_get_array_size(current_state%options_database,
"f_force_pl_u")))
652 call options_get_real_array(current_state%options_database,
"z_force_pl_u", z_force_pl_u)
653 call options_get_real_array(current_state%options_database,
"f_force_pl_u", f_force_pl_u)
655 zgrid=current_state%global_grid%configuration%vertical%zn(:)
656 call piecewise_linear_1d(z_force_pl_u(1:
size(z_force_pl_u)), f_force_pl_u(1:
size(f_force_pl_u)), zgrid, &
657 current_state%global_grid%configuration%vertical%u_force)
658 deallocate(z_force_pl_u, f_force_pl_u)
664 units_u_force=options_get_string(current_state%options_database,
"units_u_force")
665 select case(trim(units_u_force))
666 case(m_per_second_per_day)
667 current_state%global_grid%configuration%vertical%u_force(:) = &
668 current_state%global_grid%configuration%vertical%u_force(:)/seconds_in_a_day
678 forcing_timescale_v=options_get_real(current_state%options_database,
"forcing_timescale_v")
681 current_state%global_grid%configuration%vertical%v_force(:) = &
682 current_state%global_grid%configuration%vertical%v_init(:)
684 allocate(z_force_pl_v(options_get_array_size(current_state%options_database,
"z_force_pl_v")), &
685 f_force_pl_v(options_get_array_size(current_state%options_database,
"f_force_pl_v")))
686 call options_get_real_array(current_state%options_database,
"z_force_pl_v", z_force_pl_v)
687 call options_get_real_array(current_state%options_database,
"f_force_pl_v", f_force_pl_v)
689 zgrid=current_state%global_grid%configuration%vertical%zn(:)
690 call piecewise_linear_1d(z_force_pl_v(1:
size(z_force_pl_v)), f_force_pl_v(1:
size(f_force_pl_v)), zgrid, &
691 current_state%global_grid%configuration%vertical%v_force)
692 deallocate(z_force_pl_v, f_force_pl_v)
698 units_v_force=options_get_string(current_state%options_database,
"units_v_force")
699 select case(trim(units_v_force))
700 case(m_per_second_per_day)
701 current_state%global_grid%configuration%vertical%v_force(:) = &
702 current_state%global_grid%configuration%vertical%v_force(:)/seconds_in_a_day
711 forcing_timescale_q=options_get_real(current_state%options_database,
"forcing_timescale_q")
713 allocate(z_force_pl_q(options_get_array_size(current_state%options_database,
"z_force_pl_q")))
714 call options_get_real_array(current_state%options_database,
"z_force_pl_q", z_force_pl_q)
715 nzq=
size(z_force_pl_q)
716 zgrid=current_state%global_grid%configuration%vertical%zn(:)
717 allocate(f_force_pl_q_tmp(nq_force*nzq))
718 call options_get_real_array(current_state%options_database,
"f_force_pl_q", f_force_pl_q_tmp)
719 allocate(f_force_pl_q(nzq, nq_force))
720 f_force_pl_q(1:nzq, 1:nq_force)=reshape(f_force_pl_q_tmp, (/nzq, nq_force/))
722 allocate(units_q_force(options_get_array_size(current_state%options_database,
"units_q_force")))
723 call options_get_string_array(current_state%options_database,
"units_q_force", units_q_force)
726 call piecewise_linear_1d(z_force_pl_q(1:nzq), f_force_pl_q(1:nzq,n), zgrid, &
727 current_state%global_grid%configuration%vertical%q_force(:,iq))
729 current_state%l_forceq(iq)=.true.
733 select case(trim(units_q_force(n)))
734 case(kg_per_kg_per_day)
735 current_state%global_grid%configuration%vertical%q_force(:,iq) = &
736 current_state%global_grid%configuration%vertical%q_force(:,iq)/seconds_in_a_day
737 case(g_per_kg_per_day)
738 current_state%global_grid%configuration%vertical%q_force(:,iq) = &
739 0.001*current_state%global_grid%configuration%vertical%q_force(:,iq)/seconds_in_a_day
740 case(g_per_kg_per_second)
741 current_state%global_grid%configuration%vertical%q_force(:,iq) = &
742 0.001*current_state%global_grid%configuration%vertical%q_force(:,iq)
747 deallocate(f_force_pl_q_tmp, units_q_force, f_force_pl_q, z_force_pl_q)
755 l_qdiag = (.not. current_state%passive_q .and. current_state%number_q_fields .gt. 0)
781 allocate(
tend_3d_u(current_state%local_grid%size(z_index), &
782 current_state%local_grid%size(y_index), &
783 current_state%local_grid%size(x_index) ) )
786 allocate(
tend_3d_v(current_state%local_grid%size(z_index), &
787 current_state%local_grid%size(y_index), &
788 current_state%local_grid%size(x_index) ) )
791 allocate(
tend_3d_th(current_state%local_grid%size(z_index), &
792 current_state%local_grid%size(y_index), &
793 current_state%local_grid%size(x_index) ) )
796 allocate(
tend_3d_qv(current_state%local_grid%size(z_index), &
797 current_state%local_grid%size(y_index), &
798 current_state%local_grid%size(x_index) ) )
801 allocate(
tend_3d_ql(current_state%local_grid%size(z_index), &
802 current_state%local_grid%size(y_index), &
803 current_state%local_grid%size(x_index) ) )
806 allocate(
tend_3d_qi(current_state%local_grid%size(z_index), &
807 current_state%local_grid%size(y_index), &
808 current_state%local_grid%size(x_index) ) )
811 allocate(
tend_3d_qr(current_state%local_grid%size(z_index), &
812 current_state%local_grid%size(y_index), &
813 current_state%local_grid%size(x_index) ) )
816 allocate(
tend_3d_qs(current_state%local_grid%size(z_index), &
817 current_state%local_grid%size(y_index), &
818 current_state%local_grid%size(x_index) ) )
821 allocate(
tend_3d_qg(current_state%local_grid%size(z_index), &
822 current_state%local_grid%size(y_index), &
823 current_state%local_grid%size(x_index) ) )
826 allocate(
tend_3d_tabs(current_state%local_grid%size(z_index), &
827 current_state%local_grid%size(y_index), &
828 current_state%local_grid%size(x_index) ) )
833 allocate(
tend_pr_tot_u(current_state%local_grid%size(z_index)) )
836 allocate(
tend_pr_tot_v(current_state%local_grid%size(z_index)) )
839 allocate(
tend_pr_tot_th(current_state%local_grid%size(z_index)) )
842 allocate(
tend_pr_tot_qv(current_state%local_grid%size(z_index)) )
845 allocate(
tend_pr_tot_ql(current_state%local_grid%size(z_index)) )
848 allocate(
tend_pr_tot_qi(current_state%local_grid%size(z_index)) )
851 allocate(
tend_pr_tot_qr(current_state%local_grid%size(z_index)) )
854 allocate(
tend_pr_tot_qs(current_state%local_grid%size(z_index)) )
857 allocate(
tend_pr_tot_qg(current_state%local_grid%size(z_index)) )
873 type(model_state_type),
target,
intent(inout) :: current_state
874 integer :: current_x_index, current_y_index, target_x_index, target_y_index
876 current_x_index=current_state%column_local_x
877 current_y_index=current_state%column_local_y
878 target_y_index=current_y_index-current_state%local_grid%halo_size(y_index)
879 target_x_index=current_x_index-current_state%local_grid%halo_size(x_index)
881 if (current_state%first_timestep_column)
then
922 if (current_state%halo_column .or. current_state%timestep<3)
return
934 current_state%global_grid%configuration%vertical%wsubs_time_vary, &
935 current_state%time, current_state%global_grid%configuration%vertical%w_subs)
960 type(model_state_type),
intent(inout) :: current_state
963 real(kind=default_precision) :: usub, vsub
967 u_profile(:)=current_state%zu%data(:,current_state%column_local_y,current_state%column_local_x)
968 v_profile(:)=current_state%zv%data(:,current_state%column_local_y,current_state%column_local_x)
970 u_profile(:)=current_state%global_grid%configuration%vertical%olzubar(:)
971 v_profile(:)=current_state%global_grid%configuration%vertical%olzvbar(:)
974 do k=2,current_state%local_grid%size(z_index)-1
976 usub = 2.0 * (current_state%global_grid%configuration%vertical%w_subs(k-1)* &
977 current_state%global_grid%configuration%vertical%tzc1(k)*(
u_profile(k)-
u_profile(k-1)) &
978 + current_state%global_grid%configuration%vertical%w_subs(k)* &
979 current_state%global_grid%configuration%vertical%tzc2(k)* &
981 current_state%su%data(k,current_state%column_local_y,current_state%column_local_x) = &
982 current_state%su%data(k,current_state%column_local_y,current_state%column_local_x) - usub
986 vsub = 2.0 * (current_state%global_grid%configuration%vertical%w_subs(k-1)* &
987 current_state%global_grid%configuration%vertical%tzc1(k)*(
v_profile(k)-
v_profile(k-1)) &
988 + current_state%global_grid%configuration%vertical%w_subs(k)* &
989 current_state%global_grid%configuration%vertical%tzc2(k)* &
991 current_state%sv%data(k,current_state%column_local_y,current_state%column_local_x) = &
992 current_state%sv%data(k,current_state%column_local_y,current_state%column_local_x) - vsub
996 k=current_state%local_grid%size(z_index)
998 usub = 2.0 * (current_state%global_grid%configuration%vertical%w_subs(k-1)* &
999 current_state%global_grid%configuration%vertical%tzc1(k)*(
u_profile(k)-
u_profile(k-1)))
1000 current_state%su%data(k,current_state%column_local_y,current_state%column_local_x) = &
1001 current_state%su%data(k,current_state%column_local_y,current_state%column_local_x) - usub
1005 vsub = 2.0 * (current_state%global_grid%configuration%vertical%w_subs(k-1)* &
1006 current_state%global_grid%configuration%vertical%tzc1(k)*(
v_profile(k)-
v_profile(k-1)))
1007 current_state%sv%data(k,current_state%column_local_y,current_state%column_local_x) = &
1008 current_state%sv%data(k,current_state%column_local_y,current_state%column_local_x) - vsub
1014 type(model_state_type),
intent(inout) :: current_state
1017 real(kind=default_precision) :: thsub
1020 theta_profile(:)=current_state%zth%data(:,current_state%column_local_y,current_state%column_local_x) &
1021 + current_state%global_grid%configuration%vertical%thref(:)
1023 theta_profile(:)=current_state%global_grid%configuration%vertical%olzthbar(:) &
1024 + current_state%global_grid%configuration%vertical%thref(:)
1027 do k=2,current_state%local_grid%size(z_index)-1
1028 thsub = current_state%global_grid%configuration%vertical%w_subs(k)* &
1030 current_state%global_grid%configuration%vertical%rdzn(k+1)
1032 current_state%sth%data(k,current_state%column_local_y,current_state%column_local_x) = &
1033 current_state%sth%data(k,current_state%column_local_y,current_state%column_local_x) - thsub
1036 k=current_state%local_grid%size(z_index)
1037 thsub = current_state%global_grid%configuration%vertical%w_subs(k)* &
1039 current_state%global_grid%configuration%vertical%rdzn(k)
1041 current_state%sth%data(k,current_state%column_local_y,current_state%column_local_x) = &
1042 current_state%sth%data(k,current_state%column_local_y,current_state%column_local_x) - thsub
1047 type(model_state_type),
intent(inout) :: current_state
1050 real(kind=default_precision) :: qsub
1053 do n=1,current_state%number_q_fields
1055 q_profile(:)=current_state%zq(n)%data(:,current_state%column_local_y,current_state%column_local_x)
1057 q_profile(:)=current_state%global_grid%configuration%vertical%olzqbar(:,n)
1059 do k=2,current_state%local_grid%size(z_index)-1
1060 qsub = current_state%global_grid%configuration%vertical%w_subs(k)* &
1062 current_state%global_grid%configuration%vertical%rdzn(k+1)
1063 current_state%sq(n)%data(k,current_state%column_local_y,current_state%column_local_x) = &
1064 current_state%sq(n)%data(k,current_state%column_local_y,current_state%column_local_x) - qsub
1067 k=current_state%local_grid%size(z_index)
1068 qsub = current_state%global_grid%configuration%vertical%w_subs(k)* &
1070 current_state%global_grid%configuration%vertical%rdzn(k)
1071 current_state%sq(n)%data(k,current_state%column_local_y,current_state%column_local_x) = &
1072 current_state%sq(n)%data(k,current_state%column_local_y,current_state%column_local_x) - qsub
1078 type(model_state_type),
intent(inout) :: current_state
1081 real(kind=default_precision) :: dtm_scale
1084 dtm_scale=1.0_default_precision
1090 dtheta_profile(:)=dtm_scale * (current_state%global_grid%configuration%vertical%theta_force(:) - &
1091 current_state%zth%data(:,current_state%column_local_y,current_state%column_local_x) - &
1092 current_state%global_grid%configuration%vertical%thref(:))
1094 dtheta_profile(:)=dtm_scale * current_state%global_grid%configuration%vertical%theta_force(:)
1100 do k=2,current_state%local_grid%size(z_index)-1
1101 current_state%sth%data(k,current_state%column_local_y,current_state%column_local_x) = &
1102 current_state%sth%data(k,current_state%column_local_y,current_state%column_local_x) &
1109 type(model_state_type),
intent(inout) :: current_state
1112 real(kind=default_precision) :: dtm_scale
1114 do n=1,current_state%number_q_fields
1115 if (current_state%l_forceq(n))
then
1117 dtm_scale=1.0_default_precision
1123 dq_profile(:)=dtm_scale * (current_state%global_grid%configuration%vertical%q_force(:,n) - &
1124 current_state%zq(n)%data(:,current_state%column_local_y,current_state%column_local_x))
1126 dq_profile(:)=dtm_scale * current_state%global_grid%configuration%vertical%q_force(:,n)
1131 do k=2,current_state%local_grid%size(z_index)-1
1132 current_state%sq(n)%data(k,current_state%column_local_y,current_state%column_local_x) = &
1133 current_state%sq(n)%data(k,current_state%column_local_y,current_state%column_local_x) &
1142 type(model_state_type),
intent(inout) :: current_state
1145 real(kind=default_precision) :: dtm_scale
1148 dtm_scale=1.0_default_precision
1154 du_profile(:)=dtm_scale * (current_state%global_grid%configuration%vertical%u_force(:) - &
1155 current_state%global_grid%configuration%vertical%olzubar(:))
1157 du_profile(:)=dtm_scale * current_state%global_grid%configuration%vertical%u_force(:)
1162 do k=2,current_state%local_grid%size(z_index)-1
1163 current_state%su%data(k,current_state%column_local_y,current_state%column_local_x) = &
1164 current_state%su%data(k,current_state%column_local_y,current_state%column_local_x) &
1171 type(model_state_type),
intent(inout) :: current_state
1174 real(kind=default_precision) :: dtm_scale
1177 dtm_scale=1.0_default_precision
1183 dv_profile(:)=dtm_scale * (current_state%global_grid%configuration%vertical%v_force(:) - &
1184 current_state%global_grid%configuration%vertical%olzvbar(:) )
1186 dv_profile(:)=dtm_scale * current_state%global_grid%configuration%vertical%v_force(:)
1191 do k=2,current_state%local_grid%size(z_index)-1
1192 current_state%sv%data(k,current_state%column_local_y,current_state%column_local_x) = &
1193 current_state%sv%data(k,current_state%column_local_y,current_state%column_local_x) &
1201 type(model_state_type),
target,
intent(inout) :: current_state
1238 type(model_state_type),
target,
intent(inout) :: current_state
1239 real(kind=default_precision),
dimension(:),
intent(in) :: diagnostics_summed
1242 integer :: horizontal_points
1244 horizontal_points=current_state%local_grid%size(x_index) * current_state%local_grid%size(y_index)
1256 type(model_state_type),
target,
intent(in) :: current_state
1257 integer,
intent(in) :: cxn, cyn, txn, tyn
1261 tend_3d_u(:,tyn,txn)=current_state%su%data(:,cyn,cxn)
1264 tend_3d_v(:,tyn,txn)=current_state%sv%data(:,cyn,cxn)
1267 tend_3d_th(:,tyn,txn)=current_state%sth%data(:,cyn,cxn)
1288 tend_3d_tabs(:,tyn,txn)=current_state%sth%data(:,cyn,cxn) * current_state%global_grid%configuration%vertical%rprefrcp(:)
1300 type(model_state_type),
target,
intent(inout) :: current_state
1301 integer,
intent(in) :: cxn, cyn, txn, tyn
1333 current_state%sth%data(:,cyn,cxn) * current_state%global_grid%configuration%vertical%rprefrcp(:) &
1377 type(component_field_value_type),
intent(inout) :: field_value
1378 real(kind=default_precision),
dimension(:),
optional :: real_1d_field
1379 real(kind=default_precision),
dimension(:,:),
optional :: real_2d_field
1380 real(kind=default_precision),
dimension(:,:,:),
optional :: real_3d_field
1382 if (
present(real_1d_field))
then
1383 allocate(field_value%real_1d_array(
size(real_1d_field)), source=real_1d_field)
1384 else if (
present(real_2d_field))
then
1385 allocate(field_value%real_2d_array(
size(real_2d_field, 1),
size(real_2d_field, 2)), source=real_2d_field)
1386 else if (
present(real_3d_field))
then
1387 allocate(field_value%real_3d_array(
size(real_3d_field, 1),
size(real_3d_field, 2),
size(real_3d_field, 3)), &
1388 source=real_3d_field)
1395 integer,
intent(in) :: status
1397 if (status /= nf90_noerr)
then
1398 call log_log(log_error,
"NetCDF returned error code of "//trim(nf90_strerror(status)))
1407 integer,
intent(in) :: ncid
1408 integer,
intent(out) :: time_dim
1409 integer,
intent(out) :: z_dim
1410 integer :: time_dimid, z_dimid
1428 force_2d_key, force_2d_var )
1430 character(*),
intent(in) :: filename
1431 character(len=*),
intent(in) :: force_2d_key
1432 integer,
intent(in) :: ncid, time_dim, z_dim
1433 real(kind=default_precision),
intent(inout) :: time(:), z_profile(:)
1434 real(kind=default_precision),
dimension(:,:),
allocatable,
intent(inout) :: force_2d_var
1436 integer :: status, variable_id
1442 status=nf90_inq_varid(ncid,
time_key, variable_id)
1443 if (status==nf90_noerr)
then
1446 call log_log(log_error,
"No recognized time variable found in"//trim(filename))
1449 status=nf90_inq_varid(ncid,
z_key, variable_id)
1450 if (status==nf90_noerr)
then
1453 call log_log(log_error,
"No recognized height variable found in"//trim(filename))
1456 status=nf90_inq_varid(ncid, force_2d_key, variable_id)
1457 if (status==nf90_noerr)
then
1460 call log_log(log_error,
"No recognized forcing variable found in"//trim(filename))
1471 integer,
intent(in) :: ncid
1472 character(len=*),
intent(in) :: key
1473 real(kind=default_precision),
dimension(:),
intent(inout),
optional :: data1d
1474 real(kind=default_precision),
dimension(:,:),
intent(inout),
optional :: data2d
1476 integer :: variable_id
1477 real(kind=default_precision),
dimension(:,:),
allocatable :: sdata
1481 if (.not.
present(data1d) .and. .not.
present(data2d))
return
1483 if (
present(data1d))
then
1487 allocate(sdata(
size(data2d,1),
size(data2d,2)))
1489 data2d(:,:)=reshape(sdata(:,:),(/
size(data2d,1),
size(data2d,2)/))