FV3 Bundle
nh_core_nlm.F90
Go to the documentation of this file.
1 !***********************************************************************
2 !* GNU General Public License *
3 !* This file is a part of fvGFS. *
4 !* *
5 !* fvGFS is free software; you can redistribute it and/or modify it *
6 !* and are expected to follow the terms of the GNU General Public *
7 !* License as published by the Free Software Foundation; either *
8 !* version 2 of the License, or (at your option) any later version. *
9 !* *
10 !* fvGFS is distributed in the hope that it will be useful, but *
11 !* WITHOUT ANY WARRANTY; without even the implied warranty of *
12 !* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
13 !* General Public License for more details. *
14 !* *
15 !* For the full text of the GNU General Public License, *
16 !* write to: Free Software Foundation, Inc., *
17 !* 675 Mass Ave, Cambridge, MA 02139, USA. *
18 !* or see: http://www.gnu.org/licenses/gpl.html *
19 !***********************************************************************
21 ! Developer: S.-J. Lin, NOAA/GFDL
22 ! To do list:
23 ! include moisture effect in pt
24 !------------------------------
25  use constants_mod, only: rdgas, cp_air, grav
26  use tp_core_nlm_mod, only: fv_tp_2d
31 
32  implicit none
33  private
34 
35  public riem_solver3, riem_solver_c, update_dz_c, update_dz_d, nest_halo_nh
36  real, parameter:: r3 = 1./3.
37 
38 CONTAINS
39 
40  subroutine riem_solver3(ms, dt, is, ie, js, je, km, ng, &
41  isd, ied, jsd, jed, akap, cappa, cp, &
42  ptop, zs, q_con, w, delz, pt, &
43  delp, zh, pe, ppe, pk3, pk, peln, &
44  ws, scale_m, p_fac, a_imp, &
45  use_logp, last_call, fp_out)
46 !--------------------------------------------
47 ! !OUTPUT PARAMETERS
48 ! Ouput: gz: grav*height at edges
49 ! pe: full hydrostatic pressure
50 ! ppe: non-hydrostatic pressure perturbation
51 !--------------------------------------------
52  integer, intent(in):: ms, is, ie, js, je, km, ng
53  integer, intent(in):: isd, ied, jsd, jed
54  real, intent(in):: dt ! the BIG horizontal Lagrangian time step
55  real, intent(in):: akap, cp, ptop, p_fac, a_imp, scale_m
56  real, intent(in):: zs(isd:ied,jsd:jed)
57  logical, intent(in):: last_call, use_logp, fp_out
58  real, intent(in):: ws(is:ie,js:je)
59  real, intent(in), dimension(isd:,jsd:,1:):: q_con, cappa
60  real, intent(in), dimension(isd:ied,jsd:jed,km):: delp, pt
61  real, intent(inout), dimension(isd:ied,jsd:jed,km+1):: zh
62  real, intent(inout), dimension(isd:ied,jsd:jed,km):: w
63  real, intent(inout):: pe(is-1:ie+1,km+1,js-1:je+1)
64  real, intent(out):: peln(is:ie,km+1,js:je) ! ln(pe)
65  real, intent(out), dimension(isd:ied,jsd:jed,km+1):: ppe
66  real, intent(out):: delz(is-ng:ie+ng,js-ng:je+ng,km)
67  real, intent(out):: pk(is:ie,js:je,km+1)
68  real, intent(out):: pk3(isd:ied,jsd:jed,km+1)
69 ! Local:
70  real, dimension(is:ie,km):: dm, dz2, pm2, w2, gm2, cp2
71  real, dimension(is:ie,km+1)::pem, pe2, peln2, peg, pelng
72  real gama, rgrav, ptk, peln1
73  integer i, j, k
74 
75  gama = 1./(1.-akap)
76  rgrav = 1./grav
77  peln1 = log(ptop)
78  ptk = exp(akap*peln1)
79 
80 !$OMP parallel do default(none) shared(is,ie,js,je,km,delp,ptop,peln1,pk3,ptk,akap,rgrav,zh,pt, &
81 !$OMP w,a_imp,dt,gama,ws,p_fac,scale_m,ms,delz,last_call, &
82 !$OMP peln,pk,fp_out,ppe,use_logp,zs,pe,cappa,q_con ) &
83 !$OMP private(cp2, gm2, dm, dz2, pm2, pem, peg, pelng, pe2, peln2, w2)
84  do 2000 j=js, je
85 
86  do k=1,km
87  do i=is, ie
88  dm(i,k) = delp(i,j,k)
89 #ifdef MOIST_CAPPA
90  cp2(i,k) = cappa(i,j,k)
91 #endif
92  enddo
93  enddo
94 
95  do i=is,ie
96  pem(i,1) = ptop
97  peln2(i,1) = peln1
98  pk3(i,j,1) = ptk
99 #ifdef USE_COND
100  peg(i,1) = ptop
101  pelng(i,1) = peln1
102 #endif
103  enddo
104  do k=2,km+1
105  do i=is,ie
106  pem(i,k) = pem(i,k-1) + dm(i,k-1)
107  peln2(i,k) = log(pem(i,k))
108 #ifdef USE_COND
109 ! Excluding contribution from condensates:
110 ! peln used during remap; pk3 used only for p_grad
111  peg(i,k) = peg(i,k-1) + dm(i,k-1)*(1.-q_con(i,j,k-1))
112  pelng(i,k) = log(peg(i,k))
113 #endif
114  pk3(i,j,k) = exp(akap*peln2(i,k))
115  enddo
116  enddo
117 
118  do k=1,km
119  do i=is, ie
120 #ifdef USE_COND
121  pm2(i,k) = (peg(i,k+1)-peg(i,k))/(pelng(i,k+1)-pelng(i,k))
122 
123 #ifdef MOIST_CAPPA
124  gm2(i,k) = 1. / (1.-cp2(i,k))
125 #endif
126 
127 #else
128  pm2(i,k) = dm(i,k)/(peln2(i,k+1)-peln2(i,k))
129 #endif
130  dm(i,k) = dm(i,k) * rgrav
131  dz2(i,k) = zh(i,j,k+1) - zh(i,j,k)
132  w2(i,k) = w(i,j,k)
133  enddo
134  enddo
135 
136  if ( a_imp < -0.999 ) then
137  call sim3p0_solver(dt, is, ie, km, rdgas, gama, akap, pe2, dm, &
138  pem, w2, dz2, pt(is:ie,j,1:km), ws(is,j), p_fac, scale_m )
139  elseif ( a_imp < -0.5 ) then
140  call sim3_solver(dt, is, ie, km, rdgas, gama, akap, pe2, dm, &
141  pem, w2, dz2, pt(is:ie,j,1:km), ws(is,j), abs(a_imp), p_fac, scale_m)
142  elseif ( a_imp <= 0.5 ) then
143  call rim_2d(ms, dt, is, ie, km, rdgas, gama, gm2, pe2, &
144  dm, pm2, w2, dz2, pt(is:ie,j,1:km), ws(is,j), .false.)
145  elseif ( a_imp > 0.999 ) then
146  call sim1_solver(dt, is, ie, km, rdgas, gama, gm2, cp2, akap, pe2, dm, &
147  pm2, pem, w2, dz2, pt(is:ie,j,1:km), ws(is,j), p_fac)
148  else
149  call sim_solver(dt, is, ie, km, rdgas, gama, gm2, cp2, akap, pe2, dm, &
150  pm2, pem, w2, dz2, pt(is:ie,j,1:km), ws(is,j), &
151  a_imp, p_fac, scale_m)
152  endif
153 
154  do k=1, km
155  do i=is, ie
156  w(i,j,k) = w2(i,k)
157  delz(i,j,k) = dz2(i,k)
158  enddo
159  enddo
160 
161  if ( last_call ) then
162  do k=1,km+1
163  do i=is,ie
164  peln(i,k,j) = peln2(i,k)
165  pk(i,j,k) = pk3(i,j,k)
166  pe(i,k,j) = pem(i,k)
167  enddo
168  enddo
169  endif
170 
171  if( fp_out ) then
172  do k=1,km+1
173  do i=is, ie
174  ppe(i,j,k) = pe2(i,k) + pem(i,k)
175  enddo
176  enddo
177  else
178  do k=1,km+1
179  do i=is, ie
180  ppe(i,j,k) = pe2(i,k)
181  enddo
182  enddo
183  endif
184 
185  if ( use_logp ) then
186  do k=2,km+1
187  do i=is, ie
188  pk3(i,j,k) = peln2(i,k)
189  enddo
190  enddo
191  endif
192 
193  do i=is, ie
194  zh(i,j,km+1) = zs(i,j)
195  enddo
196  do k=km,1,-1
197  do i=is, ie
198  zh(i,j,k) = zh(i,j,k+1) - dz2(i,k)
199  enddo
200  enddo
201 
202 2000 continue
203 
204  end subroutine riem_solver3
205 
206 end module nh_core_nlm_mod
subroutine, public sim_solver(dt, is, ie, km, rgas, gama, gm2, cp2, kappa, pe2, dm2, pm2, pem, w2, dz2, pt2, ws, alpha, p_fac, scale_m)
subroutine, public nest_halo_nh(ptop, grav, kappa, cp, delp, delz, pt, phis, pkc, gz, pk3, npx, npy, npz, nested, pkc_pertn, computepk3, fullhalo, bd)
subroutine, public sim1_solver(dt, is, ie, km, rgas, gama, gm2, cp2, kappa, pe, dm2, pm2, pem, w2, dz2, pt2, ws, p_fac)
real, parameter, public rdgas
Gas constant for dry air [J/kg/deg].
Definition: constants.F90:77
subroutine, public rim_2d(ms, bdt, is, ie, km, rgas, gama, gm2, pe2, dm2, pm2, w2, dz2, pt2, ws, c_core)
subroutine, public riem_solver_c(ms, dt, is, ie, js, je, km, ng, akap, cappa, cp, ptop, hs, w3, pt, q_con, delp, gz, pef, ws, p_fac, a_imp, scale_m)
subroutine, public update_dz_c(is, ie, js, je, km, ng, dt, dp0, zs, area, ut, vt, gz, ws, npx, npy, sw_corner, se_corner, ne_corner, nw_corner, bd, grid_type)
real, parameter, public cp_air
Specific heat capacity of dry air at constant pressure [J/kg/deg].
Definition: constants.F90:83
subroutine, public sim3p0_solver(dt, is, ie, km, rgas, gama, kappa, pe2, dm, pem, w2, dz2, pt2, ws, p_fac, scale_m)
subroutine, public sim3_solver(dt, is, ie, km, rgas, gama, kappa, pe2, dm, pem, w2, dz2, pt2, ws, alpha, p_fac, scale_m)
real, parameter, public grav
Acceleration due to gravity [m/s^2].
Definition: constants.F90:76
subroutine, public update_dz_d(ndif, damp, hord, is, ie, js, je, km, ng, npx, npy, area, rarea, dp0, zs, zh, crx, cry, xfx, yfx, delz, ws, rdt, gridstruct, bd)
subroutine, public riem_solver3(ms, dt, is, ie, js, je, km, ng, isd, ied, jsd, jed, akap, cappa, cp, ptop, zs, q_con, w, delz, pt, delp, zh, pe, ppe, pk3, pk, peln, ws, scale_m, p_fac, a_imp, use_logp, last_call, fp_out)
Definition: nh_core_nlm.F90:46
subroutine, public fv_tp_2d(q, crx, cry, npx, npy, hord, fx, fy, xfx, yfx, gridstruct, bd, ra_x, ra_y, mfx, mfy, mass, nord, damp_c)
Definition: tp_core_nlm.F90:80
real, parameter r3
Definition: nh_core_nlm.F90:36