1 | !> @file eqn_state_seawater.f90 |
---|
2 | !------------------------------------------------------------------------------! |
---|
3 | ! This file is part of the PALM model system. |
---|
4 | ! |
---|
5 | ! PALM is free software: you can redistribute it and/or modify it under the |
---|
6 | ! terms of the GNU General Public License as published by the Free Software |
---|
7 | ! Foundation, either version 3 of the License, or (at your option) any later |
---|
8 | ! version. |
---|
9 | ! |
---|
10 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
11 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
12 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
13 | ! |
---|
14 | ! You should have received a copy of the GNU General Public License along with |
---|
15 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
16 | ! |
---|
17 | ! Copyright 1997-2018 Leibniz Universitaet Hannover |
---|
18 | !------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ----------------- |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: eqn_state_seawater.f90 2718 2018-01-02 08:49:38Z suehring $ |
---|
27 | ! Corrected "Former revisions" section |
---|
28 | ! |
---|
29 | ! 2696 2017-12-14 17:12:51Z kanani |
---|
30 | ! Change in file header (GPL part) |
---|
31 | ! |
---|
32 | ! 2369 2017-08-22 15:20:37Z suehring |
---|
33 | ! Bugfix, do not mask topography here, since density becomes zero, leading to |
---|
34 | ! division by zero in production_e |
---|
35 | ! |
---|
36 | ! 2233 2017-05-30 18:08:54Z suehring |
---|
37 | ! |
---|
38 | ! 2232 2017-05-30 17:47:52Z suehring |
---|
39 | ! Adjustments to new topography and surface concept |
---|
40 | ! |
---|
41 | ! 2031 2016-10-21 15:11:58Z knoop |
---|
42 | ! renamed variable rho to rho_ocean |
---|
43 | ! |
---|
44 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
45 | ! Forced header and separation lines into 80 columns |
---|
46 | ! |
---|
47 | ! 1873 2016-04-18 14:50:06Z maronga |
---|
48 | ! Module renamed (removed _mod) |
---|
49 | ! |
---|
50 | ! |
---|
51 | ! 1850 2016-04-08 13:29:27Z maronga |
---|
52 | ! Module renamed |
---|
53 | ! |
---|
54 | ! |
---|
55 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
56 | ! Code annotations made doxygen readable |
---|
57 | ! |
---|
58 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
59 | ! REAL constants provided with KIND-attribute |
---|
60 | ! |
---|
61 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
62 | ! ONLY-attribute added to USE-statements, |
---|
63 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
64 | ! kinds are defined in new module kinds, |
---|
65 | ! revision history before 2012 removed, |
---|
66 | ! comment fields (!:) to be used for variable explanations added to |
---|
67 | ! all variable declaration statements |
---|
68 | ! |
---|
69 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
70 | ! code put under GPL (PALM 3.9) |
---|
71 | ! |
---|
72 | ! 97 2007-06-21 08:23:15Z raasch |
---|
73 | ! Initial revision |
---|
74 | ! |
---|
75 | ! |
---|
76 | ! Description: |
---|
77 | ! ------------ |
---|
78 | !> Equation of state for seawater as a function of potential temperature, |
---|
79 | !> salinity, and pressure. |
---|
80 | !> For coefficients see Jackett et al., 2006: J. Atm. Ocean Tech. |
---|
81 | !> eqn_state_seawater calculates the potential density referred at hyp(0). |
---|
82 | !> eqn_state_seawater_func calculates density. |
---|
83 | !------------------------------------------------------------------------------! |
---|
84 | MODULE eqn_state_seawater_mod |
---|
85 | |
---|
86 | |
---|
87 | USE kinds |
---|
88 | |
---|
89 | IMPLICIT NONE |
---|
90 | |
---|
91 | PRIVATE |
---|
92 | PUBLIC eqn_state_seawater, eqn_state_seawater_func |
---|
93 | |
---|
94 | REAL(wp), DIMENSION(12), PARAMETER :: nom = & |
---|
95 | (/ 9.9984085444849347D2, 7.3471625860981584D0, & |
---|
96 | -5.3211231792841769D-2, 3.6492439109814549D-4, & |
---|
97 | 2.5880571023991390D0, -6.7168282786692354D-3, & |
---|
98 | 1.9203202055760151D-3, 1.1798263740430364D-2, & |
---|
99 | 9.8920219266399117D-8, 4.6996642771754730D-6, & |
---|
100 | -2.5862187075154352D-8, -3.2921414007960662D-12 /) |
---|
101 | !< |
---|
102 | |
---|
103 | REAL(wp), DIMENSION(13), PARAMETER :: den = & |
---|
104 | (/ 1.0D0, 7.2815210113327091D-3, & |
---|
105 | -4.4787265461983921D-5, 3.3851002965802430D-7, & |
---|
106 | 1.3651202389758572D-10, 1.7632126669040377D-3, & |
---|
107 | -8.8066583251206474D-6, -1.8832689434804897D-10, & |
---|
108 | 5.7463776745432097D-6, 1.4716275472242334D-9, & |
---|
109 | 6.7103246285651894D-6, -2.4461698007024582D-17, & |
---|
110 | -9.1534417604289062D-18 /) |
---|
111 | !< |
---|
112 | |
---|
113 | INTERFACE eqn_state_seawater |
---|
114 | MODULE PROCEDURE eqn_state_seawater |
---|
115 | MODULE PROCEDURE eqn_state_seawater_ij |
---|
116 | END INTERFACE eqn_state_seawater |
---|
117 | |
---|
118 | INTERFACE eqn_state_seawater_func |
---|
119 | MODULE PROCEDURE eqn_state_seawater_func |
---|
120 | END INTERFACE eqn_state_seawater_func |
---|
121 | |
---|
122 | CONTAINS |
---|
123 | |
---|
124 | |
---|
125 | !------------------------------------------------------------------------------! |
---|
126 | ! Description: |
---|
127 | ! ------------ |
---|
128 | !> Call for all grid points |
---|
129 | !------------------------------------------------------------------------------! |
---|
130 | SUBROUTINE eqn_state_seawater |
---|
131 | |
---|
132 | USE arrays_3d, & |
---|
133 | ONLY: hyp, prho, pt_p, rho_ocean, sa_p |
---|
134 | USE indices, & |
---|
135 | ONLY: nxl, nxr, nyn, nys, nzb, nzt |
---|
136 | |
---|
137 | USE surface_mod, & |
---|
138 | ONLY : bc_h |
---|
139 | |
---|
140 | IMPLICIT NONE |
---|
141 | |
---|
142 | INTEGER(iwp) :: i !< running index x direction |
---|
143 | INTEGER(iwp) :: j !< running index y direction |
---|
144 | INTEGER(iwp) :: k !< running index z direction |
---|
145 | INTEGER(iwp) :: l !< running index of surface type, south- or north-facing wall |
---|
146 | INTEGER(iwp) :: m !< running index surface elements |
---|
147 | INTEGER(iwp) :: surf_e !< End index of surface elements at (j,i)-gridpoint |
---|
148 | INTEGER(iwp) :: surf_s !< Start index of surface elements at (j,i)-gridpoint |
---|
149 | |
---|
150 | REAL(wp) :: pden !< |
---|
151 | REAL(wp) :: pnom !< |
---|
152 | REAL(wp) :: p1 !< |
---|
153 | REAL(wp) :: p2 !< |
---|
154 | REAL(wp) :: p3 !< |
---|
155 | REAL(wp) :: pt1 !< |
---|
156 | REAL(wp) :: pt2 !< |
---|
157 | REAL(wp) :: pt3 !< |
---|
158 | REAL(wp) :: pt4 !< |
---|
159 | REAL(wp) :: sa1 !< |
---|
160 | REAL(wp) :: sa15 !< |
---|
161 | REAL(wp) :: sa2 !< |
---|
162 | |
---|
163 | |
---|
164 | |
---|
165 | DO i = nxl, nxr |
---|
166 | DO j = nys, nyn |
---|
167 | DO k = nzb+1, nzt |
---|
168 | ! |
---|
169 | !-- Pressure is needed in dbar |
---|
170 | p1 = hyp(k) * 1E-4_wp |
---|
171 | p2 = p1 * p1 |
---|
172 | p3 = p2 * p1 |
---|
173 | |
---|
174 | ! |
---|
175 | !-- Temperature needed in degree Celsius |
---|
176 | pt1 = pt_p(k,j,i) - 273.15_wp |
---|
177 | pt2 = pt1 * pt1 |
---|
178 | pt3 = pt1 * pt2 |
---|
179 | pt4 = pt2 * pt2 |
---|
180 | |
---|
181 | sa1 = sa_p(k,j,i) |
---|
182 | sa15 = sa1 * SQRT( sa1 ) |
---|
183 | sa2 = sa1 * sa1 |
---|
184 | |
---|
185 | pnom = nom(1) + nom(2)*pt1 + nom(3)*pt2 + & |
---|
186 | nom(4)*pt3 + nom(5)*sa1 + nom(6)*sa1*pt1 + & |
---|
187 | nom(7)*sa2 |
---|
188 | |
---|
189 | pden = den(1) + den(2)*pt1 + den(3)*pt2 + & |
---|
190 | den(4)*pt3 + den(5)*pt4 + den(6)*sa1 + & |
---|
191 | den(7)*sa1*pt1 + den(8)*sa1*pt3 + den(9)*sa15 + & |
---|
192 | den(10)*sa15*pt2 |
---|
193 | ! |
---|
194 | !-- Potential density (without pressure terms) |
---|
195 | prho(k,j,i) = pnom / pden |
---|
196 | |
---|
197 | pnom = pnom + nom(8)*p1 + nom(9)*p1*pt2 + & |
---|
198 | nom(10)*p1*sa1 + nom(11)*p2 + nom(12)*p2*pt2 |
---|
199 | |
---|
200 | pden = pden + den(11)*p1 + den(12)*p2*pt3 + & |
---|
201 | den(13)*p3*pt1 |
---|
202 | |
---|
203 | ! |
---|
204 | !-- In-situ density |
---|
205 | rho_ocean(k,j,i) = pnom / pden |
---|
206 | |
---|
207 | ENDDO |
---|
208 | ! |
---|
209 | !-- Neumann conditions are assumed at top boundary |
---|
210 | prho(nzt+1,j,i) = prho(nzt,j,i) |
---|
211 | rho_ocean(nzt+1,j,i) = rho_ocean(nzt,j,i) |
---|
212 | |
---|
213 | ENDDO |
---|
214 | ENDDO |
---|
215 | ! |
---|
216 | !-- Neumann conditions at up/downward-facing surfaces |
---|
217 | !$OMP PARALLEL DO PRIVATE( i, j, k ) |
---|
218 | DO m = 1, bc_h(0)%ns |
---|
219 | i = bc_h(0)%i(m) |
---|
220 | j = bc_h(0)%j(m) |
---|
221 | k = bc_h(0)%k(m) |
---|
222 | prho(k-1,j,i) = prho(k,j,i) |
---|
223 | rho_ocean(k-1,j,i) = rho_ocean(k,j,i) |
---|
224 | ENDDO |
---|
225 | ! |
---|
226 | !-- Downward facing surfaces |
---|
227 | !$OMP PARALLEL DO PRIVATE( i, j, k ) |
---|
228 | DO m = 1, bc_h(1)%ns |
---|
229 | i = bc_h(1)%i(m) |
---|
230 | j = bc_h(1)%j(m) |
---|
231 | k = bc_h(1)%k(m) |
---|
232 | prho(k+1,j,i) = prho(k,j,i) |
---|
233 | rho_ocean(k+1,j,i) = rho_ocean(k,j,i) |
---|
234 | ENDDO |
---|
235 | |
---|
236 | END SUBROUTINE eqn_state_seawater |
---|
237 | |
---|
238 | |
---|
239 | !------------------------------------------------------------------------------! |
---|
240 | ! Description: |
---|
241 | ! ------------ |
---|
242 | !> Call for grid point i,j |
---|
243 | !------------------------------------------------------------------------------! |
---|
244 | SUBROUTINE eqn_state_seawater_ij( i, j ) |
---|
245 | |
---|
246 | USE arrays_3d, & |
---|
247 | ONLY: hyp, prho, pt_p, rho_ocean, sa_p |
---|
248 | |
---|
249 | USE indices, & |
---|
250 | ONLY: nzb, nzt |
---|
251 | |
---|
252 | USE surface_mod, & |
---|
253 | ONLY : bc_h |
---|
254 | |
---|
255 | IMPLICIT NONE |
---|
256 | |
---|
257 | INTEGER(iwp) :: i !< running index x direction |
---|
258 | INTEGER(iwp) :: j !< running index y direction |
---|
259 | INTEGER(iwp) :: k !< running index z direction |
---|
260 | INTEGER(iwp) :: l !< running index of surface type, south- or north-facing wall |
---|
261 | INTEGER(iwp) :: m !< running index surface elements |
---|
262 | INTEGER(iwp) :: surf_e !< End index of surface elements at (j,i)-gridpoint |
---|
263 | INTEGER(iwp) :: surf_s !< Start index of surface elements at (j,i)-gridpoint |
---|
264 | |
---|
265 | REAL(wp) :: pden !< |
---|
266 | REAL(wp) :: pnom !< |
---|
267 | REAL(wp) :: p1 !< |
---|
268 | REAL(wp) :: p2 !< |
---|
269 | REAL(wp) :: p3 !< |
---|
270 | REAL(wp) :: pt1 !< |
---|
271 | REAL(wp) :: pt2 !< |
---|
272 | REAL(wp) :: pt3 !< |
---|
273 | REAL(wp) :: pt4 !< |
---|
274 | REAL(wp) :: sa1 !< |
---|
275 | REAL(wp) :: sa15 !< |
---|
276 | REAL(wp) :: sa2 !< |
---|
277 | |
---|
278 | DO k = nzb+1, nzt |
---|
279 | ! |
---|
280 | !-- Pressure is needed in dbar |
---|
281 | p1 = hyp(k) * 1E-4_wp |
---|
282 | p2 = p1 * p1 |
---|
283 | p3 = p2 * p1 |
---|
284 | |
---|
285 | ! |
---|
286 | !-- Temperature needed in degree Celsius |
---|
287 | pt1 = pt_p(k,j,i) - 273.15_wp |
---|
288 | pt2 = pt1 * pt1 |
---|
289 | pt3 = pt1 * pt2 |
---|
290 | pt4 = pt2 * pt2 |
---|
291 | |
---|
292 | sa1 = sa_p(k,j,i) |
---|
293 | sa15 = sa1 * SQRT( sa1 ) |
---|
294 | sa2 = sa1 * sa1 |
---|
295 | |
---|
296 | pnom = nom(1) + nom(2)*pt1 + nom(3)*pt2 + & |
---|
297 | nom(4)*pt3 + nom(5)*sa1 + nom(6)*sa1*pt1 + & |
---|
298 | nom(7)*sa2 |
---|
299 | |
---|
300 | pden = den(1) + den(2)*pt1 + den(3)*pt2 + & |
---|
301 | den(4)*pt3 + den(5)*pt4 + den(6)*sa1 + & |
---|
302 | den(7)*sa1*pt1 + den(8)*sa1*pt3 + den(9)*sa15 + & |
---|
303 | den(10)*sa15*pt2 |
---|
304 | ! |
---|
305 | !-- Potential density (without pressure terms) |
---|
306 | prho(k,j,i) = pnom / pden |
---|
307 | |
---|
308 | pnom = pnom + nom(8)*p1 + nom(9)*p1*pt2 + & |
---|
309 | nom(10)*p1*sa1 + nom(11)*p2 + nom(12)*p2*pt2 |
---|
310 | pden = pden + den(11)*p1 + den(12)*p2*pt3 + & |
---|
311 | den(13)*p3*pt1 |
---|
312 | |
---|
313 | ! |
---|
314 | !-- In-situ density |
---|
315 | rho_ocean(k,j,i) = pnom / pden |
---|
316 | |
---|
317 | |
---|
318 | ENDDO |
---|
319 | ! |
---|
320 | !-- Neumann conditions at up/downward-facing walls |
---|
321 | surf_s = bc_h(0)%start_index(j,i) |
---|
322 | surf_e = bc_h(0)%end_index(j,i) |
---|
323 | DO m = surf_s, surf_e |
---|
324 | k = bc_h(0)%k(m) |
---|
325 | prho(k-1,j,i) = prho(k,j,i) |
---|
326 | rho_ocean(k-1,j,i) = rho_ocean(k,j,i) |
---|
327 | ENDDO |
---|
328 | ! |
---|
329 | !-- Downward facing surfaces |
---|
330 | surf_s = bc_h(1)%start_index(j,i) |
---|
331 | surf_e = bc_h(1)%end_index(j,i) |
---|
332 | DO m = surf_s, surf_e |
---|
333 | k = bc_h(1)%k(m) |
---|
334 | prho(k+1,j,i) = prho(k,j,i) |
---|
335 | rho_ocean(k+1,j,i) = rho_ocean(k,j,i) |
---|
336 | ENDDO |
---|
337 | ! |
---|
338 | !-- Neumann condition are assumed at top boundary |
---|
339 | prho(nzt+1,j,i) = prho(nzt,j,i) |
---|
340 | rho_ocean(nzt+1,j,i) = rho_ocean(nzt,j,i) |
---|
341 | |
---|
342 | END SUBROUTINE eqn_state_seawater_ij |
---|
343 | |
---|
344 | |
---|
345 | !------------------------------------------------------------------------------! |
---|
346 | ! Description: |
---|
347 | ! ------------ |
---|
348 | !> Equation of state as a function |
---|
349 | !------------------------------------------------------------------------------! |
---|
350 | REAL(wp) FUNCTION eqn_state_seawater_func( p, pt, sa ) |
---|
351 | |
---|
352 | IMPLICIT NONE |
---|
353 | |
---|
354 | REAL(wp) :: p !< |
---|
355 | REAL(wp) :: p1 !< |
---|
356 | REAL(wp) :: p2 !< |
---|
357 | REAL(wp) :: p3 !< |
---|
358 | REAL(wp) :: pt !< |
---|
359 | REAL(wp) :: pt1 !< |
---|
360 | REAL(wp) :: pt2 !< |
---|
361 | REAL(wp) :: pt3 !< |
---|
362 | REAL(wp) :: pt4 !< |
---|
363 | REAL(wp) :: sa !< |
---|
364 | REAL(wp) :: sa15 !< |
---|
365 | REAL(wp) :: sa2 !< |
---|
366 | |
---|
367 | ! |
---|
368 | !-- Pressure is needed in dbar |
---|
369 | p1 = p * 1E-4_wp |
---|
370 | p2 = p1 * p1 |
---|
371 | p3 = p2 * p1 |
---|
372 | |
---|
373 | ! |
---|
374 | !-- Temperature needed in degree Celsius |
---|
375 | pt1 = pt - 273.15_wp |
---|
376 | pt2 = pt1 * pt1 |
---|
377 | pt3 = pt1 * pt2 |
---|
378 | pt4 = pt2 * pt2 |
---|
379 | |
---|
380 | sa15 = sa * SQRT( sa ) |
---|
381 | sa2 = sa * sa |
---|
382 | |
---|
383 | |
---|
384 | eqn_state_seawater_func = & |
---|
385 | ( nom(1) + nom(2)*pt1 + nom(3)*pt2 + nom(4)*pt3 + & |
---|
386 | nom(5)*sa + nom(6)*sa*pt1 + nom(7)*sa2 + nom(8)*p1 + & |
---|
387 | nom(9)*p1*pt2 + nom(10)*p1*sa + nom(11)*p2 + nom(12)*p2*pt2 & |
---|
388 | ) / & |
---|
389 | ( den(1) + den(2)*pt1 + den(3)*pt2 + den(4)*pt3 + & |
---|
390 | den(5)*pt4 + den(6)*sa + den(7)*sa*pt1 + den(8)*sa*pt3 + & |
---|
391 | den(9)*sa15 + den(10)*sa15*pt2 + den(11)*p1 + den(12)*p2*pt3 + & |
---|
392 | den(13)*p3*pt1 & |
---|
393 | ) |
---|
394 | |
---|
395 | |
---|
396 | END FUNCTION eqn_state_seawater_func |
---|
397 | |
---|
398 | END MODULE eqn_state_seawater_mod |
---|