FV3-JEDI
pressure_variables_mod.f90
Go to the documentation of this file.
1 ! (C) Copyright 2018-2019 UCAR
2 !
3 ! This software is licensed under the terms of the Apache Licence Version 2.0
4 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5 
7 
11 
12 implicit none
13 private
14 
15 public delp_to_pe_p_logp
16 public pe_to_pkz
17 public ps_to_pkz
18 public pe_to_delp
19 public delp_to_pe
20 public pe_to_pk
21 public ps_to_delp
22 public ps_to_pe
23 public ps_to_delp_tl
24 public ps_to_delp_ad
25 
26 contains
27 
28 !----------------------------------------------------------------------------
29 ! Pressure thickness to pressure (edge), pressure (mid) and log p (mid) -----
30 !----------------------------------------------------------------------------
31 
32 subroutine delp_to_pe_p_logp(geom,delp,pe,p,logp)
33 
34  implicit none
35  type(fv3jedi_geom) , intent(in ) :: geom !Geometry for the model
36  real(kind=kind_real), intent(in ) :: delp(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz) !Pressure thickness
37  real(kind=kind_real), intent(out) :: pe(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz+1) !Pressure edge/interface
38  real(kind=kind_real), intent(out) :: p(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz) !Pressure mid point
39  real(kind=kind_real), optional, intent(out) :: logp(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz) !Log of pressure mid point
40 
41  !Locals
42  integer :: isc,iec,jsc,jec,k
43 
44  isc = geom%isc
45  iec = geom%iec
46  jsc = geom%jsc
47  jec = geom%jec
48 
49  !Pressure at layer edge
50  pe(isc:iec,jsc:jec,1) = geom%ptop
51  do k = 2,geom%npz+1
52  pe(isc:iec,jsc:jec,k) = pe(isc:iec,jsc:jec,k-1) + delp(isc:iec,jsc:jec,k-1)
53  enddo
54 
55  !Midpoint pressure
56  p(isc:iec,jsc:jec,:) = 0.5*(pe(isc:iec,jsc:jec,2:geom%npz+1) + pe(isc:iec,jsc:jec,1:geom%npz))
57 
58  if (present(logp)) then
59  !Log pressure
60  logp(isc:iec,jsc:jec,:) = log(p(isc:iec,jsc:jec,:))
61  endif
62 
63 end subroutine delp_to_pe_p_logp
64 
65 !----------------------------------------------------------------------------
66 
67 subroutine pe_to_pkz(geom,pe,pkz)
68 
69 implicit none
70 type(fv3jedi_geom) , intent(in ) :: geom !Geometry for the model
71 real(kind=kind_real), intent(in ) :: pe(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz+1) !Pressure edge/interface
72 real(kind=kind_real), intent(out) :: pkz(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz) !Pressure to the kappa
73 
74 integer :: k
75 real(kind=kind_real) :: peln(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz+1)
76 real(kind=kind_real) :: pk(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz+1)
77 
78 peln = log(pe)
79 pk = exp(kappa*peln)
80 
81 do k=1,geom%npz
82  pkz(:,:,k) = (pk(:,:,k+1)-pk(:,:,k)) / (kappa*(peln(:,:,k+1)-peln(:,:,k)))
83 enddo
84 
85 end subroutine pe_to_pkz
86 
87 !----------------------------------------------------------------------------
88 
89 subroutine pe_to_delp(geom,pe,delp)
90 
91  implicit none
92  type(fv3jedi_geom) , intent(in ) :: geom !Geometry for the model
93  real(kind=kind_real), intent(in ) :: pe(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz+1) !Pressure edge/interface
94  real(kind=kind_real), intent(out) :: delp(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz) !Pressure thickness
95 
96  !Locals
97  integer :: isc,iec,jsc,jec,k
98 
99  isc = geom%isc
100  iec = geom%iec
101  jsc = geom%jsc
102  jec = geom%jec
103 
104  !Pressure at layer edge
105  do k = 1,geom%npz
106  delp(isc:iec,jsc:jec,k) = pe(isc:iec,jsc:jec,k+1) - pe(isc:iec,jsc:jec,k)
107  enddo
108 
109 end subroutine pe_to_delp
110 
111 !----------------------------------------------------------------------------
112 
113 subroutine delp_to_pe( geom, delp, pe )
114 
115 implicit none
116 type(fv3jedi_geom) , intent(in ) :: geom !Geometry for the model
117 real(kind=kind_real), intent(in ) :: delp(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz) !Pressure thickness
118 real(kind=kind_real), intent(out) :: pe(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz+1) !Pressure edge/interface
119 
120 !Locals
121 integer :: isc,iec,jsc,jec,k
122 
123 isc = geom%isc
124 iec = geom%iec
125 jsc = geom%jsc
126 jec = geom%jec
127 
128 !Pressure at layer edge
129 pe(isc:iec,jsc:jec,1) = geom%ptop
130 do k = 2,geom%npz+1
131  pe(isc:iec,jsc:jec,k) = pe(isc:iec,jsc:jec,k-1) + delp(isc:iec,jsc:jec,k-1)
132 enddo
133 
134 end subroutine delp_to_pe
135 
136 !----------------------------------------------------------------------------
137 
138 subroutine pe_to_pk( geom, pe, pk )
139 
140 implicit none
141 type(fv3jedi_geom) , intent(in ) :: geom !Geometry for the model
142 real(kind=kind_real), intent(in ) :: pe(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz+1) !Pressure edge/interface
143 real(kind=kind_real), intent(out) :: pk(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz) !Pressure to the kappa
144 
145 !Locals
146 integer :: i, j, k
147 real(kind=kind_real) :: pel1, pel2
148 real(kind=kind_real) :: pek1, pek2
149 
150 do k=1,geom%npz
151  do j = geom%jsc,geom%jec
152  do i = geom%isc,geom%iec
153 
154  pel1 = log(pe(i,j,k+1))
155  pel2 = log(pe(i,j,k))
156 
157  pek1 = exp(kappa*pel1)
158  pek2 = exp(kappa*pel2)
159 
160  pk(i,j,k) = (pek1-pek2)/(kappa*(pel1-pel2))
161 
162  end do
163  end do
164 end do
165 
166 end subroutine pe_to_pk
167 
168 !----------------------------------------------------------------------------
169 
170 subroutine ps_to_pe(geom,ps,pe)
171 
172  implicit none
173  type(fv3jedi_geom) , intent(in ) :: geom !Geometry for the model
174  real(kind=kind_real), intent(in ) :: ps(geom%isc:geom%iec,geom%jsc:geom%jec,1 ) !Surface pressure
175  real(kind=kind_real), intent(inout) :: pe(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz+1) !Pressure thickness
176 
177  integer :: k
178 
179  do k = 1,geom%npz+1
180  pe(:,:,k) = geom%ak(k) + geom%bk(k) * ps(:,:,1)
181  enddo
182 
183 endsubroutine ps_to_pe
184 
185 !----------------------------------------------------------------------------
186 
187 subroutine ps_to_pkz(geom,ps,pkz)
188 
189  implicit none
190  type(fv3jedi_geom) , intent(in ) :: geom !Geometry for the model
191  real(kind=kind_real), intent(in ) :: ps(geom%isc:geom%iec,geom%jsc:geom%jec,1 ) !Surface pressure
192  real(kind=kind_real), intent(inout) :: pkz(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz) !Pressure ^ kappa
193 
194  integer :: k
195  real(kind=kind_real) :: pe(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz+1) !Pressure
196 
197  call ps_to_pe(geom, ps, pe)
198  call pe_to_pkz(geom, pe, pkz)
199 
200 endsubroutine ps_to_pkz
201 
202 !----------------------------------------------------------------------------
203 
204 subroutine ps_to_delp(geom,ps,delp)
205 
206  implicit none
207  type(fv3jedi_geom) , intent(in ) :: geom !Geometry for the model
208  real(kind=kind_real), intent(in ) :: ps(geom%isc:geom%iec,geom%jsc:geom%jec ) !Surface pressure
209  real(kind=kind_real), intent(inout) :: delp(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz) !Pressure thickness
210 
211  integer :: isc,iec,jsc,jec,i,j,k
212 
213  isc = geom%isc
214  iec = geom%iec
215  jsc = geom%jsc
216  jec = geom%jec
217 
218  do k = 1,geom%npz
219  do j = jsc,jec
220  do i = isc,iec
221  delp(i,j,k) = geom%ak(k+1) + geom%bk(k+1)*ps(i,j) - (geom%ak(k) + geom%bk(k)*ps(i,j))
222  enddo
223  enddo
224  enddo
225 
226 endsubroutine ps_to_delp
227 
228 subroutine ps_to_delp_tl(geom,ps_tl,delp_tl)
229 
230  implicit none
231  type(fv3jedi_geom) , intent(in ) :: geom !Geometry for the model
232  real(kind=kind_real), intent(in ) :: ps_tl(geom%isc:geom%iec,geom%jsc:geom%jec ) !Surface pressure
233  real(kind=kind_real), intent(inout) :: delp_tl(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz) !Pressure thickness
234 
235  integer :: isc,iec,jsc,jec,i,j,k
236 
237  isc = geom%isc
238  iec = geom%iec
239  jsc = geom%jsc
240  jec = geom%jec
241 
242  delp_tl = 0.0_kind_real
243  do k = 1,geom%npz
244  do j = jsc,jec
245  do i = isc,iec
246  delp_tl(i,j,k) = geom%bk(k+1)*ps_tl(i,j) - geom%bk(k)*ps_tl(i,j)
247  enddo
248  enddo
249  enddo
250 
251 endsubroutine ps_to_delp_tl
252 
253 subroutine ps_to_delp_ad(geom,ps_ad,delp_ad)
254 
255  implicit none
256  type(fv3jedi_geom) , intent(in ) :: geom !Geometry for the model
257  real(kind=kind_real), intent(inout) :: ps_ad(geom%isc:geom%iec,geom%jsc:geom%jec ) !Surface pressure
258  real(kind=kind_real), intent(inout) :: delp_ad(geom%isc:geom%iec,geom%jsc:geom%jec,1:geom%npz) !Pressure thickness
259 
260  integer :: isc,iec,jsc,jec,i,j,k
261 
262  isc = geom%isc
263  iec = geom%iec
264  jsc = geom%jsc
265  jec = geom%jec
266 
267  ps_ad = 0.0_kind_real
268 
269  do k = geom%npz,1,-1
270  do j = jec,jsc,-1
271  do i = iec,isc,-1
272  ps_ad(i,j) = ps_ad(i,j) + (geom%bk(k+1) - geom%bk(k))*delp_ad(i,j,k)
273  enddo
274  enddo
275  enddo
276 
277 endsubroutine ps_to_delp_ad
278 
279 end module pressure_vt_mod
pressure_vt_mod::ps_to_delp
subroutine, public ps_to_delp(geom, ps, delp)
Definition: pressure_variables_mod.f90:205
pressure_vt_mod::delp_to_pe
subroutine, public delp_to_pe(geom, delp, pe)
Definition: pressure_variables_mod.f90:114
pressure_vt_mod::ps_to_delp_tl
subroutine, public ps_to_delp_tl(geom, ps_tl, delp_tl)
Definition: pressure_variables_mod.f90:229
pressure_vt_mod::ps_to_pkz
subroutine, public ps_to_pkz(geom, ps, pkz)
Definition: pressure_variables_mod.f90:188
pressure_vt_mod::ps_to_delp_ad
subroutine, public ps_to_delp_ad(geom, ps_ad, delp_ad)
Definition: pressure_variables_mod.f90:254
fv3jedi_geom_mod
Fortran module handling geometry for the FV3 model.
Definition: fv3jedi_geom_mod.f90:8
fv3jedi_geom_mod::fv3jedi_geom
Fortran derived type to hold geometry data for the FV3JEDI model.
Definition: fv3jedi_geom_mod.f90:46
pressure_vt_mod::pe_to_pk
subroutine, public pe_to_pk(geom, pe, pk)
Definition: pressure_variables_mod.f90:139
fv3jedi_constants_mod
Definition: fv3jedi_constants_mod.f90:6
fv3jedi_constants_mod::kappa
real(kind=kind_real), parameter, public kappa
Definition: fv3jedi_constants_mod.f90:34
pressure_vt_mod
Definition: pressure_variables_mod.f90:6
pressure_vt_mod::pe_to_pkz
subroutine, public pe_to_pkz(geom, pe, pkz)
Definition: pressure_variables_mod.f90:68
fv3jedi_kinds_mod::kind_real
integer, parameter, public kind_real
Definition: fv3jedi_kinds_mod.f90:14
pressure_vt_mod::ps_to_pe
subroutine, public ps_to_pe(geom, ps, pe)
Definition: pressure_variables_mod.f90:171
pressure_vt_mod::delp_to_pe_p_logp
subroutine, public delp_to_pe_p_logp(geom, delp, pe, p, logp)
Definition: pressure_variables_mod.f90:33
fv3jedi_kinds_mod
Definition: fv3jedi_kinds_mod.f90:6
pressure_vt_mod::pe_to_delp
subroutine, public pe_to_delp(geom, pe, delp)
Definition: pressure_variables_mod.f90:90