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

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

source: trunk/NEMO/OFF_SRC/eosbn2.F90 @ 344

Last change on this file since 344 was 343, checked in by opalod, 18 years ago

nemo_v1_update_O29:RB: add header for OFFLINE component

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