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 @ 812

Last change on this file since 812 was 789, checked in by rblod, 16 years ago

Suppress jki routines and associated key_mpp_omp

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 38.0 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            DO ji = 1, fs_jpim1   ! vector opt.
491               zws(ji,jj) = SQRT( ABS( psal(ji,jj) ) )
492            END DO
493         END DO
494
495         !                                                ! ===============
496         DO jj = 1, jpjm1                                 ! Horizontal slab
497            !                                             ! ===============
498            DO ji = 1, fs_jpim1   ! vector opt.
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            DO ji = 1, fs_jpim1   ! vector opt.
550               prd(ji,jj) = ( 0.0285 - ralpha * ptem(ji,jj) ) * tmask(ji,jj,1)
551            END DO
552            !                                             ! ===============
553         END DO                                           !   End of slab
554         !                                                ! ===============
555
556
557      CASE ( 2 )               ! Linear formulation function of temperature and salinity
558
559         !                                                ! ===============
560         DO jj = 1, jpjm1                                 ! Horizontal slab
561            !                                             ! ===============
562            DO ji = 1, fs_jpim1   ! vector opt.
563               prd(ji,jj) = ( rbeta * psal(ji,jj) - ralpha * ptem(ji,jj) ) * tmask(ji,jj,1) 
564            END DO
565            !                                             ! ===============
566         END DO                                           !   End of slab
567         !                                                ! ===============
568
569      CASE DEFAULT
570
571         WRITE(ctmp1,*) '          bad flag value for neos = ', neos
572         CALL ctl_stop( ctmp1 )
573
574      END SELECT
575
576      IF(ln_ctl)   CALL prt_ctl(tab2d_1=prd, clinfo1=' eos2d: ')
577
578   END SUBROUTINE eos_insitu_2d
579
580
581   SUBROUTINE eos_bn2( ptem, psal, pn2 )
582      !!----------------------------------------------------------------------
583      !!                  ***  ROUTINE eos_bn2  ***
584      !!
585      !! ** Purpose :   Compute the local Brunt-Vaisala frequency at the time-
586      !!      step of the input arguments
587      !!     
588      !! ** Method :
589      !!       * neos = 0  : UNESCO sea water properties
590      !!         The brunt-vaisala frequency is computed using the polynomial
591      !!      polynomial expression of McDougall (1987):
592      !!            N^2 = grav * beta * ( alpha/beta*dk[ t ] - dk[ s ] )/e3w
593      !!      If lk_zdfddm=T, the heat/salt buoyancy flux ratio Rrau is
594      !!      computed and used in zdfddm module :
595      !!              Rrau = alpha/beta * ( dk[ t ] / dk[ s ] )
596      !!       * neos = 1  : linear equation of state (temperature only)
597      !!            N^2 = grav * ralpha * dk[ t ]/e3w
598      !!       * neos = 2  : linear equation of state (temperature & salinity)
599      !!            N^2 = grav * (ralpha * dk[ t ] - rbeta * dk[ s ] ) / e3w
600      !!      The use of potential density to compute N^2 introduces e r r o r
601      !!      in the sign of N^2 at great depths. We recommand the use of
602      !!      neos = 0, except for academical studies.
603      !!        Macro-tasked on horizontal slab (jk-loop)
604      !!      N.B. N^2 is set to zero at the first level (JK=1) in inidtr
605      !!      and is never used at this level.
606      !!
607      !! ** Action  : - pn2 : the brunt-vaisala frequency
608      !!
609      !! References :
610      !!      McDougall, T. J., J. Phys. Oceanogr., 17, 1950-1964, 1987.
611      !!
612      !! History :
613      !!   6.0  !  94-07  (G. Madec, M. Imbard)  Original code
614      !!   8.0  !  97-07  (G. Madec) introduction of statement functions
615      !!   8.5  !  02-07  (G. Madec) Free form, F90
616      !!   8.5  !  02-08  (G. Madec) introduction of arguments
617      !!----------------------------------------------------------------------
618      !! * Arguments
619      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( in ) ::   &
620         ptem,                           &  ! potential temperature
621         psal                               ! salinity
622      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( out ) ::   &
623         pn2                               ! Brunt-Vaisala frequency
624
625      !! * Local declarations
626      INTEGER  ::   ji, jj, jk   ! dummy loop indices
627      REAL(wp) ::   &
628         zgde3w, zt, zs, zh,  &  ! temporary scalars
629         zalbet, zbeta           !    "         "
630#if defined key_zdfddm
631      REAL(wp) ::   zds          ! temporary scalars
632#endif
633      !!----------------------------------------------------------------------
634      !!  OPA8.5, LODYC-IPSL (2002)
635      !!----------------------------------------------------------------------
636
637      ! pn2 : first and last levels
638      ! ---------------------------
639      ! bn^2=0. at jk=1 and jpk set in inidtr.F : no computation
640
641
642      ! pn2 : interior points only (2=< jk =< jpkm1 )
643      ! --------------------------
644
645      SELECT CASE ( neos )
646
647      CASE ( 0 )               ! Jackett and McDougall (1994) formulation
648
649         !                                                ! ===============
650         DO jk = 2, jpkm1                                 ! Horizontal slab
651            !                                             ! ===============
652            DO jj = 1, jpj
653               DO ji = 1, jpi
654                  zgde3w = grav / fse3w(ji,jj,jk)
655                  zt = 0.5 * ( ptem(ji,jj,jk) + ptem(ji,jj,jk-1) )          ! potential temperature at w-point
656                  zs = 0.5 * ( psal(ji,jj,jk) + psal(ji,jj,jk-1) ) - 35.0   ! salinity anomaly (s-35) at w-point
657                  zh = fsdepw(ji,jj,jk)                                     ! depth in meters  at w-point
658
659                  zalbet = ( ( ( - 0.255019e-07 * zt + 0.298357e-05 ) * zt   &   ! ratio alpha/beta
660                     &                               - 0.203814e-03 ) * zt   &
661                     &                               + 0.170907e-01 ) * zt   &
662                     &   + 0.665157e-01                                      &
663                     &   +     ( - 0.678662e-05 * zs                         &
664                     &           - 0.846960e-04 * zt + 0.378110e-02 ) * zs   &
665                     &   +   ( ( - 0.302285e-13 * zh                         &
666                     &           - 0.251520e-11 * zs                         &
667                     &           + 0.512857e-12 * zt * zt           ) * zh   &
668                     &           - 0.164759e-06 * zs                         &
669                     &        +(   0.791325e-08 * zt - 0.933746e-06 ) * zt   &
670                     &                               + 0.380374e-04 ) * zh
671
672                  zbeta  = ( ( -0.415613e-09 * zt + 0.555579e-07 ) * zt      &   ! beta
673                     &                            - 0.301985e-05 ) * zt      &
674                     &   + 0.785567e-03                                      &
675                     &   + (     0.515032e-08 * zs                           &
676                     &         + 0.788212e-08 * zt - 0.356603e-06 ) * zs     &
677                     &   +(  (   0.121551e-17 * zh                           &
678                     &         - 0.602281e-15 * zs                           &
679                     &         - 0.175379e-14 * zt + 0.176621e-12 ) * zh     &
680                     &                             + 0.408195e-10   * zs     &
681                     &     + ( - 0.213127e-11 * zt + 0.192867e-09 ) * zt     &
682                     &                             - 0.121555e-07 ) * zh
683
684                  pn2(ji,jj,jk) = zgde3w * zbeta * tmask(ji,jj,jk)           &   ! N^2
685                     &          * ( zalbet * ( ptem(ji,jj,jk-1) - ptem(ji,jj,jk) )   &
686                     &                     - ( psal(ji,jj,jk-1) - psal(ji,jj,jk) ) )
687#if defined key_zdfddm
688                  !                                                         !!bug **** caution a traiter zds=dk[S]= 0 !!!!
689                  zds = ( psal(ji,jj,jk-1) - psal(ji,jj,jk) )                    ! Rrau = (alpha / beta) (dk[t] / dk[s])
690                  IF ( ABS( zds) <= 1.e-20 ) zds = 1.e-20
691                  rrau(ji,jj,jk) = zalbet * ( ptem(ji,jj,jk-1) - ptem(ji,jj,jk) ) / zds
692#endif
693               END DO
694            END DO
695            !                                             ! ===============
696         END DO                                           !   End of slab
697         !                                                ! ===============
698
699
700      CASE ( 1 )               ! Linear formulation function of temperature only
701
702         !                                                ! ===============
703         DO jk = 2, jpkm1                                 ! Horizontal slab
704            !                                             ! ===============
705            DO jj = 1, jpj
706               DO ji = 1, jpi
707                  zgde3w = grav / fse3w(ji,jj,jk) * tmask(ji,jj,jk)
708                  pn2(ji,jj,jk) = zgde3w * ralpha * ( ptem(ji,jj,jk-1) - ptem(ji,jj,jk) )
709               END DO
710            END DO
711            !                                             ! ===============
712         END DO                                           !   End of slab
713         !                                                ! ===============
714
715
716      CASE ( 2 )               ! Linear formulation function of temperature and salinity
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                     &                      - rbeta  * ( psal(ji,jj,jk-1) - psal(ji,jj,jk) )  )
726               END DO
727            END DO
728#if defined key_zdfddm
729            !                                                ! Rrau = (alpha / beta) (dk[t] / dk[s])
730            zalbet = ralpha / rbeta
731            DO jj = 1, jpj
732               DO ji = 1, jpi
733                  zds = ( psal(ji,jj,jk-1) - psal(ji,jj,jk) )
734                  IF ( ABS( zds ) <= 1.e-20 ) zds = 1.e-20
735                  rrau(ji,jj,jk) = zalbet * ( ptem(ji,jj,jk-1) - ptem(ji,jj,jk) ) / zds
736               END DO
737            END DO
738#endif
739            !                                             ! ===============
740         END DO                                           !   End of slab
741         !                                                ! ===============
742
743      CASE DEFAULT
744
745         WRITE(ctmp1,*) '          bad flag value for neos = ', neos
746         CALL ctl_stop( ctmp1 )
747
748      END SELECT
749
750      IF(ln_ctl)   THEN
751         CALL prt_ctl(tab3d_1=pn2, clinfo1=' bn2  : ', ovlap=1, kdim=jpk)
752#if defined key_zdfddm
753         CALL prt_ctl(tab3d_1=rrau, clinfo1=' rrau : ', ovlap=1, kdim=jpk)
754#endif
755      ENDIF
756
757   END SUBROUTINE eos_bn2
758
759
760   SUBROUTINE eos_init
761      !!----------------------------------------------------------------------
762      !!                 ***  ROUTINE eos_init  ***
763      !!
764      !! ** Purpose :   initializations for the equation of state
765      !!
766      !! ** Method  :   Read the namelist nameos
767      !!
768      !! ** Action  :   blahblah....
769      !!
770      !! History :
771      !!   8.5  !  02-10  (G. Madec)  Original code
772      !!----------------------------------------------------------------------
773      NAMELIST/nameos/ neos, ralpha, rbeta
774      !!----------------------------------------------------------------------
775      !!  OPA 8.5, LODYC-IPSL (2002)
776      !!----------------------------------------------------------------------
777
778      ! set the initialization flag to 1
779      neos_init = 1           ! indicate that the initialization has been done
780
781      ! namelist nameos : ocean physical parameters
782
783      ! Read Namelist nameos : equation of state
784      REWIND( numnam )
785      READ  ( numnam, nameos )
786
787      ! Control print
788      IF(lwp) THEN
789         WRITE(numout,*)
790         WRITE(numout,*) 'eos_init : equation of state'
791         WRITE(numout,*) '~~~~~~~~'
792         WRITE(numout,*) '          Namelist nameos : set eos parameters'
793         WRITE(numout,*)
794         WRITE(numout,*) '             flag for eq. of state and N^2  neos   = ', neos
795         WRITE(numout,*) '             thermal exp. coef. (linear)    ralpha = ', ralpha
796         WRITE(numout,*) '             saline  exp. coef. (linear)    rbeta  = ', rbeta
797         WRITE(numout,*)
798      ENDIF
799
800      SELECT CASE ( neos )
801
802      CASE ( 0 )               ! Jackett and McDougall (1994) formulation
803
804         IF(lwp) WRITE(numout,*) '          use of Jackett & McDougall (1994) equation of state and'
805         IF(lwp) WRITE(numout,*) '                 McDougall (1987) Brunt-Vaisala frequency'
806
807      CASE ( 1 )               ! Linear formulation function of temperature only
808
809         IF(lwp) WRITE(numout,*) '          use of linear eos rho(T) = rau0 * ( 1.0285 - ralpha * T )'
810         IF( lk_zdfddm ) CALL ctl_stop( '          double diffusive mixing parameterization requires',   &
811              &                         ' that T and S are used as state variables' )
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         WRITE(ctmp1,*) '          bad flag value for neos = ', neos
820         CALL ctl_stop( ctmp1 )
821
822      END SELECT
823
824   END SUBROUTINE eos_init
825
826   !!======================================================================
827END MODULE eosbn2 
Note: See TracBrowser for help on using the repository browser.