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

source: branches/NERC/dev_r3874_FASTNEt/NEMOGCM/NEMO/OPA_SRC/TRA/eosbn2.F90 @ 6736

Last change on this file since 6736 was 6736, checked in by jamesharle, 8 years ago

FASTNEt code modifications

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