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

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

source: trunk/NEMO/OPA_SRC/eosbn2.F90 @ 593

Last change on this file since 593 was 593, checked in by opalod, 17 years ago

nemo_v2_update_001 : CT : - add non linear free surface (variable volume) with new cpp key key_vvl

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