MODULE eqn_state_seawater_mod !--------------------------------------------------------------------------------! ! This file is part of PALM. ! ! PALM is free software: you can redistribute it and/or modify it under the terms ! of the GNU General Public License as published by the Free Software Foundation, ! either version 3 of the License, or (at your option) any later version. ! ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License along with ! PALM. If not, see . ! ! Copyright 1997-2012 Leibniz University Hannover !--------------------------------------------------------------------------------! ! ! Current revisions: ! ----------------- ! ! ! Former revisions: ! ----------------- ! $Id: eqn_state_seawater.f90 1037 2012-10-22 14:10:22Z witha $ ! ! 1036 2012-10-22 13:43:42Z raasch ! code put under GPL (PALM 3.9) ! ! 388 2009-09-23 09:40:33Z raasch ! Potential density is additionally calculated in eqn_state_seawater, ! first constant in array den also defined as type double. ! ! 97 2007-06-21 08:23:15Z raasch ! Initial revision ! ! ! Description: ! ------------ ! Equation of state for seawater as a function of potential temperature, ! salinity, and pressure. ! For coefficients see Jackett et al., 2006: J. Atm. Ocean Tech. ! eqn_state_seawater calculates the potential density referred at hyp(0). ! eqn_state_seawater_func calculates density. !------------------------------------------------------------------------------! IMPLICIT NONE PRIVATE PUBLIC eqn_state_seawater, eqn_state_seawater_func REAL, DIMENSION(12), PARAMETER :: nom = & (/ 9.9984085444849347D2, 7.3471625860981584D0, & -5.3211231792841769D-2, 3.6492439109814549D-4, & 2.5880571023991390D0, -6.7168282786692354D-3, & 1.9203202055760151D-3, 1.1798263740430364D-2, & 9.8920219266399117D-8, 4.6996642771754730D-6, & -2.5862187075154352D-8, -3.2921414007960662D-12 /) REAL, DIMENSION(13), PARAMETER :: den = & (/ 1.0D0, 7.2815210113327091D-3, & -4.4787265461983921D-5, 3.3851002965802430D-7, & 1.3651202389758572D-10, 1.7632126669040377D-3, & -8.8066583251206474D-6, -1.8832689434804897D-10, & 5.7463776745432097D-6, 1.4716275472242334D-9, & 6.7103246285651894D-6, -2.4461698007024582D-17, & -9.1534417604289062D-18 /) INTERFACE eqn_state_seawater MODULE PROCEDURE eqn_state_seawater MODULE PROCEDURE eqn_state_seawater_ij END INTERFACE eqn_state_seawater INTERFACE eqn_state_seawater_func MODULE PROCEDURE eqn_state_seawater_func END INTERFACE eqn_state_seawater_func CONTAINS !------------------------------------------------------------------------------! ! Call for all grid points !------------------------------------------------------------------------------! SUBROUTINE eqn_state_seawater USE arrays_3d USE indices IMPLICIT NONE INTEGER :: i, j, k REAL :: pden, pnom, p1, p2, p3, pt1, pt2, pt3, pt4, sa1, sa15, sa2 DO i = nxl, nxr DO j = nys, nyn DO k = nzb_s_inner(j,i)+1, nzt ! !-- Pressure is needed in dbar p1 = hyp(k) * 1E-4 p2 = p1 * p1 p3 = p2 * p1 ! !-- Temperature needed in degree Celsius pt1 = pt_p(k,j,i) - 273.15 pt2 = pt1 * pt1 pt3 = pt1 * pt2 pt4 = pt2 * pt2 sa1 = sa_p(k,j,i) sa15 = sa1 * SQRT( sa1 ) sa2 = sa1 * sa1 pnom = nom(1) + nom(2)*pt1 + nom(3)*pt2 + & nom(4)*pt3 + nom(5)*sa1 + nom(6)*sa1*pt1 + & nom(7)*sa2 pden = den(1) + den(2)*pt1 + den(3)*pt2 + & den(4)*pt3 + den(5)*pt4 + den(6)*sa1 + & den(7)*sa1*pt1 + den(8)*sa1*pt3 + den(9)*sa15 + & den(10)*sa15*pt2 ! !-- Potential density (without pressure terms) prho(k,j,i) = pnom / pden pnom = pnom + nom(8)*p1 + nom(9)*p1*pt2 + & nom(10)*p1*sa1 + nom(11)*p2 + nom(12)*p2*pt2 pden = pden + den(11)*p1 + den(12)*p2*pt3 + & den(13)*p3*pt1 ! !-- In-situ density rho(k,j,i) = pnom / pden ENDDO ! !-- Neumann conditions are assumed at bottom and top boundary prho(nzt+1,j,i) = prho(nzt,j,i) prho(nzb_s_inner(j,i),j,i) = prho(nzb_s_inner(j,i)+1,j,i) rho(nzt+1,j,i) = rho(nzt,j,i) rho(nzb_s_inner(j,i),j,i) = rho(nzb_s_inner(j,i)+1,j,i) ENDDO ENDDO END SUBROUTINE eqn_state_seawater !------------------------------------------------------------------------------! ! Call for grid point i,j !------------------------------------------------------------------------------! SUBROUTINE eqn_state_seawater_ij( i, j ) USE arrays_3d USE indices IMPLICIT NONE INTEGER :: i, j, k REAL :: pden, pnom, p1, p2, p3, pt1, pt2, pt3, pt4, sa1, sa15, sa2 DO k = nzb_s_inner(j,i)+1, nzt ! !-- Pressure is needed in dbar p1 = hyp(k) * 1E-4 p2 = p1 * p1 p3 = p2 * p1 ! !-- Temperature needed in degree Celsius pt1 = pt_p(k,j,i) - 273.15 pt2 = pt1 * pt1 pt3 = pt1 * pt2 pt4 = pt2 * pt2 sa1 = sa_p(k,j,i) sa15 = sa1 * SQRT( sa1 ) sa2 = sa1 * sa1 pnom = nom(1) + nom(2)*pt1 + nom(3)*pt2 + & nom(4)*pt3 + nom(5)*sa1 + nom(6)*sa1*pt1 + & nom(7)*sa2 pden = den(1) + den(2)*pt1 + den(3)*pt2 + & den(4)*pt3 + den(5)*pt4 + den(6)*sa1 + & den(7)*sa1*pt1 + den(8)*sa1*pt3 + den(9)*sa15 + & den(10)*sa15*pt2 ! !-- Potential density (without pressure terms) prho(k,j,i) = pnom / pden pnom = pnom + nom(8)*p1 + nom(9)*p1*pt2 + & nom(10)*p1*sa1 + nom(11)*p2 + nom(12)*p2*pt2 pden = pden + den(11)*p1 + den(12)*p2*pt3 + & den(13)*p3*pt1 ! !-- In-situ density rho(k,j,i) = pnom / pden ENDDO ! !-- Neumann conditions are assumed at bottom and top boundary prho(nzt+1,j,i) = prho(nzt,j,i) prho(nzb_s_inner(j,i),j,i) = prho(nzb_s_inner(j,i)+1,j,i) rho(nzt+1,j,i) = rho(nzt,j,i) rho(nzb_s_inner(j,i),j,i) = rho(nzb_s_inner(j,i)+1,j,i) END SUBROUTINE eqn_state_seawater_ij !------------------------------------------------------------------------------! ! Equation of state as a function !------------------------------------------------------------------------------! REAL FUNCTION eqn_state_seawater_func( p, pt, sa ) IMPLICIT NONE REAL :: p, p1, p2, p3, pt, pt1, pt2, pt3, pt4, sa, sa15, sa2 ! !-- Pressure is needed in dbar p1 = p * 1E-4 p2 = p1 * p1 p3 = p2 * p1 ! !-- Temperature needed in degree Celsius pt1 = pt - 273.15 pt2 = pt1 * pt1 pt3 = pt1 * pt2 pt4 = pt2 * pt2 sa15 = sa * SQRT( sa ) sa2 = sa * sa eqn_state_seawater_func = & ( nom(1) + nom(2)*pt1 + nom(3)*pt2 + nom(4)*pt3 + & nom(5)*sa + nom(6)*sa*pt1 + nom(7)*sa2 + nom(8)*p1 + & nom(9)*p1*pt2 + nom(10)*p1*sa + nom(11)*p2 + nom(12)*p2*pt2 & ) / & ( den(1) + den(2)*pt1 + den(3)*pt2 + den(4)*pt3 + & den(5)*pt4 + den(6)*sa + den(7)*sa*pt1 + den(8)*sa*pt3 + & den(9)*sa15 + den(10)*sa15*pt2 + den(11)*p1 + den(12)*p2*pt3 + & den(13)*p3*pt1 & ) END FUNCTION eqn_state_seawater_func END MODULE eqn_state_seawater_mod