New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
eosbn2.F90 in branches/DEV_r1837_mass_heat_salt_fluxes/NEMO/OPA_SRC/TRA – NEMO

source: branches/DEV_r1837_mass_heat_salt_fluxes/NEMO/OPA_SRC/TRA/eosbn2.F90 @ 1858

Last change on this file since 1858 was 1858, checked in by gm, 14 years ago

ticket:#665 : step 1 - heat content of freezing-melting ice

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 32.2 KB
Line 
1MODULE eosbn2
2   !!==============================================================================
3   !!                       ***  MODULE  eosbn2  ***
4   !! Ocean diagnostic variable : equation of state - in situ and potential density
5   !!                                               - Brunt-Vaisala frequency
6   !!==============================================================================
7   !! History :  OPA  ! 1989-03  (O. Marti)  Original code
8   !!            6.0  ! 1994-07  (G. Madec, M. Imbard)  add bn2
9   !!            6.0  ! 1994-08  (G. Madec)  Add Jackett & McDougall eos
10   !!            7.0  ! 1996-01  (G. Madec)  statement function for e3
11   !!            8.1  ! 1997-07  (G. Madec)  density instead of volumic mass
12   !!             -   ! 1999-02  (G. Madec, N. Grima) semi-implicit pressure gradient
13   !!            8.2  ! 2001-09  (M. Ben Jelloul)  bugfix on linear eos
14   !!   NEMO     1.0  ! 2002-10  (G. Madec)  add eos_init
15   !!             -   ! 2002-11  (G. Madec, A. Bozec)  partial step, eos_insitu_2d
16   !!             -   ! 2003-08  (G. Madec)  F90, free form
17   !!            3.0  ! 2006-08  (G. Madec)  add tfreez function
18   !!----------------------------------------------------------------------
19
20   !!----------------------------------------------------------------------
21   !!   eos            : generic interface of the equation of state
22   !!   eos_insitu     : Compute the in situ density
23   !!   eos_insitu_pot : Compute the insitu and surface referenced potential
24   !!                    volumic mass
25   !!   eos_insitu_2d  : Compute the in situ density for 2d fields
26   !!   eos_bn2        : Compute the Brunt-Vaisala frequency
27   !!   tfreez         : Compute the surface freezing temperature
28   !!   eos_init       : set eos parameters (namelist)
29   !!----------------------------------------------------------------------
30   USE dom_oce         ! ocean space and time domain
31   USE phycst          ! physical constants
32   USE in_out_manager  ! I/O manager
33   USE zdfddm          ! vertical physics: double diffusion
34   USE prtctl          ! Print control
35
36   IMPLICIT NONE
37   PRIVATE
38
39   !! * Interface
40   INTERFACE eos
41      MODULE PROCEDURE eos_insitu, eos_insitu_pot, eos_insitu_2d
42   END INTERFACE
43   INTERFACE bn2
44      MODULE PROCEDURE eos_bn2
45   END INTERFACE
46
47   PUBLIC   eos        ! called by step, istate, tranpc and zpsgrd modules
48   PUBLIC   eos_init   ! called by istate module
49   PUBLIC   bn2        ! called by step module
50   PUBLIC   tfreez     ! called by sbcice_... modules
51
52   !                                        !!* Namelist (nameos) *
53   INTEGER , PUBLIC ::   nn_eos   = 0        !: = 0/1/2 type of eq. of state and Brunt-Vaisala frequ.
54   REAL(wp), PUBLIC ::   rn_alpha = 2.0e-4   !: thermal expension coeff. (linear equation of state)
55   REAL(wp), PUBLIC ::   rn_beta  = 7.7e-4   !: saline  expension coeff. (linear equation of state)
56
57   REAL(wp), PUBLIC ::   ralpbet           !: alpha / beta ratio
58   
59   !! * Substitutions
60#  include "domzgr_substitute.h90"
61#  include "vectopt_loop_substitute.h90"
62   !!----------------------------------------------------------------------
63   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009)
64   !! $Id$
65   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
66   !!----------------------------------------------------------------------
67
68CONTAINS
69
70   SUBROUTINE eos_insitu( ptem, psal, prd )
71      !!----------------------------------------------------------------------
72      !!                   ***  ROUTINE eos_insitu  ***
73      !!
74      !! ** Purpose :   Compute the in situ density (ratio rho/rau0) from
75      !!       potential temperature and salinity using an equation of state
76      !!       defined through the namelist parameter nn_eos.
77      !!
78      !! ** Method  :   3 cases:
79      !!      nn_eos = 0 : Jackett and McDougall (1994) equation of state.
80      !!         the in situ density is computed directly as a function of
81      !!         potential temperature relative to the surface (the opa t
82      !!         variable), salt and pressure (assuming no pressure variation
83      !!         along geopotential surfaces, i.e. the pressure p in decibars
84      !!         is approximated by the depth in meters.
85      !!              prd(t,s,p) = ( rho(t,s,p) - rau0 ) / rau0
86      !!         with pressure                      p        decibars
87      !!              potential temperature         t        deg celsius
88      !!              salinity                      s        psu
89      !!              reference volumic mass        rau0     kg/m**3
90      !!              in situ volumic mass          rho      kg/m**3
91      !!              in situ density anomalie      prd      no units
92      !!         Check value: rho = 1060.93298 kg/m**3 for p=10000 dbar,
93      !!          t = 40 deg celcius, s=40 psu
94      !!      nn_eos = 1 : linear equation of state function of temperature only
95      !!              prd(t) = 0.0285 - rn_alpha * t
96      !!      nn_eos = 2 : linear equation of state function of temperature and
97      !!               salinity
98      !!              prd(t,s) = rn_beta * s - rn_alpha * tn - 1.
99      !!      Note that no boundary condition problem occurs in this routine
100      !!      as (ptem,psal) are defined over the whole domain.
101      !!
102      !! ** Action  :   compute prd , the in situ density (no units)
103      !!
104      !! References :   Jackett and McDougall, J. Atmos. Ocean. Tech., 1994
105      !!----------------------------------------------------------------------
106      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) ::   ptem   ! potential temperature  [Celcius]
107      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) ::   psal   ! salinity               [psu]
108      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(  out) ::   prd    ! in situ density
109      !!
110      INTEGER  ::   ji, jj, jk           ! dummy loop indices
111      REAL(wp) ::   zt , zs , zh , zsr   ! temporary scalars
112      REAL(wp) ::   zr1, zr2, zr3, zr4   !    -         -
113      REAL(wp) ::   zrhop, ze, zbw, zb   !    -         -
114      REAL(wp) ::   zd , zc , zaw, za    !    -         -
115      REAL(wp) ::   zb1, za1, zkw, zk0   !    -         -
116      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zws   ! temporary workspace
117      !!----------------------------------------------------------------------
118
119      SELECT CASE( nn_eos )
120      !
121      CASE( 0 )                !==  Jackett and McDougall (1994) formulation  ==!
122!CDIR NOVERRCHK
123         zws(:,:,:) = SQRT( ABS( psal(:,:,:) ) )
124         
125         DO jk = 1, jpkm1
126            DO jj = 1, jpj
127               DO ji = 1, jpi
128                  zt = ptem  (ji,jj,jk)
129                  zs = psal  (ji,jj,jk)
130                  zh = fsdept(ji,jj,jk)        ! depth
131                  zsr= zws   (ji,jj,jk)        ! square root salinity
132                  !
133                  ! compute volumic mass pure water at atm pressure
134                  zr1= ( ( ( ( 6.536332e-9*zt-1.120083e-6 )*zt+1.001685e-4)*zt   &
135                     &      -9.095290e-3 )*zt+6.793952e-2 )*zt+999.842594
136                  ! seawater volumic mass atm pressure
137                  zr2= ( ( ( 5.3875e-9*zt-8.2467e-7 ) *zt+7.6438e-5 ) *zt        &
138                     &                   -4.0899e-3 ) *zt+0.824493
139                  zr3= ( -1.6546e-6*zt+1.0227e-4 ) *zt-5.72466e-3
140                  zr4= 4.8314e-4
141                  !
142                  ! potential volumic mass (reference to the surface)
143                  zrhop= ( zr4*zs + zr3*zsr + zr2 ) *zs + zr1
144                  !
145                  ! add the compression terms
146                  ze = ( -3.508914e-8*zt-1.248266e-8 ) *zt-2.595994e-6
147                  zbw= (  1.296821e-6*zt-5.782165e-9 ) *zt+1.045941e-4
148                  zb = zbw + ze * zs
149                  !
150                  zd = -2.042967e-2
151                  zc =   (-7.267926e-5*zt+2.598241e-3 ) *zt+0.1571896
152                  zaw= ( ( 5.939910e-6*zt+2.512549e-3 ) *zt-0.1028859 ) *zt - 4.721788
153                  za = ( zd*zsr + zc ) *zs + zaw
154                  !
155                  zb1=   (-0.1909078*zt+7.390729 ) *zt-55.87545
156                  za1= ( ( 2.326469e-3*zt+1.553190)*zt-65.00517 ) *zt+1044.077
157                  zkw= ( ( (-1.361629e-4*zt-1.852732e-2 ) *zt-30.41638 ) *zt + 2098.925 ) *zt+190925.6
158                  zk0= ( zb1*zsr + za1 )*zs + zkw
159                  !
160                  ! masked in situ density anomaly
161                  prd(ji,jj,jk) = (  zrhop / (  1.0 - zh / ( zk0 - zh * ( za - zh * zb ) )  )    &
162                     &             - rau0  ) * r1_rau0 * tmask(ji,jj,jk)
163               END DO
164            END DO
165         END DO
166         !
167      CASE( 1 )                !==  Linear formulation function of temperature only  ==!
168         DO jk = 1, jpkm1
169            prd(:,:,jk) = ( 0.0285 - rn_alpha * ptem(:,:,jk) ) * tmask(:,:,jk)
170         END DO
171         !
172      CASE( 2 )                !==  Linear formulation function of temperature and salinity  ==!
173         DO jk = 1, jpkm1
174            prd(:,:,jk) = ( rn_beta  * psal(:,:,jk) - rn_alpha * ptem(:,:,jk) ) * tmask(:,:,jk)
175         END DO
176         !
177      END SELECT
178      !
179      IF(ln_ctl)   CALL prt_ctl( tab3d_1=prd, clinfo1=' eos  : ', ovlap=1, kdim=jpk )
180      !
181   END SUBROUTINE eos_insitu
182
183
184   SUBROUTINE eos_insitu_pot( ptem, psal, prd, prhop )
185      !!----------------------------------------------------------------------
186      !!                  ***  ROUTINE eos_insitu_pot  ***
187      !!           
188      !! ** Purpose :   Compute the in situ density (ratio rho/rau0) and the
189      !!      potential volumic mass (Kg/m3) from potential temperature and
190      !!      salinity fields using an equation of state defined through the
191      !!     namelist parameter nn_eos.
192      !!
193      !! ** Method  :
194      !!      nn_eos = 0 : Jackett and McDougall (1994) equation of state.
195      !!         the in situ density is computed directly as a function of
196      !!         potential temperature relative to the surface (the opa t
197      !!         variable), salt and pressure (assuming no pressure variation
198      !!         along geopotential surfaces, i.e. the pressure p in decibars
199      !!         is approximated by the depth in meters.
200      !!              prd(t,s,p) = ( rho(t,s,p) - rau0 ) / rau0
201      !!              rhop(t,s)  = rho(t,s,0)
202      !!         with pressure                      p        decibars
203      !!              potential temperature         t        deg celsius
204      !!              salinity                      s        psu
205      !!              reference volumic mass        rau0     kg/m**3
206      !!              in situ volumic mass          rho      kg/m**3
207      !!              in situ density anomalie      prd      no units
208      !!
209      !!         Check value: rho = 1060.93298 kg/m**3 for p=10000 dbar,
210      !!          t = 40 deg celcius, s=40 psu
211      !!
212      !!      nn_eos = 1 : linear equation of state function of temperature only
213      !!              prd(t) = ( rho(t) - rau0 ) / rau0 = 0.028 - rn_alpha * t
214      !!              rhop(t,s)  = rho(t,s)
215      !!
216      !!      nn_eos = 2 : linear equation of state function of temperature and
217      !!               salinity
218      !!              prd(t,s) = ( rho(t,s) - rau0 ) / rau0
219      !!                       = rn_beta * s - rn_alpha * tn - 1.
220      !!              rhop(t,s)  = rho(t,s)
221      !!      Note that no boundary condition problem occurs in this routine
222      !!      as (tn,sn) or (ta,sa) are defined over the whole domain.
223      !!
224      !! ** Action  : - prd  , the in situ density (no units)
225      !!              - prhop, the potential volumic mass (Kg/m3)
226      !!
227      !! References :   Jackett and McDougall, J. Atmos. Ocean. Tech., 1994
228      !!                Brown and Campana, Mon. Weather Rev., 1978
229      !!----------------------------------------------------------------------
230      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) ::   ptem   ! potential temperature  [Celcius]
231      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) ::   psal   ! salinity               [psu]
232      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(  out) ::   prd    ! in situ density
233      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(  out) ::   prhop  ! potential density (surface referenced)
234
235      INTEGER  ::   ji, jj, jk   ! dummy loop indices
236      REAL(wp) ::   zt, zs, zh, zsr, zr1, zr2, zr3, zr4, zrhop, ze, zbw   ! temporary scalars
237      REAL(wp) ::   zb, zd, zc, zaw, za, zb1, za1, zkw, zk0               !    -         -
238      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zws   ! 3D workspace
239      !!----------------------------------------------------------------------
240
241      SELECT CASE ( nn_eos )
242      !
243      CASE( 0 )                !==  Jackett and McDougall (1994) formulation  ==!
244!CDIR NOVERRCHK
245         zws(:,:,:) = SQRT( ABS( psal(:,:,:) ) )
246         
247         DO jk = 1, jpkm1
248            DO jj = 1, jpj
249               DO ji = 1, jpi
250                  zt = ptem  (ji,jj,jk)
251                  zs = psal  (ji,jj,jk)
252                  zh = fsdept(ji,jj,jk)        ! depth
253                  zsr= zws   (ji,jj,jk)        ! square root salinity
254                  !
255                  ! compute volumic mass pure water at atm pressure
256                  zr1= ( ( ( ( 6.536332e-9*zt-1.120083e-6 )*zt+1.001685e-4 )*zt   &
257                     &                       -9.095290e-3 )*zt+6.793952e-2 )*zt+999.842594
258                  ! seawater volumic mass atm pressure
259                  zr2= ( ( ( 5.3875e-9*zt-8.2467e-7 ) *zt+7.6438e-5 ) *zt   &
260                     &                                   -4.0899e-3 ) *zt+0.824493
261                  zr3= ( -1.6546e-6*zt+1.0227e-4 ) *zt-5.72466e-3
262                  zr4= 4.8314e-4
263                  !
264                  ! potential volumic mass (reference to the surface)
265                  zrhop= ( zr4*zs + zr3*zsr + zr2 ) *zs + zr1
266                  !
267                  ! save potential volumic mass
268                  prhop(ji,jj,jk) = zrhop * tmask(ji,jj,jk)
269                  !
270                  ! add the compression terms
271                  ze = ( -3.508914e-8*zt-1.248266e-8 ) *zt-2.595994e-6
272                  zbw= (  1.296821e-6*zt-5.782165e-9 ) *zt+1.045941e-4
273                  zb = zbw + ze * zs
274                  !
275                  zd = -2.042967e-2
276                  zc =   (-7.267926e-5*zt+2.598241e-3 ) *zt+0.1571896
277                  zaw= ( ( 5.939910e-6*zt+2.512549e-3 ) *zt-0.1028859 ) *zt - 4.721788
278                  za = ( zd*zsr + zc ) *zs + zaw
279                  !
280                  zb1=   (-0.1909078*zt+7.390729 ) *zt-55.87545
281                  za1= ( ( 2.326469e-3*zt+1.553190)*zt-65.00517 ) *zt+1044.077
282                  zkw= ( ( (-1.361629e-4*zt-1.852732e-2 ) *zt-30.41638 ) *zt + 2098.925 ) *zt+190925.6
283                  zk0= ( zb1*zsr + za1 )*zs + zkw
284                  !
285                  ! masked in situ density anomaly
286                  prd(ji,jj,jk) = (  zrhop / (  1.0 - zh / ( zk0 - zh * ( za - zh * zb ) )  )    &
287                     &             - rau0  ) * r1_rau0 * tmask(ji,jj,jk)
288               END DO
289            END DO
290         END DO
291         !
292      CASE( 1 )                !==  Linear formulation = F( temperature )  ==!
293         DO jk = 1, jpkm1
294            prd  (:,:,jk) = ( 0.0285 - rn_alpha * ptem(:,:,jk) )        * tmask(:,:,jk)
295            prhop(:,:,jk) = ( 1.e0   +            prd (:,:,jk) ) * rau0 * tmask(:,:,jk)
296         END DO
297         !
298      CASE( 2 )                !==  Linear formulation = F( temperature , salinity )  ==!
299         DO jk = 1, jpkm1
300            prd  (:,:,jk) = ( rn_beta  * psal(:,:,jk) - rn_alpha * ptem(:,:,jk) )        * tmask(:,:,jk)
301            prhop(:,:,jk) = ( 1.e0   + prd (:,:,jk) )                             * rau0 * tmask(:,:,jk)
302         END DO
303         !
304      END SELECT
305      !
306      IF(ln_ctl)   CALL prt_ctl( tab3d_1=prd, clinfo1=' eos-p: ', tab3d_2=prhop, clinfo2=' pot : ', ovlap=1, kdim=jpk )
307      !
308   END SUBROUTINE eos_insitu_pot
309
310
311   SUBROUTINE eos_insitu_2d( ptem, psal, pdep, prd )
312      !!----------------------------------------------------------------------
313      !!                  ***  ROUTINE eos_insitu_2d  ***
314      !!
315      !! ** Purpose :   Compute the in situ density (ratio rho/rau0) from
316      !!      potential temperature and salinity using an equation of state
317      !!      defined through the namelist parameter nn_eos. * 2D field case
318      !!
319      !! ** Method :
320      !!      nn_eos = 0 : Jackett and McDougall (1994) equation of state.
321      !!         the in situ density is computed directly as a function of
322      !!         potential temperature relative to the surface (the opa t
323      !!         variable), salt and pressure (assuming no pressure variation
324      !!         along geopotential surfaces, i.e. the pressure p in decibars
325      !!         is approximated by the depth in meters.
326      !!              prd(t,s,p) = ( rho(t,s,p) - rau0 ) / rau0
327      !!         with pressure                      p        decibars
328      !!              potential temperature         t        deg celsius
329      !!              salinity                      s        psu
330      !!              reference volumic mass        rau0     kg/m**3
331      !!              in situ volumic mass          rho      kg/m**3
332      !!              in situ density anomalie      prd      no units
333      !!         Check value: rho = 1060.93298 kg/m**3 for p=10000 dbar,
334      !!          t = 40 deg celcius, s=40 psu
335      !!      nn_eos = 1 : linear equation of state function of temperature only
336      !!              prd(t) = 0.0285 - rn_alpha * t
337      !!      nn_eos = 2 : linear equation of state function of temperature and
338      !!               salinity
339      !!              prd(t,s) = rn_beta * s - rn_alpha * tn - 1.
340      !!      Note that no boundary condition problem occurs in this routine
341      !!      as (ptem,psal) are defined over the whole domain.
342      !!
343      !! ** Action  : - prd , the in situ density (no units)
344      !!
345      !! References :   Jackett and McDougall, J. Atmos. Ocean. Tech., 1994
346      !!----------------------------------------------------------------------
347      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   ptem   ! potential temperature  [Celcius]
348      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   psal   ! salinity               [psu]
349      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   pdep   ! depth                  [m]
350      REAL(wp), DIMENSION(jpi,jpj), INTENT(  out) ::   prd    ! in situ density
351      !!
352      INTEGER  ::   ji, jj                    ! dummy loop indices
353      REAL(wp) ::   zt, zs, zh, zsr, zr1, zr2, zr3, zr4, zrhop, ze, zbw   ! temporary scalars
354      REAL(wp) ::   zb, zd, zc, zaw, za, zb1, za1, zkw, zk0, zmask        !    -         -
355      REAL(wp), DIMENSION(jpi,jpj) ::   zws   ! 2D workspace
356      !!----------------------------------------------------------------------
357
358      prd(:,:) = 0.e0
359
360      SELECT CASE( nn_eos )
361      !
362      CASE( 0 )                !==  Jackett and McDougall (1994) formulation  ==!
363      !
364!CDIR NOVERRCHK
365         DO jj = 1, jpjm1
366!CDIR NOVERRCHK
367            DO ji = 1, fs_jpim1   ! vector opt.
368               zws(ji,jj) = SQRT( ABS( psal(ji,jj) ) )
369            END DO
370         END DO
371         DO jj = 1, jpjm1
372            DO ji = 1, fs_jpim1   ! vector opt.
373               zmask = tmask(ji,jj,1)          ! land/sea bottom mask = surf. mask
374               zt    = ptem (ji,jj)            ! interpolated T
375               zs    = psal (ji,jj)            ! interpolated S
376               zsr   = zws  (ji,jj)            ! square root of interpolated S
377               zh    = pdep (ji,jj)            ! depth at the partial step level
378               !
379               ! compute volumic mass pure water at atm pressure
380               zr1 = ( ( ( ( 6.536332e-9*zt-1.120083e-6 )*zt+1.001685e-4 )*zt   &
381                  &                        -9.095290e-3 )*zt+6.793952e-2 )*zt+999.842594
382               ! seawater volumic mass atm pressure
383               zr2 = ( ( ( 5.3875e-9*zt-8.2467e-7 )*zt+7.6438e-5 ) *zt   &
384                  &                                   -4.0899e-3 ) *zt+0.824493
385               zr3 = ( -1.6546e-6*zt+1.0227e-4 ) *zt-5.72466e-3
386               zr4 = 4.8314e-4
387               !
388               ! potential volumic mass (reference to the surface)
389               zrhop= ( zr4*zs + zr3*zsr + zr2 ) *zs + zr1
390               !
391               ! add the compression terms
392               ze = ( -3.508914e-8*zt-1.248266e-8 ) *zt-2.595994e-6
393               zbw= (  1.296821e-6*zt-5.782165e-9 ) *zt+1.045941e-4
394               zb = zbw + ze * zs
395               !
396               zd = -2.042967e-2
397               zc =   (-7.267926e-5*zt+2.598241e-3 ) *zt+0.1571896
398               zaw= ( ( 5.939910e-6*zt+2.512549e-3 ) *zt-0.1028859 ) *zt -4.721788
399               za = ( zd*zsr + zc ) *zs + zaw
400               !
401               zb1=   (-0.1909078*zt+7.390729 ) *zt-55.87545
402               za1= ( ( 2.326469e-3*zt+1.553190)*zt-65.00517 ) *zt+1044.077
403               zkw= ( ( (-1.361629e-4*zt-1.852732e-2 ) *zt-30.41638 ) *zt   &
404                  &                                       +2098.925 ) *zt+190925.6
405               zk0= ( zb1*zsr + za1 )*zs + zkw
406               !
407               ! masked in situ density anomaly
408               prd(ji,jj) = ( zrhop / (  1.0 - zh / ( zk0 - zh * ( za - zh * zb ) )  ) - rau0 ) * r1_rau0 * zmask
409            END DO
410         END DO
411         !
412      CASE( 1 )                !==  Linear formulation = F( temperature )  ==!
413         DO jj = 1, jpjm1
414            DO ji = 1, fs_jpim1   ! vector opt.
415               prd(ji,jj) = ( 0.0285 - rn_alpha * ptem(ji,jj) ) * tmask(ji,jj,1)
416            END DO
417         END DO
418         !
419      CASE( 2 )                !==  Linear formulation = F( temperature , salinity )  ==!
420         DO jj = 1, jpjm1
421            DO ji = 1, fs_jpim1   ! vector opt.
422               prd(ji,jj) = ( rn_beta * psal(ji,jj) - rn_alpha * ptem(ji,jj) ) * tmask(ji,jj,1) 
423            END DO
424         END DO
425         !
426      END SELECT
427
428      IF(ln_ctl)   CALL prt_ctl( tab2d_1=prd, clinfo1=' eos2d: ' )
429      !
430   END SUBROUTINE eos_insitu_2d
431
432
433   SUBROUTINE eos_bn2( ptem, psal, pn2 )
434      !!----------------------------------------------------------------------
435      !!                  ***  ROUTINE eos_bn2  ***
436      !!
437      !! ** Purpose :   Compute the local Brunt-Vaisala frequency at the time-
438      !!      step of the input arguments
439      !!     
440      !! ** Method :
441      !!       * nn_eos = 0  : UNESCO sea water properties
442      !!         The brunt-vaisala frequency is computed using the polynomial
443      !!      polynomial expression of McDougall (1987):
444      !!            N^2 = grav * beta * ( alpha/beta*dk[ t ] - dk[ s ] )/e3w
445      !!      If lk_zdfddm=T, the heat/salt buoyancy flux ratio Rrau is
446      !!      computed and used in zdfddm module :
447      !!              Rrau = alpha/beta * ( dk[ t ] / dk[ s ] )
448      !!       * nn_eos = 1  : linear equation of state (temperature only)
449      !!            N^2 = grav * rn_alpha * dk[ t ]/e3w
450      !!       * nn_eos = 2  : linear equation of state (temperature & salinity)
451      !!            N^2 = grav * (rn_alpha * dk[ t ] - rn_beta * dk[ s ] ) / e3w
452      !!      The use of potential density to compute N^2 introduces e r r o r
453      !!      in the sign of N^2 at great depths. We recommand the use of
454      !!      nn_eos = 0, except for academical studies.
455      !!        Macro-tasked on horizontal slab (jk-loop)
456      !!      N.B. N^2 is set to zero at the first level (JK=1) in inidtr
457      !!      and is never used at this level.
458      !!
459      !! ** Action  : - pn2 : the brunt-vaisala frequency
460      !!
461      !! References :   McDougall, J. Phys. Oceanogr., 17, 1950-1964, 1987.
462      !!----------------------------------------------------------------------
463      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) ::   ptem   ! potential temperature   [Celcius]
464      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) ::   psal   ! salinity                [psu]
465      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(  out) ::   pn2    ! Brunt-Vaisala frequency [s-1]
466      !!
467      INTEGER  ::   ji, jj, jk   ! dummy loop indices
468      REAL(wp) ::   zgde3w, zt, zs, zh, zalbet, zbeta   ! temporary scalars
469#if defined key_zdfddm
470      REAL(wp) ::   zds   ! temporary scalars
471#endif
472      !!----------------------------------------------------------------------
473
474      ! pn2 : interior points only (2=< jk =< jpkm1 )
475      ! --------------------------
476      !
477      SELECT CASE( nn_eos )
478      !
479      CASE( 0 )                !==  Jackett and McDougall (1994) formulation  ==!
480         DO jk = 2, jpkm1
481            DO jj = 1, jpj
482               DO ji = 1, jpi
483                  zgde3w = grav / fse3w(ji,jj,jk)
484                  zt = 0.5 * ( ptem(ji,jj,jk) + ptem(ji,jj,jk-1) )          ! potential temperature at w-point
485                  zs = 0.5 * ( psal(ji,jj,jk) + psal(ji,jj,jk-1) ) - 35.0   ! salinity anomaly (s-35) at w-point
486                  zh = fsdepw(ji,jj,jk)                                     ! depth in meters  at w-point
487                  !
488                  zalbet = ( ( ( - 0.255019e-07 * zt + 0.298357e-05 ) * zt   &   ! ratio alpha/beta
489                     &                               - 0.203814e-03 ) * zt   &
490                     &                               + 0.170907e-01 ) * zt   &
491                     &   + 0.665157e-01                                      &
492                     &   +     ( - 0.678662e-05 * zs                         &
493                     &           - 0.846960e-04 * zt + 0.378110e-02 ) * zs   &
494                     &   +   ( ( - 0.302285e-13 * zh                         &
495                     &           - 0.251520e-11 * zs                         &
496                     &           + 0.512857e-12 * zt * zt           ) * zh   &
497                     &           - 0.164759e-06 * zs                         &
498                     &        +(   0.791325e-08 * zt - 0.933746e-06 ) * zt   &
499                     &                               + 0.380374e-04 ) * zh
500                     !
501                  zbeta  = ( ( -0.415613e-09 * zt + 0.555579e-07 ) * zt      &   ! beta
502                     &                            - 0.301985e-05 ) * zt      &
503                     &   + 0.785567e-03                                      &
504                     &   + (     0.515032e-08 * zs                           &
505                     &         + 0.788212e-08 * zt - 0.356603e-06 ) * zs     &
506                     &   +(  (   0.121551e-17 * zh                           &
507                     &         - 0.602281e-15 * zs                           &
508                     &         - 0.175379e-14 * zt + 0.176621e-12 ) * zh     &
509                     &                             + 0.408195e-10   * zs     &
510                     &     + ( - 0.213127e-11 * zt + 0.192867e-09 ) * zt     &
511                     &                             - 0.121555e-07 ) * zh
512                     !
513                  pn2(ji,jj,jk) = zgde3w * zbeta * tmask(ji,jj,jk)           &   ! N^2
514                     &          * ( zalbet * ( ptem(ji,jj,jk-1) - ptem(ji,jj,jk) )   &
515                     &                     - ( psal(ji,jj,jk-1) - psal(ji,jj,jk) ) )
516#if defined key_zdfddm
517                  !                                                         !!bug **** caution a traiter zds=dk[S]= 0 !!!!
518                  zds = ( psal(ji,jj,jk-1) - psal(ji,jj,jk) )                    ! Rrau = (alpha / beta) (dk[t] / dk[s])
519                  IF ( ABS( zds) <= 1.e-20 ) zds = 1.e-20
520                  rrau(ji,jj,jk) = zalbet * ( ptem(ji,jj,jk-1) - ptem(ji,jj,jk) ) / zds
521#endif
522               END DO
523            END DO
524         END DO
525         !
526      CASE( 1 )                !==  Linear formulation = F( temperature )  ==!
527         DO jk = 2, jpkm1
528            pn2(:,:,jk) = grav * rn_alpha * ( ptem(:,:,jk-1) - ptem(:,:,jk) ) / fse3w(:,:,jk) * tmask(:,:,jk)
529         END DO
530         !
531      CASE( 2 )                !==  Linear formulation = F( temperature , salinity )  ==!
532         DO jk = 2, jpkm1
533            pn2(:,:,jk) = grav * (  rn_alpha * ( ptem(:,:,jk-1) - ptem(:,:,jk) )      &
534               &                  - rn_beta  * ( psal(:,:,jk-1) - psal(:,:,jk) )  )   &
535               &               / fse3w(:,:,jk) * tmask(:,:,jk)
536         END DO 
537#if defined key_zdfddm
538         DO jk = 2, jpkm1                                 ! Rrau = (alpha / beta) (dk[t] / dk[s])
539            DO jj = 1, jpj
540               DO ji = 1, jpi
541                  zds = ( psal(ji,jj,jk-1) - psal(ji,jj,jk) )
542                  IF ( ABS( zds ) <= 1.e-20 ) zds = 1.e-20
543                  rrau(ji,jj,jk) = ralpbet * ( ptem(ji,jj,jk-1) - ptem(ji,jj,jk) ) / zds
544               END DO
545            END DO
546         END DO
547#endif
548      END SELECT
549
550      IF(ln_ctl)   CALL prt_ctl( tab3d_1=pn2, clinfo1=' bn2  : ', ovlap=1, kdim=jpk )
551#if defined key_zdfddm
552      IF(ln_ctl)   CALL prt_ctl( tab3d_1=rrau, clinfo1=' rrau : ', ovlap=1, kdim=jpk )
553#endif
554      !
555   END SUBROUTINE eos_bn2
556
557
558   FUNCTION tfreez( psal ) RESULT( ptf )
559      !!----------------------------------------------------------------------
560      !!                 ***  ROUTINE eos_init  ***
561      !!
562      !! ** Purpose :   Compute the sea surface freezing temperature [Celcius]
563      !!
564      !! ** Method  :   UNESCO freezing point at the surface (pressure = 0???)
565      !!       freezing point [Celcius]=(-.0575+1.710523e-3*sqrt(abs(s))-2.154996e-4*s)*s-7.53e-4*p
566      !!       checkvalue: tf= -2.588567 Celsius for s=40.0psu, p=500. decibars
567      !!
568      !! Reference  :   UNESCO tech. papers in the marine science no. 28. 1978
569      !!----------------------------------------------------------------------
570      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   psal   ! salinity             [psu]
571      REAL(wp), DIMENSION(jpi,jpj)                ::   ptf    ! freezing temperature [Celcius]
572      !!----------------------------------------------------------------------
573      !
574      ptf(:,:) = ( - 0.0575 + 1.710523e-3 * SQRT( psal(:,:) )   &
575         &                  - 2.154996e-4 *       psal(:,:)   ) * psal(:,:)
576      !
577   END FUNCTION tfreez
578
579
580   SUBROUTINE eos_init
581      !!----------------------------------------------------------------------
582      !!                 ***  ROUTINE eos_init  ***
583      !!
584      !! ** Purpose :   initializations for the equation of state
585      !!
586      !! ** Method  :   Read the namelist nameos and control the parameters
587      !!----------------------------------------------------------------------
588      NAMELIST/nameos/ nn_eos, rn_alpha, rn_beta
589      !!----------------------------------------------------------------------
590      !
591      REWIND( numnam )            ! Read Namelist nameos : equation of state
592      READ  ( numnam, nameos )
593      !
594      IF(lwp) THEN                ! Control print
595         WRITE(numout,*)
596         WRITE(numout,*) 'eos_init : equation of state'
597         WRITE(numout,*) '~~~~~~~~'
598         WRITE(numout,*) '          Namelist nameos : set eos parameters'
599         WRITE(numout,*) '             flag for eq. of state and N^2  nn_eos   = ', nn_eos
600         WRITE(numout,*) '             thermal exp. coef. (linear)    rn_alpha = ', rn_alpha
601         WRITE(numout,*) '             saline  exp. coef. (linear)    rn_beta  = ', rn_beta
602      ENDIF
603      !
604      SELECT CASE( nn_eos )         ! check option
605      !
606      CASE( 0 )                        !==  Jackett and McDougall (1994) formulation  ==!
607         IF(lwp) WRITE(numout,*)
608         IF(lwp) WRITE(numout,*) '          use of Jackett & McDougall (1994) equation of state and'
609         IF(lwp) WRITE(numout,*) '                 McDougall (1987) Brunt-Vaisala frequency'
610         !
611      CASE( 1 )                        !==  Linear formulation = F( temperature )  ==!
612         IF(lwp) WRITE(numout,*)
613         IF(lwp) WRITE(numout,*) '          use of linear eos rho(T) = rau0 * ( 1.0285 - rn_alpha * T )'
614         IF( lk_zdfddm ) CALL ctl_stop( '          double diffusive mixing parameterization requires',   &
615              &                         ' that T and S are used as state variables' )
616         !
617      CASE( 2 )                        !==  Linear formulation = F( temperature , salinity )  ==!
618         ralpbet = rn_alpha / rn_beta
619         IF(lwp) WRITE(numout,*)
620         IF(lwp) WRITE(numout,*) '          use of linear eos rho(T,S) = rau0 * ( rn_beta * S - rn_alpha * T )'
621         !
622      CASE DEFAULT                     !==  ERROR in nn_eos  ==!
623         WRITE(ctmp1,*) '          bad flag value for nn_eos = ', nn_eos
624         CALL ctl_stop( ctmp1 )
625         !
626      END SELECT
627      !
628   END SUBROUTINE eos_init
629
630   !!======================================================================
631END MODULE eosbn2 
Note: See TracBrowser for help on using the repository browser.