FV3 Bundle
height_variables_mod.f90
Go to the documentation of this file.
2 
6 
7 implicit none
8 private
9 ! Constants from GSI
10 ! Constants for compressibility factor (Davis et al 1992)
11 real(kind_real),parameter :: cpf_a0 = 1.58123e-6_kind_real ! K/Pa
12 real(kind_real),parameter :: cpf_a1 = -2.9331e-8_kind_real ! 1/Pa
13 real(kind_real),parameter :: cpf_a2 = 1.1043e-10_kind_real ! 1/K 1/Pa
14 real(kind_real),parameter :: cpf_b0 = 5.707e-6_kind_real ! K/Pa
15 real(kind_real),parameter :: cpf_b1 = -2.051e-8_kind_real ! 1/Pa
16 real(kind_real),parameter :: cpf_c0 = 1.9898e-4_kind_real ! K/Pa
17 real(kind_real),parameter :: cpf_c1 = -2.376e-6_kind_real ! 1/Pa
18 real(kind_real),parameter :: cpf_d = 1.83e-11_kind_real ! K2/Pa2
19 real(kind_real),parameter :: cpf_e = -0.765e-8_kind_real ! K2/Pa2
20 
21 real(kind_real),parameter :: psv_a = 1.2378847e-5_kind_real ! (1/K2)
22 real(kind_real),parameter :: psv_b = -1.9121316e-2_kind_real ! (1/K)
23 real(kind_real),parameter :: psv_c = 33.93711047_kind_real !
24 real(kind_real),parameter :: psv_d = -6.3431645e+3_kind_real ! (K)
25 ! Constants for enhancement factor to calculating the mole fraction of water vapor
26 real(kind_real),parameter :: ef_alpha = 1.00062_kind_real !
27 real(kind_real),parameter :: ef_beta = 3.14e-8_kind_real ! (1/Pa)
28 real(kind_real),parameter :: ef_gamma = 5.6e-7_kind_real
29 
30 public geop_height
31 public geop_height_levels
32 
33 contains
34 
35 subroutine geop_height(geom,prs,prsi,T,q,phis,use_compress,gph)
36 
37 implicit none
38 type(fv3jedi_geom) , intent(in ) :: geom !Geometry for the model
39 real(kind_real), intent(in ) :: prs(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz) !mid layerpressure
40 real(kind_real), intent(in ) :: prsi(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz+1) !interface pressure
41 real(kind_real), intent(in ) :: phis(geom%isc:geom%iec,geom%jsc:geom%jec) !Surface geopotential (grav*Z_sfc)
42 real(kind_real), intent(in ) :: t(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
43 real(kind_real), intent(in ) :: q(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz) ! specific humidity
44 real(kind_real), intent(out) :: gph(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz) !geopotential height (meters)
45 
46 !locals
47 real(kind_real) :: tv(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
48 real(kind_real) :: qmr(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz) ! mixing ratio|kg/kg
49 logical :: use_compress
50 integer :: isc,iec,jsc,jec,npz,i,j,k
51 real(kind=kind_real) :: tkk,tvk,tc, qmk,pak,dpk,dz
52 real(kind=kind_real) :: prs_sv, prs_v
53 real(kind=kind_real) :: ehn_fct,x_v,cmpr
54 
55 isc = geom%isc
56 iec = geom%iec
57 jsc = geom%jsc
58 jec = geom%jec
59 npz = geom%npz
60 
61 
62 !get qmr--mixing ratio and virtual temeprature
63 qmr(isc:iec,jsc:jec,:) = q(isc:iec,jsc:jec,:)/(1.0 - q(isc:iec,jsc:jec,:))
64 tv(isc:iec,jsc:jec,:) = t(isc:iec,jsc:jec,:)*(1.0 + zvir*qmr(isc:iec,jsc:jec,:))
65 
66 if (use_compress) then
67 
68 ! Compute compressibility factor (Picard et al 2008) and geopotential heights at midpoint
69  do j = jsc,jec
70  do i = isc,iec
71 
72  do k = geom%npz, 1, -1
73  if ( k == geom%npz) then
74  tkk = t(i,j,k)
75  tvk = tv(i,j,k)
76  pak = exp(0.5_kind_real*(log(prsi(i,j,k+1))+log(prs(i,j,k))))
77  dpk = prsi(i,j,k+1)/prs(i,j,k)
78  else
79  tkk = 0.5_kind_real * ( t(i,j,k+1) + t(i,j,k) )
80  tvk = 0.5_kind_real * (tv(i,j,k+1) + tv(i,j,k) )
81  pak = exp(0.5_kind_real*(log(prs(i,j,k+1))+log(prs(i,j,k))))
82  dpk = prs(i,j,k+1)/prs(i,j,k)
83  end if
84 
85  tc = tkk - tice
86  qmk = qmr(i,j,k)
87  prs_sv = exp(psv_a*tkk**2 + psv_b*tkk + psv_c + psv_d/tkk ) ! Pvap sat, eq A1.1 (Pa)
88  ehn_fct = ef_alpha + ef_beta*pak + ef_gamma*tc**2 ! enhancement factor (eq. A1.2)
89  prs_v = qmk* pak/(1.0+qmk*rdry/rvap) ! vapor pressure (Pa)
90  x_v = prs_v/prs_sv * ehn_fct * prs_sv/pak ! molar fraction of water vapor (eq. A1.3)
91 ! Compressibility factor (eq A1.4 from Picard et al 2008)
92  cmpr = 1.0_kind_real - (pak/tkk) * (cpf_a0 + cpf_a1*tc + cpf_a2*tc**2 &
93  + (cpf_b0 + cpf_b1*tc)*x_v + (cpf_c0 + cpf_c1*tc)*x_v**2 ) &
94  + (pak**2/tkk**2) * (cpf_d + cpf_e*x_v**2)
95  dz = rdry/grav * tvk * cmpr * log(dpk)
96  if ( k == geom%npz) then
97  gph(i,j,k) = phis(i,j)/grav + dz
98  else
99  gph(i,j,k) = gph(i,j,k+1) + dz
100  end if
101  end do ! end k loop
102 
103  end do ! end i loop
104  end do ! end j loop
105 
106 else ! not use compressivity
107 
108  do j = jsc,jec
109  do i = isc,iec
110 
111  k = geom%npz
112  dz = rdry/grav * tv(i,j,k) * log(prsi(i,j,k+1)/prs(i,j,k))
113  gph(i,j,k) = phis(i,j)/grav + dz
114 
115  do k = geom%npz-1, 1, -1
116  dz = rdry/grav * 0.5_kind_real * (tv(i,j,k+1)+tv(i,j,k)) * log(prs(i,j,k+1)/prs(i,j,k))
117  gph(i,j,k) = gph(i,j,k+1) + dz
118  end do
119 
120  end do
121  end do
122 
123 end if
124 
125 end subroutine geop_height
126 
127 subroutine geop_height_levels(geom,prs,prsi,T,q,phis,use_compress,gphi)
129 implicit none
130 type(fv3jedi_geom) , intent(in ) :: geom !Geometry for the model
131 
132 real(kind_real), intent(in ) :: prs(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz) !mid layerpressure
133 real(kind_real), intent(in ) :: prsi(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz+1) !interface pressure
134 real(kind_real), intent(in ) :: phis(geom%isc:geom%iec,geom%jsc:geom%jec) !Surface geopotential (grav*Z_sfc)
135 real(kind_real), intent(in ) :: t(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
136 real(kind_real), intent(in ) :: q(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz) !specific humidity
137 real(kind_real), intent(out) :: gphi(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz+1) !geopotential height at interface levels (m)
138 
139 !locals
140 real(kind_real) :: tv(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz)
141 real(kind_real) :: qmr(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz) ! mixing ratio|kg/kg
142 logical :: use_compress
143 
144 integer :: isc,iec,jsc,jec,npz,i,j,k
145 real(kind=kind_real) :: tkk,tvk,tc, qmk,pak,dpk,dz
146 real(kind=kind_real) :: prs_sv, prs_v
147 real(kind=kind_real) :: ehn_fct,x_v,cmpr
148 
149 isc = geom%isc
150 iec = geom%iec
151 jsc = geom%jsc
152 jec = geom%jec
153 npz = geom%npz
154 !get qmr--mixing ratio and virtual temeprature
155 qmr(isc:iec,jsc:jec,:) = q(isc:iec,jsc:jec,:)/(1.0 - q(isc:iec,jsc:jec,:))
156 tv(isc:iec,jsc:jec,:) = t(isc:iec,jsc:jec,:)*(1.0 + zvir*qmr(isc:iec,jsc:jec,:))
157 
158 if (use_compress) then
159 
160 ! Compute compressibility factor (Picard et al 2008) and geopotential heights at midpoint
161  do j = jsc,jec
162  do i = isc,iec
163 
164  gphi(i,j,geom%npz+1) = phis(i,j)/grav !phis is gh? or gopoential
165  do k = geom%npz, 1, -1
166  if ( k == 1) then
167  pak = exp(0.5_kind_real*(log(prsi(i,j,k+1))+log(prs(i,j,k))))
168  dpk = prsi(i,j,k+1)/prs(i,j,k)
169  else
170  pak = exp(0.5_kind_real*(log(prsi(i,j,k+1))+log(prsi(i,j,k))))
171  dpk = prsi(i,j,k+1)/prsi(i,j,k)
172  end if
173  tkk = t(i,j,k)
174  tvk = tv(i,j,k)
175  tc = tkk - tice
176  qmk = qmr(i,j,k)
177  prs_sv = exp(psv_a*tkk**2 + psv_b*tkk + psv_c + psv_d/tkk ) ! Pvap sat, eq A1.1 (Pa)
178  ehn_fct = ef_alpha + ef_beta*pak + ef_gamma*tc**2 ! enhancement factor (eq. A1.2)
179  prs_v = qmk* pak/(1.0+qmk*rdry/rvap) ! vapor pressure (Pa)
180  x_v = prs_v/prs_sv * ehn_fct * prs_sv/pak ! molar fraction of water vapor (eq. A1.3)
181 ! Compressibility factor (eq A1.4 from Picard et al 2008)
182 
183  cmpr = 1.0_kind_real - (pak/tkk) * (cpf_a0 + cpf_a1*tc + cpf_a2*tc**2 &
184  + (cpf_b0 + cpf_b1*tc)*x_v + (cpf_c0 + cpf_c1*tc)*x_v**2 ) &
185  + (pak**2/tkk**2) * (cpf_d + cpf_e*x_v**2)
186  dz = rdry/grav * tvk * cmpr * log(dpk)
187  gphi(i,j,k) = gphi(i,j,k+1) + dz
188  end do ! end k loop
189 
190  end do ! end i loop
191  end do ! end j loop
192 
193 else ! not use compressivity
194  do j = jsc,jec
195  do i = isc,iec
196 
197  gphi(i,j, geom%npz+1) = phis(i,j)/grav
198 
199  do k = geom%npz, 1, -1
200  if(k ==1) then
201  dz = rdry/grav * tv(i,j,k) * log(prsi(i,j,k+1)/prs(i,j,k))
202  else
203  dz = rdry/grav * tv(i,j,k) * log(prsi(i,j,k+1)/prsi(i,j,k))
204  end if
205  gphi(i,j,k) = gphi(i,j,k+1) + dz
206  end do
207 
208  end do
209  end do
210 
211 end if
212 
213 end subroutine geop_height_levels
214 end module height_vt_mod
real(kind=kind_real), parameter, public tice
real(kind_real), parameter psv_b
real(kind_real), parameter cpf_b0
real(kind=kind_real), parameter, public rdry
Fortran derived type to hold geometry data for the FV3JEDI model.
real(kind_real), parameter cpf_d
real(kind=kind_real), parameter, public rvap
subroutine, public geop_height_levels(geom, prs, prsi, T, q, phis, use_compress, gphi)
real(kind_real), parameter cpf_a2
real(kind_real), parameter cpf_a0
real(kind_real), parameter ef_alpha
real(kind_real), parameter cpf_e
subroutine, public geop_height(geom, prs, prsi, T, q, phis, use_compress, gph)
real(kind_real), parameter psv_c
real(kind_real), parameter psv_d
real(kind_real), parameter cpf_c1
real, parameter, public grav
Acceleration due to gravity [m/s^2].
Definition: constants.F90:76
real(kind_real), parameter ef_beta
real(kind_real), parameter ef_gamma
Fortran module handling geometry for the FV3 model.
real(kind_real), parameter psv_a
real(kind=kind_real), parameter, public zvir
integer, parameter, public kind_real
real(kind_real), parameter cpf_c0
real(kind_real), parameter cpf_a1
real(kind_real), parameter cpf_b1