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

source: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/eosbn2.F90 @ 2636

Last change on this file since 2636 was 2636, checked in by gm, 13 years ago

dynamic mem: #785 ; move ctl_stop & warn in lib_mpp to avoid a circular dependency + ctl_stop improvment

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