[96] | 1 | MODULE eqn_state_seawater_mod |
---|
| 2 | |
---|
[1036] | 3 | !--------------------------------------------------------------------------------! |
---|
| 4 | ! This file is part of PALM. |
---|
| 5 | ! |
---|
| 6 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
| 7 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
| 8 | ! either version 3 of the License, or (at your option) any later 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-2012 Leibniz University Hannover |
---|
| 18 | !--------------------------------------------------------------------------------! |
---|
| 19 | ! |
---|
[484] | 20 | ! Current revisions: |
---|
[96] | 21 | ! ----------------- |
---|
[392] | 22 | ! |
---|
[96] | 23 | ! |
---|
| 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
[97] | 26 | ! $Id: eqn_state_seawater.f90 1037 2012-10-22 14:10:22Z maronga $ |
---|
[96] | 27 | ! |
---|
[1037] | 28 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 29 | ! code put under GPL (PALM 3.9) |
---|
| 30 | ! |
---|
[392] | 31 | ! 388 2009-09-23 09:40:33Z raasch |
---|
| 32 | ! Potential density is additionally calculated in eqn_state_seawater, |
---|
| 33 | ! first constant in array den also defined as type double. |
---|
| 34 | ! |
---|
[98] | 35 | ! 97 2007-06-21 08:23:15Z raasch |
---|
[96] | 36 | ! Initial revision |
---|
| 37 | ! |
---|
| 38 | ! |
---|
| 39 | ! Description: |
---|
| 40 | ! ------------ |
---|
| 41 | ! Equation of state for seawater as a function of potential temperature, |
---|
| 42 | ! salinity, and pressure. |
---|
| 43 | ! For coefficients see Jackett et al., 2006: J. Atm. Ocean Tech. |
---|
[97] | 44 | ! eqn_state_seawater calculates the potential density referred at hyp(0). |
---|
| 45 | ! eqn_state_seawater_func calculates density. |
---|
[96] | 46 | !------------------------------------------------------------------------------! |
---|
| 47 | |
---|
| 48 | IMPLICIT NONE |
---|
| 49 | |
---|
| 50 | PRIVATE |
---|
| 51 | PUBLIC eqn_state_seawater, eqn_state_seawater_func |
---|
| 52 | |
---|
| 53 | REAL, DIMENSION(12), PARAMETER :: nom = & |
---|
| 54 | (/ 9.9984085444849347D2, 7.3471625860981584D0, & |
---|
| 55 | -5.3211231792841769D-2, 3.6492439109814549D-4, & |
---|
| 56 | 2.5880571023991390D0, -6.7168282786692354D-3, & |
---|
| 57 | 1.9203202055760151D-3, 1.1798263740430364D-2, & |
---|
| 58 | 9.8920219266399117D-8, 4.6996642771754730D-6, & |
---|
| 59 | -2.5862187075154352D-8, -3.2921414007960662D-12 /) |
---|
| 60 | |
---|
| 61 | REAL, DIMENSION(13), PARAMETER :: den = & |
---|
[231] | 62 | (/ 1.0D0, 7.2815210113327091D-3, & |
---|
[96] | 63 | -4.4787265461983921D-5, 3.3851002965802430D-7, & |
---|
| 64 | 1.3651202389758572D-10, 1.7632126669040377D-3, & |
---|
| 65 | -8.8066583251206474D-6, -1.8832689434804897D-10, & |
---|
| 66 | 5.7463776745432097D-6, 1.4716275472242334D-9, & |
---|
| 67 | 6.7103246285651894D-6, -2.4461698007024582D-17, & |
---|
| 68 | -9.1534417604289062D-18 /) |
---|
| 69 | |
---|
| 70 | INTERFACE eqn_state_seawater |
---|
| 71 | MODULE PROCEDURE eqn_state_seawater |
---|
| 72 | MODULE PROCEDURE eqn_state_seawater_ij |
---|
| 73 | END INTERFACE eqn_state_seawater |
---|
| 74 | |
---|
| 75 | INTERFACE eqn_state_seawater_func |
---|
| 76 | MODULE PROCEDURE eqn_state_seawater_func |
---|
| 77 | END INTERFACE eqn_state_seawater_func |
---|
| 78 | |
---|
| 79 | CONTAINS |
---|
| 80 | |
---|
| 81 | |
---|
| 82 | !------------------------------------------------------------------------------! |
---|
| 83 | ! Call for all grid points |
---|
| 84 | !------------------------------------------------------------------------------! |
---|
| 85 | SUBROUTINE eqn_state_seawater |
---|
| 86 | |
---|
| 87 | USE arrays_3d |
---|
| 88 | USE indices |
---|
| 89 | |
---|
| 90 | IMPLICIT NONE |
---|
| 91 | |
---|
| 92 | INTEGER :: i, j, k |
---|
| 93 | |
---|
[388] | 94 | REAL :: pden, pnom, p1, p2, p3, pt1, pt2, pt3, pt4, sa1, sa15, sa2 |
---|
[96] | 95 | |
---|
| 96 | DO i = nxl, nxr |
---|
| 97 | DO j = nys, nyn |
---|
[97] | 98 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
[96] | 99 | ! |
---|
| 100 | !-- Pressure is needed in dbar |
---|
[336] | 101 | p1 = hyp(k) * 1E-4 |
---|
[96] | 102 | p2 = p1 * p1 |
---|
| 103 | p3 = p2 * p1 |
---|
| 104 | |
---|
| 105 | ! |
---|
| 106 | !-- Temperature needed in degree Celsius |
---|
| 107 | pt1 = pt_p(k,j,i) - 273.15 |
---|
| 108 | pt2 = pt1 * pt1 |
---|
| 109 | pt3 = pt1 * pt2 |
---|
| 110 | pt4 = pt2 * pt2 |
---|
| 111 | |
---|
| 112 | sa1 = sa_p(k,j,i) |
---|
| 113 | sa15 = sa1 * SQRT( sa1 ) |
---|
| 114 | sa2 = sa1 * sa1 |
---|
| 115 | |
---|
[388] | 116 | pnom = nom(1) + nom(2)*pt1 + nom(3)*pt2 + & |
---|
| 117 | nom(4)*pt3 + nom(5)*sa1 + nom(6)*sa1*pt1 + & |
---|
| 118 | nom(7)*sa2 |
---|
[96] | 119 | |
---|
[388] | 120 | pden = den(1) + den(2)*pt1 + den(3)*pt2 + & |
---|
| 121 | den(4)*pt3 + den(5)*pt4 + den(6)*sa1 + & |
---|
| 122 | den(7)*sa1*pt1 + den(8)*sa1*pt3 + den(9)*sa15 + & |
---|
| 123 | den(10)*sa15*pt2 |
---|
| 124 | |
---|
| 125 | ! |
---|
| 126 | !-- Potential density (without pressure terms) |
---|
| 127 | prho(k,j,i) = pnom / pden |
---|
| 128 | |
---|
| 129 | pnom = pnom + nom(8)*p1 + nom(9)*p1*pt2 + & |
---|
| 130 | nom(10)*p1*sa1 + nom(11)*p2 + nom(12)*p2*pt2 |
---|
| 131 | |
---|
| 132 | pden = pden + den(11)*p1 + den(12)*p2*pt3 + & |
---|
| 133 | den(13)*p3*pt1 |
---|
| 134 | |
---|
| 135 | ! |
---|
| 136 | !-- In-situ density |
---|
| 137 | rho(k,j,i) = pnom / pden |
---|
| 138 | |
---|
[96] | 139 | ENDDO |
---|
[97] | 140 | ! |
---|
| 141 | !-- Neumann conditions are assumed at bottom and top boundary |
---|
[388] | 142 | prho(nzt+1,j,i) = prho(nzt,j,i) |
---|
| 143 | prho(nzb_s_inner(j,i),j,i) = prho(nzb_s_inner(j,i)+1,j,i) |
---|
| 144 | rho(nzt+1,j,i) = rho(nzt,j,i) |
---|
| 145 | rho(nzb_s_inner(j,i),j,i) = rho(nzb_s_inner(j,i)+1,j,i) |
---|
| 146 | |
---|
[96] | 147 | ENDDO |
---|
| 148 | ENDDO |
---|
| 149 | |
---|
| 150 | END SUBROUTINE eqn_state_seawater |
---|
| 151 | |
---|
| 152 | |
---|
| 153 | !------------------------------------------------------------------------------! |
---|
| 154 | ! Call for grid point i,j |
---|
| 155 | !------------------------------------------------------------------------------! |
---|
| 156 | SUBROUTINE eqn_state_seawater_ij( i, j ) |
---|
| 157 | |
---|
| 158 | USE arrays_3d |
---|
| 159 | USE indices |
---|
| 160 | |
---|
| 161 | IMPLICIT NONE |
---|
| 162 | |
---|
| 163 | INTEGER :: i, j, k |
---|
| 164 | |
---|
[388] | 165 | REAL :: pden, pnom, p1, p2, p3, pt1, pt2, pt3, pt4, sa1, sa15, sa2 |
---|
[96] | 166 | |
---|
[97] | 167 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
[96] | 168 | ! |
---|
| 169 | !-- Pressure is needed in dbar |
---|
[336] | 170 | p1 = hyp(k) * 1E-4 |
---|
[96] | 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 |
---|
| 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 | |
---|
[388] | 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 | ! |
---|
| 195 | !-- Potential density (without pressure terms) |
---|
| 196 | prho(k,j,i) = pnom / pden |
---|
| 197 | |
---|
| 198 | pnom = pnom + nom(8)*p1 + nom(9)*p1*pt2 + & |
---|
| 199 | nom(10)*p1*sa1 + nom(11)*p2 + nom(12)*p2*pt2 |
---|
| 200 | pden = pden + den(11)*p1 + den(12)*p2*pt3 + & |
---|
| 201 | den(13)*p3*pt1 |
---|
| 202 | |
---|
| 203 | ! |
---|
| 204 | !-- In-situ density |
---|
| 205 | rho(k,j,i) = pnom / pden |
---|
| 206 | |
---|
| 207 | |
---|
[96] | 208 | ENDDO |
---|
[388] | 209 | |
---|
[97] | 210 | ! |
---|
| 211 | !-- Neumann conditions are assumed at bottom and top boundary |
---|
[388] | 212 | prho(nzt+1,j,i) = prho(nzt,j,i) |
---|
| 213 | prho(nzb_s_inner(j,i),j,i) = prho(nzb_s_inner(j,i)+1,j,i) |
---|
| 214 | rho(nzt+1,j,i) = rho(nzt,j,i) |
---|
| 215 | rho(nzb_s_inner(j,i),j,i) = rho(nzb_s_inner(j,i)+1,j,i) |
---|
[96] | 216 | |
---|
| 217 | END SUBROUTINE eqn_state_seawater_ij |
---|
| 218 | |
---|
| 219 | |
---|
| 220 | !------------------------------------------------------------------------------! |
---|
| 221 | ! Equation of state as a function |
---|
| 222 | !------------------------------------------------------------------------------! |
---|
| 223 | REAL FUNCTION eqn_state_seawater_func( p, pt, sa ) |
---|
| 224 | |
---|
| 225 | IMPLICIT NONE |
---|
| 226 | |
---|
| 227 | REAL :: p, p1, p2, p3, pt, pt1, pt2, pt3, pt4, sa, sa15, sa2 |
---|
| 228 | |
---|
| 229 | ! |
---|
| 230 | !-- Pressure is needed in dbar |
---|
| 231 | p1 = p * 1E-4 |
---|
| 232 | p2 = p1 * p1 |
---|
| 233 | p3 = p2 * p1 |
---|
| 234 | |
---|
| 235 | ! |
---|
| 236 | !-- Temperature needed in degree Celsius |
---|
| 237 | pt1 = pt - 273.15 |
---|
| 238 | pt2 = pt1 * pt1 |
---|
| 239 | pt3 = pt1 * pt2 |
---|
| 240 | pt4 = pt2 * pt2 |
---|
| 241 | |
---|
| 242 | sa15 = sa * SQRT( sa ) |
---|
| 243 | sa2 = sa * sa |
---|
| 244 | |
---|
| 245 | |
---|
| 246 | eqn_state_seawater_func = & |
---|
| 247 | ( nom(1) + nom(2)*pt1 + nom(3)*pt2 + nom(4)*pt3 + & |
---|
| 248 | nom(5)*sa + nom(6)*sa*pt1 + nom(7)*sa2 + nom(8)*p1 + & |
---|
| 249 | nom(9)*p1*pt2 + nom(10)*p1*sa + nom(11)*p2 + nom(12)*p2*pt2 & |
---|
| 250 | ) / & |
---|
| 251 | ( den(1) + den(2)*pt1 + den(3)*pt2 + den(4)*pt3 + & |
---|
| 252 | den(5)*pt4 + den(6)*sa + den(7)*sa*pt1 + den(8)*sa*pt3 + & |
---|
| 253 | den(9)*sa15 + den(10)*sa15*pt2 + den(11)*p1 + den(12)*p2*pt3 + & |
---|
| 254 | den(13)*p3*pt1 & |
---|
| 255 | ) |
---|
| 256 | |
---|
| 257 | |
---|
| 258 | END FUNCTION eqn_state_seawater_func |
---|
| 259 | |
---|
| 260 | END MODULE eqn_state_seawater_mod |
---|