[1873] | 1 | !> @file eqn_state_seawater.f90 |
---|
[1320] | 2 | !------------------------------------------------------------------------------! |
---|
[2696] | 3 | ! This file is part of the PALM model system. |
---|
[1036] | 4 | ! |
---|
[2000] | 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. |
---|
[1036] | 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 | ! |
---|
[2718] | 17 | ! Copyright 1997-2018 Leibniz Universitaet Hannover |
---|
[1320] | 18 | !------------------------------------------------------------------------------! |
---|
[1036] | 19 | ! |
---|
[484] | 20 | ! Current revisions: |
---|
[96] | 21 | ! ----------------- |
---|
[1354] | 22 | ! |
---|
[2233] | 23 | ! |
---|
[1321] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: eqn_state_seawater.f90 2718 2018-01-02 08:49:38Z Giersch $ |
---|
[2716] | 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 |
---|
[2369] | 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 |
---|
[1321] | 37 | ! |
---|
[2233] | 38 | ! 2232 2017-05-30 17:47:52Z suehring |
---|
| 39 | ! Adjustments to new topography and surface concept |
---|
| 40 | ! |
---|
[2032] | 41 | ! 2031 2016-10-21 15:11:58Z knoop |
---|
| 42 | ! renamed variable rho to rho_ocean |
---|
| 43 | ! |
---|
[2001] | 44 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
| 45 | ! Forced header and separation lines into 80 columns |
---|
| 46 | ! |
---|
[1874] | 47 | ! 1873 2016-04-18 14:50:06Z maronga |
---|
| 48 | ! Module renamed (removed _mod) |
---|
| 49 | ! |
---|
| 50 | ! |
---|
[1851] | 51 | ! 1850 2016-04-08 13:29:27Z maronga |
---|
| 52 | ! Module renamed |
---|
| 53 | ! |
---|
| 54 | ! |
---|
[1683] | 55 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
| 56 | ! Code annotations made doxygen readable |
---|
| 57 | ! |
---|
[1354] | 58 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
| 59 | ! REAL constants provided with KIND-attribute |
---|
| 60 | ! |
---|
[1321] | 61 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 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 |
---|
[96] | 68 | ! |
---|
[1037] | 69 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 70 | ! code put under GPL (PALM 3.9) |
---|
| 71 | ! |
---|
[98] | 72 | ! 97 2007-06-21 08:23:15Z raasch |
---|
[96] | 73 | ! Initial revision |
---|
| 74 | ! |
---|
| 75 | ! |
---|
| 76 | ! Description: |
---|
| 77 | ! ------------ |
---|
[1682] | 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. |
---|
[96] | 83 | !------------------------------------------------------------------------------! |
---|
[1682] | 84 | MODULE eqn_state_seawater_mod |
---|
| 85 | |
---|
[1320] | 86 | |
---|
| 87 | USE kinds |
---|
[96] | 88 | |
---|
| 89 | IMPLICIT NONE |
---|
| 90 | |
---|
| 91 | PRIVATE |
---|
| 92 | PUBLIC eqn_state_seawater, eqn_state_seawater_func |
---|
| 93 | |
---|
[1320] | 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 /) |
---|
[1682] | 101 | !< |
---|
[96] | 102 | |
---|
[1320] | 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 /) |
---|
[1682] | 111 | !< |
---|
[96] | 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 | !------------------------------------------------------------------------------! |
---|
[1682] | 126 | ! Description: |
---|
| 127 | ! ------------ |
---|
| 128 | !> Call for all grid points |
---|
[96] | 129 | !------------------------------------------------------------------------------! |
---|
| 130 | SUBROUTINE eqn_state_seawater |
---|
| 131 | |
---|
[1320] | 132 | USE arrays_3d, & |
---|
[2031] | 133 | ONLY: hyp, prho, pt_p, rho_ocean, sa_p |
---|
[1320] | 134 | USE indices, & |
---|
[2369] | 135 | ONLY: nxl, nxr, nyn, nys, nzb, nzt |
---|
[96] | 136 | |
---|
[2232] | 137 | USE surface_mod, & |
---|
| 138 | ONLY : bc_h |
---|
| 139 | |
---|
[96] | 140 | IMPLICIT NONE |
---|
| 141 | |
---|
[2232] | 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 |
---|
[96] | 149 | |
---|
[2232] | 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 !< |
---|
[1320] | 162 | |
---|
| 163 | |
---|
[96] | 164 | |
---|
| 165 | DO i = nxl, nxr |
---|
| 166 | DO j = nys, nyn |
---|
[2232] | 167 | DO k = nzb+1, nzt |
---|
[96] | 168 | ! |
---|
| 169 | !-- Pressure is needed in dbar |
---|
[1353] | 170 | p1 = hyp(k) * 1E-4_wp |
---|
[96] | 171 | p2 = p1 * p1 |
---|
| 172 | p3 = p2 * p1 |
---|
| 173 | |
---|
| 174 | ! |
---|
| 175 | !-- Temperature needed in degree Celsius |
---|
[1353] | 176 | pt1 = pt_p(k,j,i) - 273.15_wp |
---|
[96] | 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 | |
---|
[1320] | 185 | pnom = nom(1) + nom(2)*pt1 + nom(3)*pt2 + & |
---|
| 186 | nom(4)*pt3 + nom(5)*sa1 + nom(6)*sa1*pt1 + & |
---|
[388] | 187 | nom(7)*sa2 |
---|
[96] | 188 | |
---|
[1320] | 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 + & |
---|
[388] | 192 | den(10)*sa15*pt2 |
---|
| 193 | ! |
---|
| 194 | !-- Potential density (without pressure terms) |
---|
[2369] | 195 | prho(k,j,i) = pnom / pden |
---|
[388] | 196 | |
---|
[1320] | 197 | pnom = pnom + nom(8)*p1 + nom(9)*p1*pt2 + & |
---|
[388] | 198 | nom(10)*p1*sa1 + nom(11)*p2 + nom(12)*p2*pt2 |
---|
| 199 | |
---|
[1320] | 200 | pden = pden + den(11)*p1 + den(12)*p2*pt3 + & |
---|
[388] | 201 | den(13)*p3*pt1 |
---|
| 202 | |
---|
| 203 | ! |
---|
| 204 | !-- In-situ density |
---|
[2369] | 205 | rho_ocean(k,j,i) = pnom / pden |
---|
[388] | 206 | |
---|
[96] | 207 | ENDDO |
---|
[97] | 208 | ! |
---|
[2232] | 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) |
---|
[388] | 212 | |
---|
[96] | 213 | ENDDO |
---|
| 214 | ENDDO |
---|
[2232] | 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 |
---|
[96] | 235 | |
---|
| 236 | END SUBROUTINE eqn_state_seawater |
---|
| 237 | |
---|
| 238 | |
---|
| 239 | !------------------------------------------------------------------------------! |
---|
[1682] | 240 | ! Description: |
---|
| 241 | ! ------------ |
---|
| 242 | !> Call for grid point i,j |
---|
[96] | 243 | !------------------------------------------------------------------------------! |
---|
| 244 | SUBROUTINE eqn_state_seawater_ij( i, j ) |
---|
| 245 | |
---|
[1320] | 246 | USE arrays_3d, & |
---|
[2031] | 247 | ONLY: hyp, prho, pt_p, rho_ocean, sa_p |
---|
[1320] | 248 | |
---|
| 249 | USE indices, & |
---|
[2369] | 250 | ONLY: nzb, nzt |
---|
[96] | 251 | |
---|
[2232] | 252 | USE surface_mod, & |
---|
| 253 | ONLY : bc_h |
---|
| 254 | |
---|
[96] | 255 | IMPLICIT NONE |
---|
| 256 | |
---|
[2232] | 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 |
---|
[96] | 264 | |
---|
[2232] | 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 !< |
---|
[96] | 277 | |
---|
[2232] | 278 | DO k = nzb+1, nzt |
---|
[96] | 279 | ! |
---|
| 280 | !-- Pressure is needed in dbar |
---|
[1353] | 281 | p1 = hyp(k) * 1E-4_wp |
---|
[96] | 282 | p2 = p1 * p1 |
---|
| 283 | p3 = p2 * p1 |
---|
| 284 | |
---|
| 285 | ! |
---|
| 286 | !-- Temperature needed in degree Celsius |
---|
[1353] | 287 | pt1 = pt_p(k,j,i) - 273.15_wp |
---|
[96] | 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 | |
---|
[1320] | 296 | pnom = nom(1) + nom(2)*pt1 + nom(3)*pt2 + & |
---|
| 297 | nom(4)*pt3 + nom(5)*sa1 + nom(6)*sa1*pt1 + & |
---|
[388] | 298 | nom(7)*sa2 |
---|
| 299 | |
---|
[1320] | 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 + & |
---|
[388] | 303 | den(10)*sa15*pt2 |
---|
| 304 | ! |
---|
| 305 | !-- Potential density (without pressure terms) |
---|
[2369] | 306 | prho(k,j,i) = pnom / pden |
---|
[388] | 307 | |
---|
[1320] | 308 | pnom = pnom + nom(8)*p1 + nom(9)*p1*pt2 + & |
---|
[388] | 309 | nom(10)*p1*sa1 + nom(11)*p2 + nom(12)*p2*pt2 |
---|
[1320] | 310 | pden = pden + den(11)*p1 + den(12)*p2*pt3 + & |
---|
[388] | 311 | den(13)*p3*pt1 |
---|
| 312 | |
---|
| 313 | ! |
---|
| 314 | !-- In-situ density |
---|
[2369] | 315 | rho_ocean(k,j,i) = pnom / pden |
---|
[388] | 316 | |
---|
| 317 | |
---|
[96] | 318 | ENDDO |
---|
[97] | 319 | ! |
---|
[2232] | 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) |
---|
[96] | 341 | |
---|
| 342 | END SUBROUTINE eqn_state_seawater_ij |
---|
| 343 | |
---|
| 344 | |
---|
| 345 | !------------------------------------------------------------------------------! |
---|
[1682] | 346 | ! Description: |
---|
| 347 | ! ------------ |
---|
| 348 | !> Equation of state as a function |
---|
[96] | 349 | !------------------------------------------------------------------------------! |
---|
[1320] | 350 | REAL(wp) FUNCTION eqn_state_seawater_func( p, pt, sa ) |
---|
[96] | 351 | |
---|
| 352 | IMPLICIT NONE |
---|
| 353 | |
---|
[1682] | 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 !< |
---|
[96] | 366 | |
---|
| 367 | ! |
---|
| 368 | !-- Pressure is needed in dbar |
---|
[1353] | 369 | p1 = p * 1E-4_wp |
---|
[96] | 370 | p2 = p1 * p1 |
---|
| 371 | p3 = p2 * p1 |
---|
| 372 | |
---|
| 373 | ! |
---|
| 374 | !-- Temperature needed in degree Celsius |
---|
[1353] | 375 | pt1 = pt - 273.15_wp |
---|
[96] | 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 |
---|