From f60c33e10354d415b131294e22822832de367385 Mon Sep 17 00:00:00 2001 From: Daniel Williams Date: Mon, 29 Nov 2021 11:33:15 +0000 Subject: [PATCH 1/2] Introduce vertical integral of humidity Calculates column integrated specific humidity at each surface grid location --- .../model/spectral_dynamics.F90 | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/atmos_spectral/model/spectral_dynamics.F90 b/src/atmos_spectral/model/spectral_dynamics.F90 index ab2e0b9ae..fa22c9401 100644 --- a/src/atmos_spectral/model/spectral_dynamics.F90 +++ b/src/atmos_spectral/model/spectral_dynamics.F90 @@ -105,7 +105,7 @@ module spectral_dynamics_mod !=============================================================================================== ! variables needed for diagnostics integer :: id_ps, id_u, id_v, id_t, id_vor, id_div, id_omega, id_wspd, id_slp -integer :: id_pres_full, id_pres_half, id_zfull, id_zhalf, id_vort_norm, id_EKE +integer :: id_pres_full, id_pres_half, id_zfull, id_zhalf, id_vort_norm, id_EKE, id_sphum_vert_int integer :: id_uu, id_vv, id_tt, id_omega_omega, id_uv, id_omega_t, id_vw, id_uw, id_ut, id_vt, id_v_vor, id_uz, id_vz, id_omega_z integer, allocatable, dimension(:) :: id_tr, id_utr, id_vtr, id_wtr !extra advection diags added by RG real :: gamma, expf, expf_inverse @@ -1681,6 +1681,9 @@ subroutine spectral_diagnostics_init(Time) id_slp = register_diag_field(mod_name, & 'slp',(/id_lon,id_lat/), Time, 'sea level pressure', 'pascals') + +id_sphum_vert_int = register_diag_field(mod_name, & + 'sphum_vert_int', (/id_lon,id_lat/), Time, 'vertical column mass of specific humidity', 'kg/m2') if(id_slp > 0) then gamma = 0.006 @@ -1716,7 +1719,7 @@ subroutine spectral_diagnostics(Time, p_surf, u_grid, v_grid, t_grid, wg_full, t real, dimension(is:ie, js:je, num_levels) :: ln_p_full, p_full, z_full, worka3d, workb3d real, dimension(is:ie, js:je, num_levels+1) :: ln_p_half, p_half, z_half -real, dimension(is:ie, js:je) :: t_low, slp, worka2d, workb2d +real, dimension(is:ie, js:je) :: t_low, slp, worka2d, workb2d, vert_int_sphum complex, dimension(ms:me, ns:ne, num_levels) :: vor_spec, div_spec complex, dimension(ms:me, ns:ne) :: vorx, vory logical :: used @@ -1820,6 +1823,15 @@ subroutine spectral_diagnostics(Time, p_surf, u_grid, v_grid, t_grid, wg_full, t if(id_wtr(ntr) > 0) used = send_data(id_wtr(ntr), worka3d, Time) enddo +if(id_sphum_vert_int > 0) then + if(id_zfull > 0 .or. id_zhalf > 0) then + call tracer_vertical_integral(p_half, grid_tracers, nhum, vert_int_sphum) + used = send_data(id_sphum_vert_int, vert_int_sphum, Time) + else + call error_mesg('spectral_diagnostics','Vertical integral requires fields height or height_half', FATAL) + endif +endif + if(id_slp > 0) then do j=js,je do i=is,ie @@ -1930,5 +1942,22 @@ subroutine spectral_diagnostics_end return end subroutine spectral_diagnostics_end !=================================================================================== +subroutine tracer_vertical_integral(p_half, grid_tracers, nhum, vert_int_sphum) + ! This subroutine calculates the vertical integral of the tracer field, as + ! defined by the equation W = -1/g sum(q_{v,i} * delta_p,i) + integer, intent(in) :: nhum + real, intent(in), dimension(is:, js:, :) :: p_half + real, intent(in), dimension(is:, js:, :, :, :) :: grid_tracers + real, intent(out), dimension(is:ie, js:je) :: vert_int_sphum + + real, dimension(is:ie, js:je, num_levels) :: p_half_diff, ppress_sphum + + p_half_diff = p_half(:,:,1:num_levels) - p_half(:,:,2:num_levels+1) + ppress_sphum = grid_tracers(:,:,:,current,nhum) * p_half_diff + vert_int_sphum = -(1.0/grav) * sum(ppress_sphum, DIM=3) + + return +end subroutine tracer_vertical_integral +!=================================================================================== end module spectral_dynamics_mod From 1d91f645bd4c64320ceb2fe70aba7abdcb5dcd27 Mon Sep 17 00:00:00 2001 From: Daniel Williams Date: Mon, 29 Nov 2021 14:49:17 +0000 Subject: [PATCH 2/2] Improved error message --- src/atmos_spectral/model/spectral_dynamics.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/atmos_spectral/model/spectral_dynamics.F90 b/src/atmos_spectral/model/spectral_dynamics.F90 index fa22c9401..52eff231d 100644 --- a/src/atmos_spectral/model/spectral_dynamics.F90 +++ b/src/atmos_spectral/model/spectral_dynamics.F90 @@ -1828,7 +1828,7 @@ subroutine spectral_diagnostics(Time, p_surf, u_grid, v_grid, t_grid, wg_full, t call tracer_vertical_integral(p_half, grid_tracers, nhum, vert_int_sphum) used = send_data(id_sphum_vert_int, vert_int_sphum, Time) else - call error_mesg('spectral_diagnostics','Vertical integral requires fields height or height_half', FATAL) + call error_mesg('spectral_diagnostics','Vertical integral requires diagnostics height or height_half', FATAL) endif endif