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

source: trunk/NEMOGCM/NEMO/OPA_SRC/TRA/eosbn2.F90 @ 4070

Last change on this file since 4070 was 4070, checked in by djlea, 11 years ago

#1087: Bug fix to freezing temperature used in ASM code.

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