17 implicit none ;
private
28 logical :: initialized = .false.
30 real :: test_kh_scaling
32 logical :: use_test_kh_profile
38 integer :: id_ert=-1, id_erb=-1, id_erc=-1, id_erh=-1, id_kddt=-1, id_kd=-1
39 integer :: id_chct=-1, id_chcb=-1, id_chcc=-1, id_chch=-1
40 integer :: id_t0=-1, id_tf=-1, id_s0=-1, id_sf=-1, id_n2_0=-1, id_n2_f=-1
41 integer :: id_h=-1, id_zint=-1
53 real,
dimension(G%isd:G%ied,G%jsd:G%jed,GV%ke), &
58 real,
intent(in) :: dt
60 real,
dimension(G%isd:G%ied,G%jsd:G%jed,GV%ke+1), &
61 optional,
intent(in) :: kd_int
64 real,
dimension(GV%ke) :: &
67 real,
dimension(GV%ke+1) :: &
70 real :: ustar, absf, htot
73 integer :: i, j, k, is, ie, js, je, nz, itt
75 is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
77 if (.not.
associated(cs))
call mom_error(fatal,
"diapyc_energy_req_test: "// &
78 "Module must be initialized before it is used.")
81 do j=js,je ;
do i=is,ie ;
if (g%mask2dT(i,j) > 0.5)
then
82 if (
present(kd_int) .and. .not.cs%use_test_Kh_profile)
then
83 do k=1,nz+1 ; kd(k) = cs%test_Kh_scaling*kd_int(i,j,k) ;
enddo
85 htot = 0.0 ; h_top(1) = 0.0
87 t0(k) = tv%T(i,j,k) ; s0(k) = tv%S(i,j,k)
88 h_col(k) = h_3d(i,j,k)
89 h_top(k+1) = h_top(k) + h_col(k)
94 h_bot(k) = h_bot(k+1) + h_col(k)
97 ustar = 0.01*us%m_to_Z*us%T_to_s
98 absf = 0.25*((abs(g%CoriolisBu(i-1,j-1)) + abs(g%CoriolisBu(i,j))) + &
99 (abs(g%CoriolisBu(i-1,j-1)) + abs(g%CoriolisBu(i,j))))
100 kd(1) = 0.0 ; kd(nz+1) = 0.0
102 tmp1 = h_top(k) * h_bot(k) * gv%H_to_Z
103 kd(k) = cs%test_Kh_scaling * &
104 ustar * 0.41 * (tmp1*ustar) / (absf*tmp1 + htot*ustar)
107 may_print =
is_root_pe() .and. (i==ie) .and. (j==je)
108 call diapyc_energy_req_calc(h_col, t0, s0, kd, energy_kd, dt, tv, g, gv, us, &
109 may_print=may_print, cs=cs)
110 endif ;
enddo ;
enddo
121 G, GV, US, may_print, CS)
125 real,
dimension(GV%ke),
intent(in) :: h_in
127 real,
dimension(GV%ke),
intent(in) :: t_in
128 real,
dimension(GV%ke),
intent(in) :: s_in
129 real,
dimension(GV%ke+1),
intent(in) :: kd
131 real,
intent(in) :: dt
132 real,
intent(out) :: energy_kd
137 logical,
optional,
intent(in) :: may_print
140 optional,
pointer :: cs
149 real,
dimension(GV%ke) :: &
197 real,
dimension(GV%ke+1) :: &
211 real,
dimension(GV%ke+1,4) :: &
242 real :: dte_t2, dt_km1_t2, dt_k_t2
243 real :: dse_t2, ds_km1_t2, ds_k_t2
247 real,
dimension(GV%ke) :: &
249 real,
dimension(GV%ke+1) :: &
250 dpea_dkd, dpea_dkd_est, dpea_dkd_err, dpea_dkd_trunc, dpea_dkd_err_norm, &
251 dpeb_dkd, dpeb_dkd_est, dpeb_dkd_err, dpeb_dkd_trunc, dpeb_dkd_err_norm
252 real :: pe_chg_tot1a, pe_chg_tot2a, t_chg_tota
253 real :: pe_chg_tot1b, pe_chg_tot2b, t_chg_totb
254 real :: pe_chg_tot1c, pe_chg_tot2c, t_chg_totc
255 real :: pe_chg_tot1d, pe_chg_tot2d, t_chg_totd
256 real,
dimension(GV%ke+1) :: dpechg_dkd
258 real,
dimension(6) :: dt_k_itt, ds_k_itt, dt_km1_itt, ds_km1_itt
260 integer :: k, nz, itt, max_itt, k_cent
261 logical :: surface_bl, bottom_bl, central, halves, debug
262 logical :: old_pe_calc
264 h_neglect = gv%H_subroundoff
268 surface_bl = .true. ; bottom_bl = .true. ; halves = .true.
269 central = .true. ; k_cent = nz/2
271 do_print = .false. ;
if (
present(may_print) .and.
present(cs)) do_print = may_print
273 dpea_dkd(:) = 0.0 ; dpea_dkd_est(:) = 0.0 ; dpea_dkd_err(:) = 0.0
274 dpea_dkd_err_norm(:) = 0.0 ; dpea_dkd_trunc(:) = 0.0
275 dpeb_dkd(:) = 0.0 ; dpeb_dkd_est(:) = 0.0 ; dpeb_dkd_err(:) = 0.0
276 dpeb_dkd_err_norm(:) = 0.0 ; dpeb_dkd_trunc(:) = 0.0
278 htot = 0.0 ; pres(1) = 0.0 ; pres_z(1) = 0.0 ; z_int(1) = 0.0
280 t0(k) = t_in(k) ; s0(k) = s_in(k)
282 htot = htot + h_tr(k)
283 pres(k+1) = pres(k) + gv%H_to_Pa * h_tr(k)
284 pres_z(k+1) = us%Z_to_m * pres(k+1)
285 p_lay(k) = 0.5*(pres(k) + pres(k+1))
286 z_int(k+1) = z_int(k) - h_tr(k)
289 h_tr(k) = max(h_tr(k), 1e-15*htot)
294 kddt_h(1) = 0.0 ; kddt_h(nz+1) = 0.0
296 kddt_h(k) = min((gv%Z_to_H**2*dt)*kd(k) / (0.5*(h_tr(k-1) + h_tr(k))), 1e3*htot)
304 dmass = gv%H_to_kg_m2 * h_tr(k)
305 dpres = gv%H_to_Pa * h_tr(k)
306 dt_to_dpe(k) = (dmass * (pres(k) + 0.5*dpres)) * dsv_dt(k)
307 ds_to_dpe(k) = (dmass * (pres(k) + 0.5*dpres)) * dsv_ds(k)
308 dt_to_dcolht(k) = dmass * us%m_to_Z * dsv_dt(k) * cs%ColHt_scaling
309 ds_to_dcolht(k) = dmass * us%m_to_Z * dsv_ds(k) * cs%ColHt_scaling
314 pe_chg_k(:,:) = 0.0 ; colht_cor_k(:,:) = 0.0
318 old_pe_calc = .false.
322 hp_a(k) = h_tr(k) ; hp_b(k) = h_tr(k)
323 dt_to_dpe_a(k) = dt_to_dpe(k) ; ds_to_dpe_a(k) = ds_to_dpe(k)
324 dt_to_dpe_b(k) = dt_to_dpe(k) ; ds_to_dpe_b(k) = ds_to_dpe(k)
325 dt_to_dcolht_a(k) = dt_to_dcolht(k) ; ds_to_dcolht_a(k) = ds_to_dcolht(k)
326 dt_to_dcolht_b(k) = dt_to_dcolht(k) ; ds_to_dcolht_b(k) = ds_to_dcolht(k)
334 if (old_pe_calc)
then
336 dt_km1_t2 = (t0(k)-t0(k-1))
337 ds_km1_t2 = (s0(k)-s0(k-1))
338 dte_t2 = 0.0 ; dse_t2 = 0.0
340 dte_t2 = kddt_h(k-1) * ((t0(k-2) - t0(k-1)) + dte(k-2))
341 dse_t2 = kddt_h(k-1) * ((s0(k-2) - s0(k-1)) + dse(k-2))
342 dt_km1_t2 = (t0(k)-t0(k-1)) - &
343 (kddt_h(k-1) / hp_a(k-1)) * ((t0(k-2) - t0(k-1)) + dte(k-2))
344 ds_km1_t2 = (s0(k)-s0(k-1)) - &
345 (kddt_h(k-1) / hp_a(k-1)) * ((s0(k-2) - s0(k-1)) + dse(k-2))
347 dte_term = dte_t2 + hp_a(k-1) * (t0(k-1)-t0(k))
348 dse_term = dse_t2 + hp_a(k-1) * (s0(k-1)-s0(k))
351 th_a(k-1) = h_tr(k-1) * t0(k-1) ; sh_a(k-1) = h_tr(k-1) * s0(k-1)
353 th_a(k-1) = h_tr(k-1) * t0(k-1) + kddt_h(k-1) * te(k-2)
354 sh_a(k-1) = h_tr(k-1) * s0(k-1) + kddt_h(k-1) * se(k-2)
356 th_b(k) = h_tr(k) * t0(k) ; sh_b(k) = h_tr(k) * s0(k)
362 kddt_h_guess = kddt_h(k)
363 if (old_pe_calc)
then
365 dte_term, dse_term, dt_km1_t2, ds_km1_t2, &
366 dt_to_dpe(k), ds_to_dpe(k), dt_to_dpe_a(k-1), ds_to_dpe_a(k-1), &
367 pres_z(k), dt_to_dcolht(k), ds_to_dcolht(k), &
368 dt_to_dcolht_a(k-1), ds_to_dcolht_a(k-1), &
369 pe_chg_k(k,1), dpea_dkd(k))
371 call find_pe_chg(0.0, kddt_h_guess, hp_a(k-1), hp_b(k), &
372 th_a(k-1), sh_a(k-1), th_b(k), sh_b(k), &
373 dt_to_dpe_a(k-1), ds_to_dpe_a(k-1), dt_to_dpe_b(k), ds_to_dpe_b(k), &
374 pres_z(k), dt_to_dcolht_a(k-1), ds_to_dcolht_a(k-1), &
375 dt_to_dcolht_b(k), ds_to_dcolht_b(k), &
376 pe_chg=pe_chg_k(k,1), dpec_dkd=dpea_dkd(k), &
377 colht_cor=colht_cor_k(k,1))
382 kddt_h_guess = (1.0+0.01*(itt-3))*kddt_h(k)
384 if (old_pe_calc)
then
386 dte_term, dse_term, dt_km1_t2, ds_km1_t2, &
387 dt_to_dpe(k), ds_to_dpe(k), dt_to_dpe_a(k-1), ds_to_dpe_a(k-1), &
388 pres_z(k), dt_to_dcolht(k), ds_to_dcolht(k), &
389 dt_to_dcolht_a(k-1), ds_to_dcolht_a(k-1), &
392 call find_pe_chg(0.0, kddt_h_guess, hp_a(k-1), hp_b(k), &
393 th_a(k-1), sh_a(k-1), th_b(k), sh_b(k), &
394 dt_to_dpe_a(k-1), ds_to_dpe_a(k-1), dt_to_dpe_b(k), ds_to_dpe_b(k), &
395 pres_z(k), dt_to_dcolht_a(k-1), ds_to_dcolht_a(k-1), &
396 dt_to_dcolht_b(k), ds_to_dcolht_b(k), &
401 dpea_dkd_est(k) = (4.0*(pe_chg(4)-pe_chg(2))/(0.02*kddt_h(k)) - &
402 (pe_chg(5)-pe_chg(1))/(0.04*kddt_h(k))) / 3.0
403 dpea_dkd_trunc(k) = (pe_chg(4)-pe_chg(2))/(0.02*kddt_h(k)) - &
404 (pe_chg(5)-pe_chg(1))/(0.04*kddt_h(k))
405 dpea_dkd_err(k) = (dpea_dkd_est(k) - dpea_dkd(k))
406 dpea_dkd_err_norm(k) = (dpea_dkd_est(k) - dpea_dkd(k)) / &
407 (abs(dpea_dkd_est(k)) + abs(dpea_dkd(k)) + 1e-100)
413 b1 = 1.0 / (hp_a(k-1) + kddt_h(k))
414 c1_a(k) = kddt_h(k) * b1
416 te(1) = b1*(h_tr(1)*t0(1))
417 se(1) = b1*(h_tr(1)*s0(1))
419 te(k-1) = b1 * (h_tr(k-1) * t0(k-1) + kddt_h(k-1) * te(k-2))
420 se(k-1) = b1 * (h_tr(k-1) * s0(k-1) + kddt_h(k-1) * se(k-2))
422 if (old_pe_calc)
then
423 dte(k-1) = b1 * ( kddt_h(k)*(t0(k)-t0(k-1)) + dte_t2 )
424 dse(k-1) = b1 * ( kddt_h(k)*(s0(k)-s0(k-1)) + dse_t2 )
427 hp_a(k) = h_tr(k) + (hp_a(k-1) * b1) * kddt_h(k)
428 dt_to_dpe_a(k) = dt_to_dpe(k) + c1_a(k)*dt_to_dpe_a(k-1)
429 ds_to_dpe_a(k) = ds_to_dpe(k) + c1_a(k)*ds_to_dpe_a(k-1)
430 dt_to_dcolht_a(k) = dt_to_dcolht(k) + c1_a(k)*dt_to_dcolht_a(k-1)
431 ds_to_dcolht_a(k) = ds_to_dcolht(k) + c1_a(k)*ds_to_dcolht_a(k-1)
435 b1 = 1.0 / (hp_a(nz))
436 tf(nz) = b1 * (h_tr(nz) * t0(nz) + kddt_h(nz) * te(nz-1))
437 sf(nz) = b1 * (h_tr(nz) * s0(nz) + kddt_h(nz) * se(nz-1))
438 if (old_pe_calc)
then
439 dte(nz) = b1 * kddt_h(nz) * ((t0(nz-1)-t0(nz)) + dte(nz-1))
440 dse(nz) = b1 * kddt_h(nz) * ((s0(nz-1)-s0(nz)) + dse(nz-1))
444 tf(k) = te(k) + c1_a(k+1)*tf(k+1)
445 sf(k) = se(k) + c1_a(k+1)*sf(k+1)
449 do k=1,nz ; ta(k) = tf(k) ; sa(k) = sf(k) ;
enddo
450 pe_chg_tot1a = 0.0 ; pe_chg_tot2a = 0.0 ; t_chg_tota = 0.0
452 pe_chg_tot1a = pe_chg_tot1a + (dt_to_dpe(k) * (tf(k) - t0(k)) + &
453 ds_to_dpe(k) * (sf(k) - s0(k)))
454 t_chg_tota = t_chg_tota + h_tr(k) * (tf(k) - t0(k))
457 pe_chg_tot2a = pe_chg_tot2a + (pe_chg_k(k,1) - colht_cor_k(k,1))
464 old_pe_calc = .false.
468 hp_a(k) = h_tr(k) ; hp_b(k) = h_tr(k)
469 dt_to_dpe_a(k) = dt_to_dpe(k) ; ds_to_dpe_a(k) = ds_to_dpe(k)
470 dt_to_dpe_b(k) = dt_to_dpe(k) ; ds_to_dpe_b(k) = ds_to_dpe(k)
471 dt_to_dcolht_a(k) = dt_to_dcolht(k) ; ds_to_dcolht_a(k) = ds_to_dcolht(k)
472 dt_to_dcolht_b(k) = dt_to_dcolht(k) ; ds_to_dcolht_b(k) = ds_to_dcolht(k)
480 if (old_pe_calc)
then
482 dt_k_t2 = (t0(k-1)-t0(k))
483 ds_k_t2 = (s0(k-1)-s0(k))
484 dte_t2 = 0.0 ; dse_t2 = 0.0
486 dte_t2 = kddt_h(k+1) * ((t0(k+1) - t0(k)) + dte(k+1))
487 dse_t2 = kddt_h(k+1) * ((s0(k+1) - s0(k)) + dse(k+1))
488 dt_k_t2 = (t0(k-1)-t0(k)) - &
489 (kddt_h(k+1)/ hp_b(k)) * ((t0(k+1) - t0(k)) + dte(k+1))
490 ds_k_t2 = (s0(k-1)-s0(k)) - &
491 (kddt_h(k+1)/ hp_b(k)) * ((s0(k+1) - s0(k)) + dse(k+1))
493 dte_term = dte_t2 + hp_b(k) * (t0(k)-t0(k-1))
494 dse_term = dse_t2 + hp_b(k) * (s0(k)-s0(k-1))
496 th_a(k-1) = h_tr(k-1) * t0(k-1) ; sh_a(k-1) = h_tr(k-1) * s0(k-1)
498 th_b(k) = h_tr(k) * t0(k) ; sh_b(k) = h_tr(k) * s0(k)
500 th_b(k) = h_tr(k) * t0(k) + kddt_h(k+1) * te(k+1)
501 sh_b(k) = h_tr(k) * s0(k) + kddt_h(k+1) * se(k+1)
506 kddt_h_guess = kddt_h(k)
508 if (old_pe_calc)
then
510 dte_term, dse_term, dt_k_t2, ds_k_t2, &
511 dt_to_dpe(k-1), ds_to_dpe(k-1), dt_to_dpe_b(k), ds_to_dpe_b(k), &
512 pres_z(k), dt_to_dcolht(k-1), ds_to_dcolht(k-1), &
513 dt_to_dcolht_b(k), ds_to_dcolht_b(k), &
514 pe_chg=pe_chg_k(k,2), dpec_dkd=dpeb_dkd(k))
516 call find_pe_chg(0.0, kddt_h_guess, hp_a(k-1), hp_b(k), &
517 th_a(k-1), sh_a(k-1), th_b(k), sh_b(k), &
518 dt_to_dpe_a(k-1), ds_to_dpe_a(k-1), dt_to_dpe_b(k), ds_to_dpe_b(k), &
519 pres_z(k), dt_to_dcolht_a(k-1), ds_to_dcolht_a(k-1), &
520 dt_to_dcolht_b(k), ds_to_dcolht_b(k), &
521 pe_chg=pe_chg_k(k,2), dpec_dkd=dpeb_dkd(k), &
522 colht_cor=colht_cor_k(k,2))
528 kddt_h_guess = (1.0+0.01*(itt-3))*kddt_h(k)
530 if (old_pe_calc)
then
532 dte_term, dse_term, dt_k_t2, ds_k_t2, &
533 dt_to_dpe(k-1), ds_to_dpe(k-1), dt_to_dpe_b(k), ds_to_dpe_b(k), &
534 pres_z(k), dt_to_dcolht(k-1), ds_to_dcolht(k-1), &
535 dt_to_dcolht_b(k), ds_to_dcolht_b(k), &
538 call find_pe_chg(0.0, kddt_h_guess, hp_a(k-1), hp_b(k), &
539 th_a(k-1), sh_a(k-1), th_b(k), sh_b(k), &
540 dt_to_dpe_a(k-1), ds_to_dpe_a(k-1), dt_to_dpe_b(k), ds_to_dpe_b(k), &
541 pres_z(k), dt_to_dcolht_a(k-1), ds_to_dcolht_a(k-1), &
542 dt_to_dcolht_b(k), ds_to_dcolht_b(k), &
547 dpeb_dkd_est(k) = (4.0*(pe_chg(4)-pe_chg(2))/(0.02*kddt_h(k)) - &
548 (pe_chg(5)-pe_chg(1))/(0.04*kddt_h(k))) / 3.0
549 dpeb_dkd_trunc(k) = (pe_chg(4)-pe_chg(2))/(0.02*kddt_h(k)) - &
550 (pe_chg(5)-pe_chg(1))/(0.04*kddt_h(k))
551 dpeb_dkd_err(k) = (dpeb_dkd_est(k) - dpeb_dkd(k))
552 dpeb_dkd_err_norm(k) = (dpeb_dkd_est(k) - dpeb_dkd(k)) / &
553 (abs(dpeb_dkd_est(k)) + abs(dpeb_dkd(k)) + 1e-100)
559 b1 = 1.0 / (hp_b(k) + kddt_h(k))
560 c1_b(k) = kddt_h(k) * b1
562 te(nz) = b1* (h_tr(nz)*t0(nz))
563 se(nz) = b1* (h_tr(nz)*s0(nz))
565 te(k) = b1 * (h_tr(k) * t0(k) + kddt_h(k+1) * te(k+1))
566 se(k) = b1 * (h_tr(k) * s0(k) + kddt_h(k+1) * se(k+1))
568 if (old_pe_calc)
then
569 dte(k) = b1 * ( kddt_h(k)*(t0(k-1)-t0(k)) + dte_t2 )
570 dse(k) = b1 * ( kddt_h(k)*(s0(k-1)-s0(k)) + dse_t2 )
573 hp_b(k-1) = h_tr(k-1) + (hp_b(k) * b1) * kddt_h(k)
574 dt_to_dpe_b(k-1) = dt_to_dpe(k-1) + c1_b(k)*dt_to_dpe_b(k)
575 ds_to_dpe_b(k-1) = ds_to_dpe(k-1) + c1_b(k)*ds_to_dpe_b(k)
576 dt_to_dcolht_b(k-1) = dt_to_dcolht(k-1) + c1_b(k)*dt_to_dcolht_b(k)
577 ds_to_dcolht_b(k-1) = ds_to_dcolht(k-1) + c1_b(k)*ds_to_dcolht_b(k)
582 tf(1) = b1 * (h_tr(1) * t0(1) + kddt_h(2) * te(2))
583 sf(1) = b1 * (h_tr(1) * s0(1) + kddt_h(2) * se(2))
584 if (old_pe_calc)
then
585 dte(1) = b1 * kddt_h(2) * ((t0(2)-t0(1)) + dte(2))
586 dse(1) = b1 * kddt_h(2) * ((s0(2)-s0(1)) + dse(2))
590 tf(k) = te(k) + c1_b(k)*tf(k-1)
591 sf(k) = se(k) + c1_b(k)*sf(k-1)
595 do k=1,nz ; tb(k) = tf(k) ; sb(k) = sf(k) ;
enddo
596 pe_chg_tot1b = 0.0 ; pe_chg_tot2b = 0.0 ; t_chg_totb = 0.0
598 pe_chg_tot1b = pe_chg_tot1b + (dt_to_dpe(k) * (tf(k) - t0(k)) + &
599 ds_to_dpe(k) * (sf(k) - s0(k)))
600 t_chg_totb = t_chg_totb + h_tr(k) * (tf(k) - t0(k))
603 pe_chg_tot2b = pe_chg_tot2b + (pe_chg_k(k,2) - colht_cor_k(k,2))
613 hp_a(k) = h_tr(k) ; hp_b(k) = h_tr(k)
614 dt_to_dpe_a(k) = dt_to_dpe(k) ; ds_to_dpe_a(k) = ds_to_dpe(k)
615 dt_to_dpe_b(k) = dt_to_dpe(k) ; ds_to_dpe_b(k) = ds_to_dpe(k)
616 dt_to_dcolht_a(k) = dt_to_dcolht(k) ; ds_to_dcolht_a(k) = ds_to_dcolht(k)
617 dt_to_dcolht_b(k) = dt_to_dcolht(k) ; ds_to_dcolht_b(k) = ds_to_dcolht(k)
626 th_a(k-1) = h_tr(k-1) * t0(k-1) ; sh_a(k-1) = h_tr(k-1) * s0(k-1)
628 th_a(k-1) = h_tr(k-1) * t0(k-1) + kddt_h(k-1) * te_a(k-2)
629 sh_a(k-1) = h_tr(k-1) * s0(k-1) + kddt_h(k-1) * se_a(k-2)
631 th_b(k) = h_tr(k) * t0(k) ; sh_b(k) = h_tr(k) * s0(k)
633 kddt_h_a(k) = 0.0 ;
if (k < k_cent) kddt_h_a(k) = kddt_h(k)
637 th_a(k-1), sh_a(k-1), th_b(k), sh_b(k), &
638 dt_to_dpe_a(k-1), ds_to_dpe_a(k-1), dt_to_dpe_b(k), ds_to_dpe_b(k), &
639 pres_z(k), dt_to_dcolht_a(k-1), ds_to_dcolht_a(k-1), &
640 dt_to_dcolht_b(k), ds_to_dcolht_b(k), &
641 pe_chg=pe_change, colht_cor=colht_cor)
642 pe_chg_k(k,3) = pe_change
643 colht_cor_k(k,3) = colht_cor
645 b1 = 1.0 / (hp_a(k-1) + kddt_h_a(k))
646 c1_a(k) = kddt_h_a(k) * b1
648 te_a(1) = b1*(h_tr(1)*t0(1))
649 se_a(1) = b1*(h_tr(1)*s0(1))
651 te_a(k-1) = b1 * (h_tr(k-1) * t0(k-1) + kddt_h_a(k-1) * te_a(k-2))
652 se_a(k-1) = b1 * (h_tr(k-1) * s0(k-1) + kddt_h_a(k-1) * se_a(k-2))
655 hp_a(k) = h_tr(k) + (hp_a(k-1) * b1) * kddt_h_a(k)
656 dt_to_dpe_a(k) = dt_to_dpe(k) + c1_a(k)*dt_to_dpe_a(k-1)
657 ds_to_dpe_a(k) = ds_to_dpe(k) + c1_a(k)*ds_to_dpe_a(k-1)
658 dt_to_dcolht_a(k) = dt_to_dcolht(k) + c1_a(k)*dt_to_dcolht_a(k-1)
659 ds_to_dcolht_a(k) = ds_to_dcolht(k) + c1_a(k)*ds_to_dcolht_a(k-1)
668 th_a(k-1) = h_tr(k-1) * t0(k-1) ; sh_a(k-1) = h_tr(k-1) * s0(k-1)
674 th_b(k) = h_tr(k) * t0(k) ; sh_b(k) = h_tr(k) * s0(k)
676 th_b(k) = h_tr(k) * t0(k) + kddt_h(k+1) * te_b(k+1)
677 sh_b(k) = h_tr(k) * s0(k) + kddt_h(k+1) * se_b(k+1)
680 kddt_h_b(k) = 0.0 ;
if (k > k_cent) kddt_h_b(k) = kddt_h(k)
684 th_a(k-1), sh_a(k-1), th_b(k), sh_b(k), &
685 dt_to_dpe_a(k-1), ds_to_dpe_a(k-1), dt_to_dpe_b(k), ds_to_dpe_b(k), &
686 pres_z(k), dt_to_dcolht_a(k-1), ds_to_dcolht_a(k-1), &
687 dt_to_dcolht_b(k), ds_to_dcolht_b(k), &
688 pe_chg=pe_change, colht_cor=colht_cor)
689 pe_chg_k(k,3) = pe_chg_k(k,3) + pe_change
690 colht_cor_k(k,3) = colht_cor_k(k,3) + colht_cor
692 b1 = 1.0 / (hp_b(k) + kddt_h_b(k))
693 c1_b(k) = kddt_h_b(k) * b1
695 te_b(k) = b1 * (h_tr(k)*t0(k))
696 se_b(k) = b1 * (h_tr(k)*s0(k))
698 te_b(k) = b1 * (h_tr(k) * t0(k) + kddt_h_b(k+1) * te_b(k+1))
699 se_b(k) = b1 * (h_tr(k) * s0(k) + kddt_h_b(k+1) * se_b(k+1))
702 hp_b(k-1) = h_tr(k-1) + (hp_b(k) * b1) * kddt_h_b(k)
703 dt_to_dpe_b(k-1) = dt_to_dpe(k-1) + c1_b(k)*dt_to_dpe_b(k)
704 ds_to_dpe_b(k-1) = ds_to_dpe(k-1) + c1_b(k)*ds_to_dpe_b(k)
705 dt_to_dcolht_b(k-1) = dt_to_dcolht(k-1) + c1_b(k)*dt_to_dcolht_b(k)
706 ds_to_dcolht_b(k-1) = ds_to_dcolht(k-1) + c1_b(k)*ds_to_dcolht_b(k)
716 th_a(k-1) = h_tr(k-1) * t0(k-1) ; sh_a(k-1) = h_tr(k-1) * s0(k-1)
718 th_a(k-1) = h_tr(k-1) * t0(k-1) + kddt_h(k-1) * te_a(k-2)
719 sh_a(k-1) = h_tr(k-1) * s0(k-1) + kddt_h(k-1) * se_a(k-2)
722 th_b(k) = h_tr(k) * t0(k) ; sh_b(k) = h_tr(k) * s0(k)
724 th_b(k) = h_tr(k) * t0(k) + kddt_h(k+1) * te_b(k+1)
725 sh_b(k) = h_tr(k) * s0(k) + kddt_h(k+1) * se_b(k+1)
731 th_a(k-1), sh_a(k-1), th_b(k), sh_b(k), &
732 dt_to_dpe_a(k-1), ds_to_dpe_a(k-1), dt_to_dpe_b(k), ds_to_dpe_b(k), &
733 pres_z(k), dt_to_dcolht_a(k-1), ds_to_dcolht_a(k-1), &
734 dt_to_dcolht_b(k), ds_to_dcolht_b(k), &
735 pe_chg=pe_change, colht_cor=colht_cor)
736 pe_chg_k(k,3) = pe_chg_k(k,3) + pe_change
737 colht_cor_k(k,3) = colht_cor_k(k,3) + colht_cor
752 b1 = 1.0 / (hp_a(k-1)*hp_b(k) + kddt_h(k)*(hp_a(k-1) + hp_b(k)))
753 tf(k-1) = ((hp_b(k) + kddt_h(k)) * th_a(k-1) + kddt_h(k) * th_b(k) ) * b1
754 sf(k-1) = ((hp_b(k) + kddt_h(k)) * sh_a(k-1) + kddt_h(k) * sh_b(k) ) * b1
755 tf(k) = (kddt_h(k) * th_a(k-1) + (hp_a(k-1) + kddt_h(k)) * th_b(k) ) * b1
756 sf(k) = (kddt_h(k) * sh_a(k-1) + (hp_a(k-1) + kddt_h(k)) * sh_b(k) ) * b1
758 c1_a(k) = kddt_h(k) / (hp_a(k-1) + kddt_h(k))
759 c1_b(k) = kddt_h(k) / (hp_b(k) + kddt_h(k))
764 tf(k) = te_a(k) + c1_a(k+1)*tf(k+1)
765 sf(k) = se_a(k) + c1_a(k+1)*sf(k+1)
768 tf(k) = te_b(k) + c1_b(k)*tf(k-1)
769 sf(k) = se_b(k) + c1_b(k)*sf(k-1)
773 pe_chg_tot1c = 0.0 ; pe_chg_tot2c = 0.0 ; t_chg_totc = 0.0
775 pe_chg_tot1c = pe_chg_tot1c + (dt_to_dpe(k) * (tf(k) - t0(k)) + &
776 ds_to_dpe(k) * (sf(k) - s0(k)))
777 t_chg_totc = t_chg_totc + h_tr(k) * (tf(k) - t0(k))
780 pe_chg_tot2c = pe_chg_tot2c + (pe_chg_k(k,3) - colht_cor_k(k,3))
790 hp_a(k) = h_tr(k) ; hp_b(k) = h_tr(k)
791 dt_to_dpe_a(k) = dt_to_dpe(k) ; ds_to_dpe_a(k) = ds_to_dpe(k)
792 dt_to_dpe_b(k) = dt_to_dpe(k) ; ds_to_dpe_b(k) = ds_to_dpe(k)
793 dt_to_dcolht_a(k) = dt_to_dcolht(k) ; ds_to_dcolht_a(k) = ds_to_dcolht(k)
794 dt_to_dcolht_b(k) = dt_to_dcolht(k) ; ds_to_dcolht_b(k) = ds_to_dcolht(k)
806 th_a(k-1) = h_tr(k-1) * t0(k-1) ; sh_a(k-1) = h_tr(k-1) * s0(k-1)
808 th_a(k-1) = h_tr(k-1) * t0(k-1) + kd_so_far(k-1) * te(k-2)
809 sh_a(k-1) = h_tr(k-1) * s0(k-1) + kd_so_far(k-1) * se(k-2)
811 th_b(k) = h_tr(k) * t0(k) ; sh_b(k) = h_tr(k) * s0(k)
813 dkd = 0.5 * kddt_h(k) - kd_so_far(k)
816 th_a(k-1), sh_a(k-1), th_b(k), sh_b(k), &
817 dt_to_dpe_a(k-1), ds_to_dpe_a(k-1), dt_to_dpe_b(k), ds_to_dpe_b(k), &
818 pres_z(k), dt_to_dcolht_a(k-1), ds_to_dcolht_a(k-1), &
819 dt_to_dcolht_b(k), ds_to_dcolht_b(k), &
820 pe_chg=pe_change, colht_cor=colht_cor)
822 pe_chg_k(k,4) = pe_change
823 colht_cor_k(k,4) = colht_cor
825 kd_so_far(k) = kd_so_far(k) + dkd
827 b1 = 1.0 / (hp_a(k-1) + kd_so_far(k))
828 c1_a(k) = kd_so_far(k) * b1
830 te(1) = b1*(h_tr(1)*t0(1))
831 se(1) = b1*(h_tr(1)*s0(1))
833 te(k-1) = b1 * (h_tr(k-1) * t0(k-1) + kd_so_far(k-1) * te(k-2))
834 se(k-1) = b1 * (h_tr(k-1) * s0(k-1) + kd_so_far(k-1) * se(k-2))
837 hp_a(k) = h_tr(k) + (hp_a(k-1) * b1) * kd_so_far(k)
838 dt_to_dpe_a(k) = dt_to_dpe(k) + c1_a(k)*dt_to_dpe_a(k-1)
839 ds_to_dpe_a(k) = ds_to_dpe(k) + c1_a(k)*ds_to_dpe_a(k-1)
840 dt_to_dcolht_a(k) = dt_to_dcolht(k) + c1_a(k)*dt_to_dcolht_a(k-1)
841 ds_to_dcolht_a(k) = ds_to_dcolht(k) + c1_a(k)*ds_to_dcolht_a(k-1)
849 th_a(k-1) = h_tr(k-1) * t0(k-1) ; sh_a(k-1) = h_tr(k-1) * s0(k-1)
851 th_a(k-1) = h_tr(k-1) * t0(k-1) + kd_so_far(k-1) * te(k-2)
852 sh_a(k-1) = h_tr(k-1) * s0(k-1) + kd_so_far(k-1) * se(k-2)
855 th_b(k) = h_tr(k) * t0(k) ; sh_b(k) = h_tr(k) * s0(k)
857 th_b(k) = h_tr(k) * t0(k) + kd_so_far(k+1) * te(k+1)
858 sh_b(k) = h_tr(k) * s0(k) + kd_so_far(k+1) * se(k+1)
861 dkd = kddt_h(k) - kd_so_far(k)
864 th_a(k-1), sh_a(k-1), th_b(k), sh_b(k), &
865 dt_to_dpe_a(k-1), ds_to_dpe_a(k-1), dt_to_dpe_b(k), ds_to_dpe_b(k), &
866 pres_z(k), dt_to_dcolht_a(k-1), ds_to_dcolht_a(k-1), &
867 dt_to_dcolht_b(k), ds_to_dcolht_b(k), &
868 pe_chg=pe_change, colht_cor=colht_cor)
870 pe_chg_k(k,4) = pe_chg_k(k,4) + pe_change
871 colht_cor_k(k,4) = colht_cor_k(k,4) + colht_cor
874 kd_so_far(k) = kd_so_far(k) + dkd
876 b1 = 1.0 / (hp_b(k) + kd_so_far(k))
877 c1_b(k) = kd_so_far(k) * b1
879 te(k) = b1 * (h_tr(k)*t0(k))
880 se(k) = b1 * (h_tr(k)*s0(k))
882 te(k) = b1 * (h_tr(k) * t0(k) + kd_so_far(k+1) * te(k+1))
883 se(k) = b1 * (h_tr(k) * s0(k) + kd_so_far(k+1) * se(k+1))
886 hp_b(k-1) = h_tr(k-1) + (hp_b(k) * b1) * kd_so_far(k)
887 dt_to_dpe_b(k-1) = dt_to_dpe(k-1) + c1_b(k)*dt_to_dpe_b(k)
888 ds_to_dpe_b(k-1) = ds_to_dpe(k-1) + c1_b(k)*ds_to_dpe_b(k)
889 dt_to_dcolht_b(k-1) = dt_to_dcolht(k-1) + c1_b(k)*dt_to_dcolht_b(k)
890 ds_to_dcolht_b(k-1) = ds_to_dcolht(k-1) + c1_b(k)*ds_to_dcolht_b(k)
897 tf(1) = b1 * (h_tr(1) * t0(1) + kddt_h(2) * te(2))
898 sf(1) = b1 * (h_tr(1) * s0(1) + kddt_h(2) * se(2))
900 tf(k) = te(k) + c1_b(k)*tf(k-1)
901 sf(k) = se(k) + c1_b(k)*sf(k-1)
905 pe_chg_tot1d = 0.0 ; pe_chg_tot2d = 0.0 ; t_chg_totd = 0.0
907 pe_chg_tot1d = pe_chg_tot1d + (dt_to_dpe(k) * (tf(k) - t0(k)) + &
908 ds_to_dpe(k) * (sf(k) - s0(k)))
909 t_chg_totd = t_chg_totd + h_tr(k) * (tf(k) - t0(k))
912 pe_chg_tot2d = pe_chg_tot2d + (pe_chg_k(k,4) - colht_cor_k(k,4))
918 energy_kd = 0.0 ;
do k=2,nz ; energy_kd = energy_kd + pe_chg_k(k,1) ;
enddo
919 energy_kd = energy_kd / dt
923 if (cs%id_ERt>0)
call post_data(cs%id_ERt, pe_chg_k(:,1), cs%diag)
924 if (cs%id_ERb>0)
call post_data(cs%id_ERb, pe_chg_k(:,2), cs%diag)
925 if (cs%id_ERc>0)
call post_data(cs%id_ERc, pe_chg_k(:,3), cs%diag)
926 if (cs%id_ERh>0)
call post_data(cs%id_ERh, pe_chg_k(:,4), cs%diag)
927 if (cs%id_Kddt>0)
call post_data(cs%id_Kddt, kddt_h, cs%diag)
928 if (cs%id_Kd>0)
call post_data(cs%id_Kd, kd, cs%diag)
929 if (cs%id_h>0)
call post_data(cs%id_h, h_tr, cs%diag)
930 if (cs%id_zInt>0)
call post_data(cs%id_zInt, z_int, cs%diag)
931 if (cs%id_CHCt>0)
call post_data(cs%id_CHCt, colht_cor_k(:,1), cs%diag)
932 if (cs%id_CHCb>0)
call post_data(cs%id_CHCb, colht_cor_k(:,2), cs%diag)
933 if (cs%id_CHCc>0)
call post_data(cs%id_CHCc, colht_cor_k(:,3), cs%diag)
934 if (cs%id_CHCh>0)
call post_data(cs%id_CHCh, colht_cor_k(:,4), cs%diag)
935 if (cs%id_T0>0)
call post_data(cs%id_T0, t0, cs%diag)
936 if (cs%id_Tf>0)
call post_data(cs%id_Tf, tf, cs%diag)
937 if (cs%id_S0>0)
call post_data(cs%id_S0, s0, cs%diag)
938 if (cs%id_Sf>0)
call post_data(cs%id_Sf, sf, cs%diag)
939 if (cs%id_N2_0>0)
then
940 n2(1) = 0.0 ; n2(nz+1) = 0.0
943 pres(k), rho_here, tv%eqn_of_state)
944 n2(k) = ((us%L_to_Z**2*gv%g_Earth) * rho_here / (0.5*gv%H_to_Z*(h_tr(k-1) + h_tr(k)))) * &
945 ( 0.5*(dsv_dt(k-1) + dsv_dt(k)) * (t0(k-1) - t0(k)) + &
946 0.5*(dsv_ds(k-1) + dsv_ds(k)) * (s0(k-1) - s0(k)) )
950 if (cs%id_N2_f>0)
then
951 n2(1) = 0.0 ; n2(nz+1) = 0.0
954 pres(k), rho_here, tv%eqn_of_state)
955 n2(k) = ((us%L_to_Z**2*gv%g_Earth) * rho_here / (0.5*gv%H_to_Z*(h_tr(k-1) + h_tr(k)))) * &
956 ( 0.5*(dsv_dt(k-1) + dsv_dt(k)) * (tf(k-1) - tf(k)) + &
957 0.5*(dsv_ds(k-1) + dsv_ds(k)) * (sf(k-1) - sf(k)) )
967 subroutine find_pe_chg(Kddt_h0, dKddt_h, hp_a, hp_b, Th_a, Sh_a, Th_b, Sh_b, &
968 dT_to_dPE_a, dS_to_dPE_a, dT_to_dPE_b, dS_to_dPE_b, &
969 pres_Z, dT_to_dColHt_a, dS_to_dColHt_a, dT_to_dColHt_b, dS_to_dColHt_b, &
970 PE_chg, dPEc_dKd, dPE_max, dPEc_dKd_0, ColHt_cor)
971 real,
intent(in) :: Kddt_h0
974 real,
intent(in) :: dKddt_h
977 real,
intent(in) :: hp_a
981 real,
intent(in) :: hp_b
985 real,
intent(in) :: Th_a
988 real,
intent(in) :: Sh_a
991 real,
intent(in) :: Th_b
994 real,
intent(in) :: Sh_b
997 real,
intent(in) :: dT_to_dPE_a
1001 real,
intent(in) :: dS_to_dPE_a
1005 real,
intent(in) :: dT_to_dPE_b
1009 real,
intent(in) :: dS_to_dPE_b
1013 real,
intent(in) :: pres_Z
1016 real,
intent(in) :: dT_to_dColHt_a
1020 real,
intent(in) :: dS_to_dColHt_a
1024 real,
intent(in) :: dT_to_dColHt_b
1028 real,
intent(in) :: dS_to_dColHt_b
1033 real,
optional,
intent(out) :: PE_chg
1035 real,
optional,
intent(out) :: dPEc_dKd
1037 real,
optional,
intent(out) :: dPE_max
1040 real,
optional,
intent(out) :: dPEc_dKd_0
1042 real,
optional,
intent(out) :: ColHt_cor
1065 bdt1 = hp_a * hp_b + kddt_h0 * hps
1066 dt_c = hp_a * th_b - hp_b * th_a
1067 ds_c = hp_a * sh_b - hp_b * sh_a
1068 pec_core = hp_b * (dt_to_dpe_a * dt_c + ds_to_dpe_a * ds_c) - &
1069 hp_a * (dt_to_dpe_b * dt_c + ds_to_dpe_b * ds_c)
1070 colht_core = hp_b * (dt_to_dcolht_a * dt_c + ds_to_dcolht_a * ds_c) - &
1071 hp_a * (dt_to_dcolht_b * dt_c + ds_to_dcolht_b * ds_c)
1073 if (
present(pe_chg))
then
1076 y1 = dkddt_h / (bdt1 * (bdt1 + dkddt_h * hps))
1077 pe_chg = pec_core * y1
1078 colht_chg = colht_core * y1
1079 if (colht_chg < 0.0) pe_chg = pe_chg - pres_z * colht_chg
1080 if (
present(colht_cor)) colht_cor = -pres_z * min(colht_chg, 0.0)
1081 elseif (
present(colht_cor))
then
1082 y1 = dkddt_h / (bdt1 * (bdt1 + dkddt_h * hps))
1083 colht_cor = -pres_z * min(colht_core * y1, 0.0)
1086 if (
present(dpec_dkd))
then
1088 y1 = 1.0 / (bdt1 + dkddt_h * hps)**2
1089 dpec_dkd = pec_core * y1
1090 colht_chg = colht_core * y1
1091 if (colht_chg < 0.0) dpec_dkd = dpec_dkd - pres_z * colht_chg
1094 if (
present(dpe_max))
then
1096 y1 = 1.0 / (bdt1 * hps)
1097 dpe_max = pec_core * y1
1098 colht_chg = colht_core * y1
1099 if (colht_chg < 0.0) dpe_max = dpe_max - pres_z * colht_chg
1102 if (
present(dpec_dkd_0))
then
1105 dpec_dkd_0 = pec_core * y1
1106 colht_chg = colht_core * y1
1107 if (colht_chg < 0.0) dpec_dkd_0 = dpec_dkd_0 - pres_z * colht_chg
1117 dT_km1_t2, dS_km1_t2, dT_to_dPE_k, dS_to_dPE_k, &
1118 dT_to_dPEa, dS_to_dPEa, pres_Z, dT_to_dColHt_k, &
1119 dS_to_dColHt_k, dT_to_dColHta, dS_to_dColHta, &
1120 PE_chg, dPEc_dKd, dPE_max, dPEc_dKd_0)
1121 real,
intent(in) :: Kddt_h
1124 real,
intent(in) :: h_k
1125 real,
intent(in) :: b_den_1
1129 real,
intent(in) :: dTe_term
1131 real,
intent(in) :: dSe_term
1133 real,
intent(in) :: dT_km1_t2
1135 real,
intent(in) :: dS_km1_t2
1137 real,
intent(in) :: pres_Z
1140 real,
intent(in) :: dT_to_dPE_k
1144 real,
intent(in) :: dS_to_dPE_k
1148 real,
intent(in) :: dT_to_dPEa
1152 real,
intent(in) :: dS_to_dPEa
1156 real,
intent(in) :: dT_to_dColHt_k
1160 real,
intent(in) :: dS_to_dColHt_k
1164 real,
intent(in) :: dT_to_dColHta
1168 real,
intent(in) :: dS_to_dColHta
1173 real,
optional,
intent(out) :: PE_chg
1175 real,
optional,
intent(out) :: dPEc_dKd
1177 real,
optional,
intent(out) :: dPE_max
1180 real,
optional,
intent(out) :: dPEc_dKd_0
1197 real :: dT_k, dT_km1
1198 real :: dS_k, dS_km1
1201 real :: ddT_k_dKd, ddT_km1_dKd
1202 real :: ddS_k_dKd, ddS_km1_dKd
1204 b1 = 1.0 / (b_den_1 + kddt_h)
1212 i_kr_denom = 1.0 / (h_k*b_den_1 + (b_den_1 + h_k)*kddt_h)
1214 dt_k = (kddt_h*i_kr_denom) * dte_term
1215 ds_k = (kddt_h*i_kr_denom) * dse_term
1217 if (
present(pe_chg))
then
1220 dt_km1 = b1kd * ( dt_k + dt_km1_t2 )
1221 ds_km1 = b1kd * ( ds_k + ds_km1_t2 )
1223 pe_chg = (dt_to_dpe_k * dt_k + dt_to_dpea * dt_km1) + &
1224 (ds_to_dpe_k * ds_k + ds_to_dpea * ds_km1)
1225 colht_chg = (dt_to_dcolht_k * dt_k + dt_to_dcolhta * dt_km1) + &
1226 (ds_to_dcolht_k * ds_k + ds_to_dcolhta * ds_km1)
1227 if (colht_chg < 0.0) pe_chg = pe_chg - pres_z * colht_chg
1230 if (
present(dpec_dkd))
then
1232 dkr_dkd = (h_k*b_den_1) * i_kr_denom**2
1234 ddt_k_dkd = dkr_dkd * dte_term
1235 dds_k_dkd = dkr_dkd * dse_term
1236 ddt_km1_dkd = (b1**2 * b_den_1) * ( dt_k + dt_km1_t2 ) + b1kd * ddt_k_dkd
1237 dds_km1_dkd = (b1**2 * b_den_1) * ( ds_k + ds_km1_t2 ) + b1kd * dds_k_dkd
1240 dpec_dkd = (dt_to_dpe_k * ddt_k_dkd + dt_to_dpea * ddt_km1_dkd) + &
1241 (ds_to_dpe_k * dds_k_dkd + ds_to_dpea * dds_km1_dkd)
1242 dcolht_dkd = (dt_to_dcolht_k * ddt_k_dkd + dt_to_dcolhta * ddt_km1_dkd) + &
1243 (ds_to_dcolht_k * dds_k_dkd + ds_to_dcolhta * dds_km1_dkd)
1244 if (dcolht_dkd < 0.0) dpec_dkd = dpec_dkd - pres_z * dcolht_dkd
1247 if (
present(dpe_max))
then
1249 dpe_max = (dt_to_dpea * dt_km1_t2 + ds_to_dpea * ds_km1_t2) + &
1250 ((dt_to_dpe_k + dt_to_dpea) * dte_term + &
1251 (ds_to_dpe_k + ds_to_dpea) * dse_term) / (b_den_1 + h_k)
1252 dcolht_max = (dt_to_dcolhta * dt_km1_t2 + ds_to_dcolhta * ds_km1_t2) + &
1253 ((dt_to_dcolht_k + dt_to_dcolhta) * dte_term + &
1254 (ds_to_dcolht_k + ds_to_dcolhta) * dse_term) / (b_den_1 + h_k)
1255 if (dcolht_max < 0.0) dpe_max = dpe_max - pres_z*dcolht_max
1258 if (
present(dpec_dkd_0))
then
1260 dpec_dkd_0 = (dt_to_dpea * dt_km1_t2 + ds_to_dpea * ds_km1_t2) / (b_den_1) + &
1261 (dt_to_dpe_k * dte_term + ds_to_dpe_k * dse_term) / (h_k*b_den_1)
1262 dcolht_dkd = (dt_to_dcolhta * dt_km1_t2 + ds_to_dcolhta * ds_km1_t2) / (b_den_1) + &
1263 (dt_to_dcolht_k * dte_term + ds_to_dcolht_k * dse_term) / (h_k*b_den_1)
1264 if (dcolht_dkd < 0.0) dpec_dkd_0 = dpec_dkd_0 - pres_z*dcolht_dkd
1271 type(time_type),
intent(in) :: time
1276 type(
diag_ctrl),
target,
intent(inout) :: diag
1279 integer,
save :: init_calls = 0
1281 #include "version_variable.h"
1282 character(len=40) :: mdl =
"MOM_diapyc_energy_req"
1283 character(len=256) :: mesg
1285 if (.not.
associated(cs))
then ;
allocate(cs)
1286 else ;
return ;
endif
1288 cs%initialized = .true.
1293 call get_param(param_file, mdl,
"ENERGY_REQ_KH_SCALING", cs%test_Kh_scaling, &
1294 "A scaling factor for the diapycnal diffusivity used in "//&
1295 "testing the energy requirements.", default=1.0, units=
"nondim")
1296 call get_param(param_file, mdl,
"ENERGY_REQ_COL_HT_SCALING", cs%ColHt_scaling, &
1297 "A scaling factor for the column height change correction "//&
1298 "used in testing the energy requirements.", default=1.0, units=
"nondim")
1299 call get_param(param_file, mdl,
"ENERGY_REQ_USE_TEST_PROFILE", &
1300 cs%use_test_Kh_profile, &
1301 "If true, use the internal test diffusivity profile in "//&
1302 "place of any that might be passed in as an argument.", default=.false.)
1305 "Diffusivity Energy Requirements, top-down",
"J m-2")
1307 "Diffusivity Energy Requirements, bottom-up",
"J m-2")
1309 "Diffusivity Energy Requirements, center-last",
"J m-2")
1311 "Diffusivity Energy Requirements, halves",
"J m-2")
1313 "Implicit diffusive coupling coefficient",
"m", conversion=gv%H_to_m)
1315 "Diffusivity in test",
"m2 s-1", conversion=us%Z_to_m**2)
1317 "Test column layer thicknesses",
"m", conversion=gv%H_to_m)
1319 "Test column layer interface heights",
"m", conversion=gv%H_to_m)
1321 "Column Height Correction to Energy Requirements, top-down",
"J m-2")
1323 "Column Height Correction to Energy Requirements, bottom-up",
"J m-2")
1325 "Column Height Correction to Energy Requirements, center-last",
"J m-2")
1327 "Column Height Correction to Energy Requirements, halves",
"J m-2")
1329 "Temperature before mixing",
"deg C")
1331 "Temperature after mixing",
"deg C")
1333 "Salinity before mixing",
"g kg-1")
1335 "Salinity after mixing",
"g kg-1")
1337 "Squared buoyancy frequency before mixing",
"second-2", conversion=us%s_to_T**2)
1339 "Squared buoyancy frequency after mixing",
"second-2", conversion=us%s_to_T**2)
1347 if (
associated(cs))
deallocate(cs)