MODULE eqn_state_seawater_mod !------------------------------------------------------------------------------! ! Actual revisions: ! ----------------- ! First constant in array den also defined as type double ! ! Former revisions: ! ----------------- ! $Id: eqn_state_seawater.f90 336 2009-06-10 11:19:35Z letzel $ ! ! 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 :: 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(0) * 1E-4 ! p1 = 0.0 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 rho(k,j,i) = & ( nom(1) + nom(2)*pt1 + nom(3)*pt2 + & nom(4)*pt3 + nom(5)*sa1 + nom(6)*sa1*pt1 + & nom(7)*sa2 + nom(8)*p1 + nom(9)*p1*pt2 + & nom(10)*p1*sa1 + nom(11)*p2 + nom(12)*p2*pt2 & ) / & ( 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 + den(11)*p1 + den(12)*p2*pt3 + & den(13)*p3*pt1 & ) ENDDO ! !-- Neumann conditions are assumed at bottom and top boundary 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 :: 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(0) * 1E-4 ! p1 = 0.0 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 rho(k,j,i) = ( nom(1) + nom(2)*pt1 + nom(3)*pt2 + & nom(4)*pt3 + nom(5)*sa1 + nom(6)*sa1*pt1 + & nom(7)*sa2 + nom(8)*p1 + nom(9)*p1*pt2 + & nom(10)*p1*sa1 + nom(11)*p2 + nom(12)*p2*pt2 & ) / & ( 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 + den(11)*p1 + den(12)*p2*pt3 + & den(13)*p3*pt1 & ) ENDDO ! !-- Neumann conditions are assumed at bottom and top boundary 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