1 | !> @file eqn_state_seawater.f90 |
---|
2 | !------------------------------------------------------------------------------! |
---|
3 | ! This file is part of PALM. |
---|
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-2016 Leibniz Universitaet Hannover |
---|
18 | !------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ----------------- |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: eqn_state_seawater.f90 2001 2016-08-20 18:41:22Z suehring $ |
---|
27 | ! |
---|
28 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
29 | ! Forced header and separation lines into 80 columns |
---|
30 | ! |
---|
31 | ! 1873 2016-04-18 14:50:06Z maronga |
---|
32 | ! Module renamed (removed _mod) |
---|
33 | ! |
---|
34 | ! |
---|
35 | ! 1850 2016-04-08 13:29:27Z maronga |
---|
36 | ! Module renamed |
---|
37 | ! |
---|
38 | ! |
---|
39 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
40 | ! Code annotations made doxygen readable |
---|
41 | ! |
---|
42 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
43 | ! REAL constants provided with KIND-attribute |
---|
44 | ! |
---|
45 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
46 | ! ONLY-attribute added to USE-statements, |
---|
47 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
48 | ! kinds are defined in new module kinds, |
---|
49 | ! revision history before 2012 removed, |
---|
50 | ! comment fields (!:) to be used for variable explanations added to |
---|
51 | ! all variable declaration statements |
---|
52 | ! |
---|
53 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
54 | ! code put under GPL (PALM 3.9) |
---|
55 | ! |
---|
56 | ! 97 2007-06-21 08:23:15Z raasch |
---|
57 | ! Initial revision |
---|
58 | ! |
---|
59 | ! |
---|
60 | ! Description: |
---|
61 | ! ------------ |
---|
62 | !> Equation of state for seawater as a function of potential temperature, |
---|
63 | !> salinity, and pressure. |
---|
64 | !> For coefficients see Jackett et al., 2006: J. Atm. Ocean Tech. |
---|
65 | !> eqn_state_seawater calculates the potential density referred at hyp(0). |
---|
66 | !> eqn_state_seawater_func calculates density. |
---|
67 | !------------------------------------------------------------------------------! |
---|
68 | MODULE eqn_state_seawater_mod |
---|
69 | |
---|
70 | |
---|
71 | USE kinds |
---|
72 | |
---|
73 | IMPLICIT NONE |
---|
74 | |
---|
75 | PRIVATE |
---|
76 | PUBLIC eqn_state_seawater, eqn_state_seawater_func |
---|
77 | |
---|
78 | REAL(wp), DIMENSION(12), PARAMETER :: nom = & |
---|
79 | (/ 9.9984085444849347D2, 7.3471625860981584D0, & |
---|
80 | -5.3211231792841769D-2, 3.6492439109814549D-4, & |
---|
81 | 2.5880571023991390D0, -6.7168282786692354D-3, & |
---|
82 | 1.9203202055760151D-3, 1.1798263740430364D-2, & |
---|
83 | 9.8920219266399117D-8, 4.6996642771754730D-6, & |
---|
84 | -2.5862187075154352D-8, -3.2921414007960662D-12 /) |
---|
85 | !< |
---|
86 | |
---|
87 | REAL(wp), DIMENSION(13), PARAMETER :: den = & |
---|
88 | (/ 1.0D0, 7.2815210113327091D-3, & |
---|
89 | -4.4787265461983921D-5, 3.3851002965802430D-7, & |
---|
90 | 1.3651202389758572D-10, 1.7632126669040377D-3, & |
---|
91 | -8.8066583251206474D-6, -1.8832689434804897D-10, & |
---|
92 | 5.7463776745432097D-6, 1.4716275472242334D-9, & |
---|
93 | 6.7103246285651894D-6, -2.4461698007024582D-17, & |
---|
94 | -9.1534417604289062D-18 /) |
---|
95 | !< |
---|
96 | |
---|
97 | INTERFACE eqn_state_seawater |
---|
98 | MODULE PROCEDURE eqn_state_seawater |
---|
99 | MODULE PROCEDURE eqn_state_seawater_ij |
---|
100 | END INTERFACE eqn_state_seawater |
---|
101 | |
---|
102 | INTERFACE eqn_state_seawater_func |
---|
103 | MODULE PROCEDURE eqn_state_seawater_func |
---|
104 | END INTERFACE eqn_state_seawater_func |
---|
105 | |
---|
106 | CONTAINS |
---|
107 | |
---|
108 | |
---|
109 | !------------------------------------------------------------------------------! |
---|
110 | ! Description: |
---|
111 | ! ------------ |
---|
112 | !> Call for all grid points |
---|
113 | !------------------------------------------------------------------------------! |
---|
114 | SUBROUTINE eqn_state_seawater |
---|
115 | |
---|
116 | USE arrays_3d, & |
---|
117 | ONLY: hyp, prho, pt_p, rho, sa_p |
---|
118 | USE indices, & |
---|
119 | ONLY: nxl, nxr, nyn, nys, nzb_s_inner, nzt |
---|
120 | |
---|
121 | IMPLICIT NONE |
---|
122 | |
---|
123 | INTEGER(iwp) :: i !< |
---|
124 | INTEGER(iwp) :: j !< |
---|
125 | INTEGER(iwp) :: k !< |
---|
126 | |
---|
127 | REAL(wp) :: pden !< |
---|
128 | REAL(wp) :: pnom !< |
---|
129 | REAL(wp) :: p1 !< |
---|
130 | REAL(wp) :: p2 !< |
---|
131 | REAL(wp) :: p3 !< |
---|
132 | REAL(wp) :: pt1 !< |
---|
133 | REAL(wp) :: pt2 !< |
---|
134 | REAL(wp) :: pt3 !< |
---|
135 | REAL(wp) :: pt4 !< |
---|
136 | REAL(wp) :: sa1 !< |
---|
137 | REAL(wp) :: sa15 !< |
---|
138 | REAL(wp) :: sa2 !< |
---|
139 | |
---|
140 | |
---|
141 | |
---|
142 | DO i = nxl, nxr |
---|
143 | DO j = nys, nyn |
---|
144 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
145 | ! |
---|
146 | !-- Pressure is needed in dbar |
---|
147 | p1 = hyp(k) * 1E-4_wp |
---|
148 | p2 = p1 * p1 |
---|
149 | p3 = p2 * p1 |
---|
150 | |
---|
151 | ! |
---|
152 | !-- Temperature needed in degree Celsius |
---|
153 | pt1 = pt_p(k,j,i) - 273.15_wp |
---|
154 | pt2 = pt1 * pt1 |
---|
155 | pt3 = pt1 * pt2 |
---|
156 | pt4 = pt2 * pt2 |
---|
157 | |
---|
158 | sa1 = sa_p(k,j,i) |
---|
159 | sa15 = sa1 * SQRT( sa1 ) |
---|
160 | sa2 = sa1 * sa1 |
---|
161 | |
---|
162 | pnom = nom(1) + nom(2)*pt1 + nom(3)*pt2 + & |
---|
163 | nom(4)*pt3 + nom(5)*sa1 + nom(6)*sa1*pt1 + & |
---|
164 | nom(7)*sa2 |
---|
165 | |
---|
166 | pden = den(1) + den(2)*pt1 + den(3)*pt2 + & |
---|
167 | den(4)*pt3 + den(5)*pt4 + den(6)*sa1 + & |
---|
168 | den(7)*sa1*pt1 + den(8)*sa1*pt3 + den(9)*sa15 + & |
---|
169 | den(10)*sa15*pt2 |
---|
170 | |
---|
171 | ! |
---|
172 | !-- Potential density (without pressure terms) |
---|
173 | prho(k,j,i) = pnom / pden |
---|
174 | |
---|
175 | pnom = pnom + nom(8)*p1 + nom(9)*p1*pt2 + & |
---|
176 | nom(10)*p1*sa1 + nom(11)*p2 + nom(12)*p2*pt2 |
---|
177 | |
---|
178 | pden = pden + den(11)*p1 + den(12)*p2*pt3 + & |
---|
179 | den(13)*p3*pt1 |
---|
180 | |
---|
181 | ! |
---|
182 | !-- In-situ density |
---|
183 | rho(k,j,i) = pnom / pden |
---|
184 | |
---|
185 | ENDDO |
---|
186 | ! |
---|
187 | !-- Neumann conditions are assumed at bottom and top boundary |
---|
188 | prho(nzt+1,j,i) = prho(nzt,j,i) |
---|
189 | prho(nzb_s_inner(j,i),j,i) = prho(nzb_s_inner(j,i)+1,j,i) |
---|
190 | rho(nzt+1,j,i) = rho(nzt,j,i) |
---|
191 | rho(nzb_s_inner(j,i),j,i) = rho(nzb_s_inner(j,i)+1,j,i) |
---|
192 | |
---|
193 | ENDDO |
---|
194 | ENDDO |
---|
195 | |
---|
196 | END SUBROUTINE eqn_state_seawater |
---|
197 | |
---|
198 | |
---|
199 | !------------------------------------------------------------------------------! |
---|
200 | ! Description: |
---|
201 | ! ------------ |
---|
202 | !> Call for grid point i,j |
---|
203 | !------------------------------------------------------------------------------! |
---|
204 | SUBROUTINE eqn_state_seawater_ij( i, j ) |
---|
205 | |
---|
206 | USE arrays_3d, & |
---|
207 | ONLY: hyp, prho, pt_p, rho, sa_p |
---|
208 | |
---|
209 | USE indices, & |
---|
210 | ONLY: nzb_s_inner, nzt |
---|
211 | |
---|
212 | IMPLICIT NONE |
---|
213 | |
---|
214 | INTEGER(iwp) :: i, j, k |
---|
215 | |
---|
216 | REAL(wp) :: pden, pnom, p1, p2, p3, pt1, pt2, pt3, pt4, sa1, sa15, & |
---|
217 | sa2 |
---|
218 | |
---|
219 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
220 | ! |
---|
221 | !-- Pressure is needed in dbar |
---|
222 | p1 = hyp(k) * 1E-4_wp |
---|
223 | p2 = p1 * p1 |
---|
224 | p3 = p2 * p1 |
---|
225 | |
---|
226 | ! |
---|
227 | !-- Temperature needed in degree Celsius |
---|
228 | pt1 = pt_p(k,j,i) - 273.15_wp |
---|
229 | pt2 = pt1 * pt1 |
---|
230 | pt3 = pt1 * pt2 |
---|
231 | pt4 = pt2 * pt2 |
---|
232 | |
---|
233 | sa1 = sa_p(k,j,i) |
---|
234 | sa15 = sa1 * SQRT( sa1 ) |
---|
235 | sa2 = sa1 * sa1 |
---|
236 | |
---|
237 | pnom = nom(1) + nom(2)*pt1 + nom(3)*pt2 + & |
---|
238 | nom(4)*pt3 + nom(5)*sa1 + nom(6)*sa1*pt1 + & |
---|
239 | nom(7)*sa2 |
---|
240 | |
---|
241 | pden = den(1) + den(2)*pt1 + den(3)*pt2 + & |
---|
242 | den(4)*pt3 + den(5)*pt4 + den(6)*sa1 + & |
---|
243 | den(7)*sa1*pt1 + den(8)*sa1*pt3 + den(9)*sa15 + & |
---|
244 | den(10)*sa15*pt2 |
---|
245 | |
---|
246 | ! |
---|
247 | !-- Potential density (without pressure terms) |
---|
248 | prho(k,j,i) = pnom / pden |
---|
249 | |
---|
250 | pnom = pnom + nom(8)*p1 + nom(9)*p1*pt2 + & |
---|
251 | nom(10)*p1*sa1 + nom(11)*p2 + nom(12)*p2*pt2 |
---|
252 | pden = pden + den(11)*p1 + den(12)*p2*pt3 + & |
---|
253 | den(13)*p3*pt1 |
---|
254 | |
---|
255 | ! |
---|
256 | !-- In-situ density |
---|
257 | rho(k,j,i) = pnom / pden |
---|
258 | |
---|
259 | |
---|
260 | ENDDO |
---|
261 | |
---|
262 | ! |
---|
263 | !-- Neumann conditions are assumed at bottom and top boundary |
---|
264 | prho(nzt+1,j,i) = prho(nzt,j,i) |
---|
265 | prho(nzb_s_inner(j,i),j,i) = prho(nzb_s_inner(j,i)+1,j,i) |
---|
266 | rho(nzt+1,j,i) = rho(nzt,j,i) |
---|
267 | rho(nzb_s_inner(j,i),j,i) = rho(nzb_s_inner(j,i)+1,j,i) |
---|
268 | |
---|
269 | END SUBROUTINE eqn_state_seawater_ij |
---|
270 | |
---|
271 | |
---|
272 | !------------------------------------------------------------------------------! |
---|
273 | ! Description: |
---|
274 | ! ------------ |
---|
275 | !> Equation of state as a function |
---|
276 | !------------------------------------------------------------------------------! |
---|
277 | REAL(wp) FUNCTION eqn_state_seawater_func( p, pt, sa ) |
---|
278 | |
---|
279 | IMPLICIT NONE |
---|
280 | |
---|
281 | REAL(wp) :: p !< |
---|
282 | REAL(wp) :: p1 !< |
---|
283 | REAL(wp) :: p2 !< |
---|
284 | REAL(wp) :: p3 !< |
---|
285 | REAL(wp) :: pt !< |
---|
286 | REAL(wp) :: pt1 !< |
---|
287 | REAL(wp) :: pt2 !< |
---|
288 | REAL(wp) :: pt3 !< |
---|
289 | REAL(wp) :: pt4 !< |
---|
290 | REAL(wp) :: sa !< |
---|
291 | REAL(wp) :: sa15 !< |
---|
292 | REAL(wp) :: sa2 !< |
---|
293 | |
---|
294 | ! |
---|
295 | !-- Pressure is needed in dbar |
---|
296 | p1 = p * 1E-4_wp |
---|
297 | p2 = p1 * p1 |
---|
298 | p3 = p2 * p1 |
---|
299 | |
---|
300 | ! |
---|
301 | !-- Temperature needed in degree Celsius |
---|
302 | pt1 = pt - 273.15_wp |
---|
303 | pt2 = pt1 * pt1 |
---|
304 | pt3 = pt1 * pt2 |
---|
305 | pt4 = pt2 * pt2 |
---|
306 | |
---|
307 | sa15 = sa * SQRT( sa ) |
---|
308 | sa2 = sa * sa |
---|
309 | |
---|
310 | |
---|
311 | eqn_state_seawater_func = & |
---|
312 | ( nom(1) + nom(2)*pt1 + nom(3)*pt2 + nom(4)*pt3 + & |
---|
313 | nom(5)*sa + nom(6)*sa*pt1 + nom(7)*sa2 + nom(8)*p1 + & |
---|
314 | nom(9)*p1*pt2 + nom(10)*p1*sa + nom(11)*p2 + nom(12)*p2*pt2 & |
---|
315 | ) / & |
---|
316 | ( den(1) + den(2)*pt1 + den(3)*pt2 + den(4)*pt3 + & |
---|
317 | den(5)*pt4 + den(6)*sa + den(7)*sa*pt1 + den(8)*sa*pt3 + & |
---|
318 | den(9)*sa15 + den(10)*sa15*pt2 + den(11)*p1 + den(12)*p2*pt3 + & |
---|
319 | den(13)*p3*pt1 & |
---|
320 | ) |
---|
321 | |
---|
322 | |
---|
323 | END FUNCTION eqn_state_seawater_func |
---|
324 | |
---|
325 | END MODULE eqn_state_seawater_mod |
---|