Initialises the forcing data structures.
227 type(model_state_type),
target,
intent(inout) :: current_state
235 real(kind=DEFAULT_PRECISION),
dimension(:),
allocatable :: f_subs_pl
236 real(kind=DEFAULT_PRECISION),
dimension(:),
allocatable :: z_subs_pl
239 real(kind=DEFAULT_PRECISION),
dimension(:, :),
allocatable :: f_force_pl_q
240 real(kind=DEFAULT_PRECISION),
dimension(:),
allocatable :: z_force_pl_q
241 real(kind=DEFAULT_PRECISION),
dimension(:),
allocatable :: f_force_pl_theta
242 real(kind=DEFAULT_PRECISION),
dimension(:),
allocatable :: z_force_pl_theta
243 real(kind=DEFAULT_PRECISION),
dimension(:),
allocatable :: f_force_pl_u
244 real(kind=DEFAULT_PRECISION),
dimension(:),
allocatable :: z_force_pl_u
245 real(kind=DEFAULT_PRECISION),
dimension(:),
allocatable :: f_force_pl_v
246 real(kind=DEFAULT_PRECISION),
dimension(:),
allocatable :: z_force_pl_v
248 integer :: subsidence_input_type=divergence
250 real(kind=DEFAULT_PRECISION),
allocatable :: f_force_pl_q_tmp(:)
251 real(kind=DEFAULT_PRECISION),
allocatable :: zgrid(:)
253 character(len=STRING_LENGTH),
dimension(:),
allocatable :: units_q_force
254 character(len=STRING_LENGTH) :: units_theta_force=
'unset' 255 character(len=STRING_LENGTH) :: units_u_force=
'unset' 256 character(len=STRING_LENGTH) :: units_v_force=
'unset' 258 logical :: convert_input_theta_from_temperature=.false.
263 allocate(theta_profile(current_state%local_grid%size(z_index)), &
264 q_profile(current_state%local_grid%size(z_index)), &
265 u_profile(current_state%local_grid%size(z_index)), &
266 v_profile(current_state%local_grid%size(z_index)))
268 allocate(dtheta_profile(current_state%local_grid%size(z_index)), &
269 dq_profile(current_state%local_grid%size(z_index)), &
270 du_profile(current_state%local_grid%size(z_index)), &
271 dv_profile(current_state%local_grid%size(z_index)))
273 allocate(du_profile_diag(current_state%local_grid%size(z_index)), dv_profile_diag(current_state%local_grid%size(z_index)), &
274 dtheta_profile_diag(current_state%local_grid%size(z_index)), &
275 dq_profile_diag(current_state%local_grid%size(z_index), current_state%number_q_fields))
277 allocate(zgrid(current_state%local_grid%size(z_index)))
281 l_subs_pl_theta=options_get_logical(current_state%options_database,
"l_subs_pl_theta")
282 l_subs_pl_q=options_get_logical(current_state%options_database,
"l_subs_pl_q")
283 subsidence_input_type=options_get_integer(current_state%options_database,
"subsidence_input_type")
284 l_subs_local_theta=options_get_logical(current_state%options_database,
"subsidence_local_theta")
285 l_subs_local_q=options_get_logical(current_state%options_database,
"subsidence_local_q")
288 if ((l_subs_pl_theta .and. .not. l_subs_local_theta) .or. &
289 (l_subs_pl_q .and. .not. l_subs_local_q))
then 290 if (.not. is_component_enabled(current_state%options_database,
"mean_profiles"))
then 291 call log_master_log(log_error,
"Damping requires the mean profiles component to be enabled")
295 if (l_subs_pl_theta .or. l_subs_pl_q)
then 296 allocate(z_subs_pl(options_get_array_size(current_state%options_database,
"z_subs_pl")), &
297 f_subs_pl(options_get_array_size(current_state%options_database,
"f_subs_pl")))
298 call options_get_real_array(current_state%options_database,
"z_subs_pl", z_subs_pl)
299 call options_get_real_array(current_state%options_database,
"f_subs_pl", f_subs_pl)
301 zgrid=current_state%global_grid%configuration%vertical%z(:)
302 call piecewise_linear_1d(z_subs_pl(1:
size(z_subs_pl)), f_subs_pl(1:
size(f_subs_pl)), zgrid, &
303 current_state%global_grid%configuration%vertical%w_subs)
304 if (subsidence_input_type==divergence)
then 305 current_state%global_grid%configuration%vertical%w_subs(:) = &
306 -1.0*current_state%global_grid%configuration%vertical%w_subs(:)*zgrid(:)
308 deallocate(z_subs_pl, f_subs_pl)
314 if (.not.
allocated(current_state%l_forceq))
then 315 allocate(current_state%l_forceq(current_state%number_q_fields))
316 current_state%l_forceq=.false.
319 l_constant_forcing_theta=options_get_logical(current_state%options_database,
"l_constant_forcing_theta")
320 l_constant_forcing_q=options_get_logical(current_state%options_database,
"l_constant_forcing_q")
321 l_constant_forcing_u=options_get_logical(current_state%options_database,
"l_constant_forcing_u")
322 l_constant_forcing_v=options_get_logical(current_state%options_database,
"l_constant_forcing_v")
324 if (l_constant_forcing_q)
then 325 allocate(names_force_pl_q(options_get_array_size(current_state%options_database,
"names_constant_forcing_q")))
326 call options_get_string_array(current_state%options_database,
"names_constant_forcing_q", names_force_pl_q)
329 if (l_constant_forcing_theta)
then 330 constant_forcing_type_theta=options_get_integer(current_state%options_database,
"constant_forcing_type_theta")
331 forcing_timescale_theta=options_get_real(current_state%options_database,
"forcing_timescale_theta")
332 l_constant_forcing_theta_z2pressure=options_get_logical(current_state%options_database,
"l_constant_forcing_theta_z2pressure")
334 allocate(z_force_pl_theta(options_get_array_size(current_state%options_database,
"z_force_pl_theta")), &
335 f_force_pl_theta(options_get_array_size(current_state%options_database,
"f_force_pl_theta")))
336 call options_get_real_array(current_state%options_database,
"z_force_pl_theta", z_force_pl_theta)
337 call options_get_real_array(current_state%options_database,
"f_force_pl_theta", f_force_pl_theta)
339 relax_to_initial_theta_profile=options_get_logical(current_state%options_database,
"relax_to_initial_theta_profile")
340 if (relax_to_initial_theta_profile)
then 341 current_state%global_grid%configuration%vertical%theta_force(:) = &
342 current_state%global_grid%configuration%vertical%theta_init(:)
344 if (l_constant_forcing_theta_z2pressure)
then 345 zgrid=current_state%global_grid%configuration%vertical%zn(:)
347 zgrid=current_state%global_grid%configuration%vertical%prefn(:)
349 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, &
350 current_state%global_grid%configuration%vertical%theta_force)
354 if (convert_input_theta_from_temperature)
then 355 current_state%global_grid%configuration%vertical%theta_force(:) = &
356 current_state%global_grid%configuration%vertical%theta_force(:)* &
357 current_state%global_grid%configuration%vertical%prefrcp(:)
360 if (constant_forcing_type_theta==tendency)
then 361 units_theta_force=options_get_string(current_state%options_database,
"units_theta_force")
362 select case(trim(units_theta_force))
364 current_state%global_grid%configuration%vertical%theta_force(:) = &
365 current_state%global_grid%configuration%vertical%theta_force(:)/seconds_in_a_day
369 deallocate(z_force_pl_theta, f_force_pl_theta)
373 if (l_constant_forcing_u)
then 374 constant_forcing_type_u=options_get_integer(current_state%options_database,
"constant_forcing_type_u")
375 forcing_timescale_u=options_get_real(current_state%options_database,
"forcing_timescale_u")
376 relax_to_initial_u_profile=options_get_logical(current_state%options_database,
"relax_to_initial_u_profile")
377 if (relax_to_initial_u_profile)
then 378 current_state%global_grid%configuration%vertical%u_force(:) = &
379 current_state%global_grid%configuration%vertical%u_init(:)
381 allocate(z_force_pl_u(options_get_array_size(current_state%options_database,
"z_force_pl_u")), &
382 f_force_pl_u(options_get_array_size(current_state%options_database,
"f_force_pl_u")))
383 call options_get_real_array(current_state%options_database,
"z_force_pl_u", z_force_pl_u)
384 call options_get_real_array(current_state%options_database,
"f_force_pl_u", f_force_pl_u)
386 zgrid=current_state%global_grid%configuration%vertical%zn(:)
387 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, &
388 current_state%global_grid%configuration%vertical%u_force)
389 deallocate(z_force_pl_u, f_force_pl_u)
393 if (constant_forcing_type_u==tendency)
then 395 units_u_force=options_get_string(current_state%options_database,
"units_u_force")
396 select case(trim(units_u_force))
397 case(m_per_second_per_day)
398 current_state%global_grid%configuration%vertical%u_force(:) = &
399 current_state%global_grid%configuration%vertical%u_force(:)/seconds_in_a_day
407 if (l_constant_forcing_v)
then 408 constant_forcing_type_v=options_get_integer(current_state%options_database,
"constant_forcing_type_v")
409 forcing_timescale_v=options_get_real(current_state%options_database,
"forcing_timescale_v")
410 relax_to_initial_v_profile=options_get_logical(current_state%options_database,
"relax_to_initial_v_profile")
411 if (relax_to_initial_v_profile)
then 412 current_state%global_grid%configuration%vertical%v_force(:) = &
413 current_state%global_grid%configuration%vertical%v_init(:)
415 allocate(z_force_pl_v(options_get_array_size(current_state%options_database,
"z_force_pl_v")), &
416 f_force_pl_v(options_get_array_size(current_state%options_database,
"f_force_pl_v")))
417 call options_get_real_array(current_state%options_database,
"z_force_pl_v", z_force_pl_v)
418 call options_get_real_array(current_state%options_database,
"f_force_pl_v", f_force_pl_v)
420 zgrid=current_state%global_grid%configuration%vertical%zn(:)
421 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, &
422 current_state%global_grid%configuration%vertical%v_force)
423 deallocate(z_force_pl_v, f_force_pl_v)
427 if (constant_forcing_type_v==tendency)
then 429 units_v_force=options_get_string(current_state%options_database,
"units_v_force")
430 select case(trim(units_v_force))
431 case(m_per_second_per_day)
432 current_state%global_grid%configuration%vertical%v_force(:) = &
433 current_state%global_grid%configuration%vertical%v_force(:)/seconds_in_a_day
440 if (l_constant_forcing_q)
then 441 constant_forcing_type_q=options_get_integer(current_state%options_database,
"constant_forcing_type_q")
442 forcing_timescale_q=options_get_real(current_state%options_database,
"forcing_timescale_q")
443 nq_force=
size(names_force_pl_q)
444 allocate(z_force_pl_q(options_get_array_size(current_state%options_database,
"z_force_pl_q")))
445 call options_get_real_array(current_state%options_database,
"z_force_pl_q", z_force_pl_q)
446 nzq=
size(z_force_pl_q)
447 zgrid=current_state%global_grid%configuration%vertical%zn(:)
448 allocate(f_force_pl_q_tmp(nq_force*nzq))
449 call options_get_real_array(current_state%options_database,
"f_force_pl_q", f_force_pl_q_tmp)
450 allocate(f_force_pl_q(nzq, nq_force))
451 f_force_pl_q(1:nzq, 1:nq_force)=reshape(f_force_pl_q_tmp, (/nzq, nq_force/))
453 allocate(units_q_force(options_get_array_size(current_state%options_database,
"units_q_force")))
454 call options_get_string_array(current_state%options_database,
"units_q_force", units_q_force)
456 iq=get_q_index(trim(names_force_pl_q(n)),
'forcing:time-independent')
457 call piecewise_linear_1d(z_force_pl_q(1:nzq), f_force_pl_q(1:nzq,n), zgrid, &
458 current_state%global_grid%configuration%vertical%q_force(:,iq))
460 current_state%l_forceq(iq)=.true.
463 if (constant_forcing_type_u==tendency)
then 464 select case(trim(units_q_force(n)))
465 case(kg_per_kg_per_day)
466 current_state%global_grid%configuration%vertical%q_force(:,iq) = &
467 current_state%global_grid%configuration%vertical%q_force(:,iq)/seconds_in_a_day
468 case(g_per_kg_per_day)
469 current_state%global_grid%configuration%vertical%q_force(:,iq) = &
470 0.001*current_state%global_grid%configuration%vertical%q_force(:,iq)/seconds_in_a_day
471 case(g_per_kg_per_second)
472 current_state%global_grid%configuration%vertical%q_force(:,iq) = &
473 0.001*current_state%global_grid%configuration%vertical%q_force(:,iq)
478 deallocate(f_force_pl_q_tmp, units_q_force, f_force_pl_q, z_force_pl_q)