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