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 trunk/NEMO/OPA_SRC/TRA – NEMO

source: trunk/NEMO/OPA_SRC/TRA/eosbn2.F90 @ 1613

Last change on this file since 1613 was 1613, checked in by ctlod, 15 years ago

move few modules into different (more approriate) directories, see ticket: #530

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