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