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.
traldf.F90 in trunk/NEMO/OPA_SRC/TRA – NEMO

source: trunk/NEMO/OPA_SRC/TRA/traldf.F90 @ 902

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

Correct a bug with key_ldf_slp and ln_traldf_iso = .FALSE., see ticket #118

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 15.4 KB
Line 
1MODULE traldf
2   !!======================================================================
3   !!                       ***  MODULE  traldf  ***
4   !! Ocean Active tracers : lateral diffusive trends
5   !!=====================================================================
6   !! History :  9.0  ! 05-11 (G. Madec)  Original code
7   !!----------------------------------------------------------------------
8
9   !!----------------------------------------------------------------------
10   !!   tra_ldf     : update the tracer trend with the lateral diffusion
11   !!       ldf_ctl : initialization, namelist read, and parameters control
12   !!       ldf_ano : compute lateral diffusion for constant T-S profiles
13   !!----------------------------------------------------------------------
14   USE oce             ! ocean dynamics and tracers
15   USE dom_oce         ! ocean space and time domain
16   USE phycst          ! physical constants
17   USE ldftra_oce      ! ocean tracer   lateral physics
18   USE ldfslp          ! ???
19   USE traldf_bilapg   ! lateral mixing            (tra_ldf_bilapg routine)
20   USE traldf_bilap    ! lateral mixing             (tra_ldf_bilap routine)
21   USE traldf_iso      ! lateral mixing               (tra_ldf_iso routine)
22   USE traldf_lap      ! lateral mixing               (tra_ldf_lap routine)
23   USE trdmod          ! ocean active tracers trends
24   USE trdmod_oce      ! ocean variables trends
25   USE prtctl          ! Print control
26   USE in_out_manager  ! I/O manager
27   USE lib_mpp         ! distribued memory computing library
28   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
29
30   IMPLICIT NONE
31   PRIVATE
32
33   PUBLIC   tra_ldf    ! called by step.F90
34
35   INTEGER, PUBLIC ::   nldf = 0   ! type of lateral diffusion used defined from ln_traldf_... namlist logicals)
36                                   ! (need to be public to be used in vertical diffusion routine)
37#if defined key_traldf_ano
38   REAL, DIMENSION(jpi,jpj,jpk) ::   t0_ldf, s0_ldf   ! lateral diffusion trends of T & S
39      !                                               ! for a constant vertical profile
40#endif
41
42   !! * Substitutions
43#  include "domzgr_substitute.h90"
44#  include "vectopt_loop_substitute.h90"
45   !!----------------------------------------------------------------------
46   !!   OPA 9.0 , LOCEAN-IPSL (2006)
47   !! $Header$
48   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
49   !!----------------------------------------------------------------------
50
51CONTAINS
52
53   SUBROUTINE tra_ldf( kt )
54      !!----------------------------------------------------------------------
55      !!                  ***  ROUTINE tra_ldf  ***
56      !!
57      !! ** Purpose :   compute the lateral ocean tracer physics.
58      !!
59      !!----------------------------------------------------------------------
60      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
61      !!
62      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   ztrdt, ztrds   ! 3D temporary workspace
63      !!----------------------------------------------------------------------
64
65      IF( kt == nit000 )   CALL ldf_ctl          ! initialisation & control of options
66
67      IF( l_trdtra )   THEN                      ! temporary save of ta and sa trends
68         ztrdt(:,:,:) = ta(:,:,:) 
69         ztrds(:,:,:) = sa(:,:,:) 
70      ENDIF
71
72      SELECT CASE ( nldf )                       ! compute lateral mixing trend and add it to the general trend
73      CASE ( 0 )   ;   CALL tra_ldf_lap   ( kt )      ! iso-level laplacian
74      CASE ( 1 )   ;   CALL tra_ldf_iso   ( kt )      ! rotated laplacian (except dk[ dk[.] ] part)
75      CASE ( 2 )   ;   CALL tra_ldf_bilap ( kt )      ! iso-level bilaplacian
76      CASE ( 3 )   ;   CALL tra_ldf_bilapg( kt )      ! s-coord. horizontal bilaplacian
77         !
78      CASE ( -1 )                                     ! esopa: test all possibility with control print
79         CALL tra_ldf_lap    ( kt )
80         CALL prt_ctl( tab3d_1=ta, clinfo1=' ldf0 - Ta: ', mask1=tmask,               &
81            &          tab3d_2=sa, clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
82         CALL tra_ldf_iso    ( kt )
83         CALL prt_ctl( tab3d_1=ta, clinfo1=' ldf1 - Ta: ', mask1=tmask,               &
84            &          tab3d_2=sa, clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
85         CALL tra_ldf_bilap  ( kt )
86         CALL prt_ctl( tab3d_1=ta, clinfo1=' ldf2 - Ta: ', mask1=tmask,               &
87            &          tab3d_2=sa, clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
88         CALL tra_ldf_bilapg ( kt )
89         CALL prt_ctl( tab3d_1=ta, clinfo1=' ldf3 - Ta: ', mask1=tmask,               &
90            &          tab3d_2=sa, clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
91      END SELECT
92
93#if defined key_traldf_ano
94      ta(:,:,:) = ta(:,:,:) - t0_ldf(:,:,:)      ! anomaly: substract the reference diffusivity
95      sa(:,:,:) = sa(:,:,:) - s0_ldf(:,:,:)
96#endif
97      IF( l_trdtra )   THEN                      ! save the horizontal diffusive trends for further diagnostics
98         ztrdt(:,:,:) = ta(:,:,:) - ztrdt(:,:,:)
99         ztrds(:,:,:) = sa(:,:,:) - ztrds(:,:,:)
100         CALL trd_mod( ztrdt, ztrds, jptra_trd_ldf, 'TRA', kt )
101      ENDIF
102      !                                          ! print mean trends (used for debugging)
103      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ta, clinfo1=' ldf  - Ta: ', mask1=tmask,               &
104         &                       tab3d_2=sa, clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
105      !
106   END SUBROUTINE tra_ldf
107
108
109   SUBROUTINE ldf_ctl
110      !!----------------------------------------------------------------------
111      !!                  ***  ROUTINE ldf_ctl  ***
112      !!
113      !! ** Purpose :   Choice of the operator for the lateral tracer diffusion
114      !!
115      !! ** Method  :   set nldf from the nam_traldf logicals
116      !!      nldf == -1   ESOPA test: ALL operators are used
117      !!      nldf ==  0   laplacian operator
118      !!      nldf ==  1   Rotated laplacian operator
119      !!      nldf ==  2   bilaplacian operator
120      !!      nldf ==  3   Rotated bilaplacian
121      !!----------------------------------------------------------------------
122      INTEGER ::   ioptio, ierr         ! temporary integers
123!     
124!     NAMELIST/nam_traldf/ ln_traldf_lap  , ln_traldf_bilap,                &
125!        &                 ln_traldf_level, ln_traldf_hor, ln_traldf_iso,   &
126!        &                 aht0, ahtb0, aeiv0
127      !!----------------------------------------------------------------------
128
129      !  Define the lateral mixing oparator for tracers
130      ! ===============================================
131   
132      ! Namelist nam_traldf already read in ldftra module
133!     ! Read Namelist nam_traldf : Lateral physics on tracers
134!     REWIND( numnam )
135!     READ  ( numnam, nam_traldf )
136
137      IF(lwp) THEN                    ! Namelist print
138         WRITE(numout,*)
139         WRITE(numout,*) 'tra:ldf_ctl : lateral tracer diffusive operator'
140         WRITE(numout,*) '~~~~~~~~~~~'
141         WRITE(numout,*) '       Namelist nam_traldf : set lateral mixing parameters (type, direction, coefficients)'
142         WRITE(numout,*) '          laplacian operator          ln_traldf_lap   = ', ln_traldf_lap
143         WRITE(numout,*) '          bilaplacian operator        ln_traldf_bilap = ', ln_traldf_bilap
144         WRITE(numout,*) '          iso-level                   ln_traldf_level = ', ln_traldf_level
145         WRITE(numout,*) '          horizontal (geopotential)   ln_traldf_hor   = ', ln_traldf_hor
146         WRITE(numout,*) '          iso-neutral                 ln_traldf_iso   = ', ln_traldf_iso
147      ENDIF
148
149      !                               ! control the input
150      ioptio = 0
151      IF( ln_traldf_lap   )   ioptio = ioptio + 1
152      IF( ln_traldf_bilap )   ioptio = ioptio + 1
153      IF( ioptio >  1 )   CALL ctl_stop( '          use ONE or NONE of the 2 lap/bilap operator type on tracer' )
154      IF( ioptio == 0 )   nldf = -2   ! No lateral diffusion
155      ioptio = 0
156      IF( ln_traldf_level )   ioptio = ioptio + 1
157      IF( ln_traldf_hor   )   ioptio = ioptio + 1
158      IF( ln_traldf_iso   )   ioptio = ioptio + 1
159      IF( ioptio /= 1 )   CALL ctl_stop( '          use only ONE direction (level/hor/iso)' )
160
161      ! defined the type of lateral diffusion from ln_traldf_... logicals
162      ! CAUTION : nldf = 1 is used in trazdf_imp, change it carefully
163      ierr = 0
164      IF( ln_traldf_lap ) THEN       ! laplacian operator
165         IF ( ln_zco ) THEN                ! z-coordinate
166            IF ( ln_traldf_level )   nldf = 0      ! iso-level  (no rotation)
167            IF ( ln_traldf_hor   )   nldf = 0      ! horizontal (no rotation)
168            IF ( ln_traldf_iso   )   nldf = 1      ! isoneutral (   rotation)
169         ENDIF
170         IF ( ln_zps ) THEN             ! z-coordinate
171            IF ( ln_traldf_level )   ierr = 1      ! iso-level not allowed
172            IF ( ln_traldf_hor   )   nldf = 0      ! horizontal (no rotation)
173            IF ( ln_traldf_iso   )   nldf = 1      ! isoneutral (   rotation)
174         ENDIF
175         IF ( ln_sco ) THEN             ! z-coordinate
176            IF ( ln_traldf_level )   nldf = 0      ! iso-level  (no rotation)
177            IF ( ln_traldf_hor   )   nldf = 1      ! horizontal (   rotation)
178            IF ( ln_traldf_iso   )   nldf = 1      ! isoneutral (   rotation)
179         ENDIF
180      ENDIF
181
182      IF( ln_traldf_bilap ) THEN      ! bilaplacian operator
183         IF ( ln_zco ) THEN                ! z-coordinate
184            IF ( ln_traldf_level )   nldf = 2      ! iso-level  (no rotation)
185            IF ( ln_traldf_hor   )   nldf = 2      ! horizontal (no rotation)
186            IF ( ln_traldf_iso   )   ierr = 2      ! isoneutral (   rotation)
187         ENDIF
188         IF ( ln_zps ) THEN             ! z-coordinate
189            IF ( ln_traldf_level )   ierr = 1      ! iso-level not allowed
190            IF ( ln_traldf_hor   )   nldf = 2      ! horizontal (no rotation)
191            IF ( ln_traldf_iso   )   ierr = 2      ! isoneutral (   rotation)
192         ENDIF
193         IF ( ln_sco ) THEN             ! z-coordinate
194            IF ( ln_traldf_level )   nldf = 2      ! iso-level  (no rotation)
195            IF ( ln_traldf_hor   )   nldf = 3      ! horizontal (   rotation)
196            IF ( ln_traldf_iso   )   ierr = 2      ! isoneutral (   rotation)
197         ENDIF
198      ENDIF
199
200      IF( ierr == 1 )   CALL ctl_stop( ' iso-level in z-coordinate - partial step, not allowed' )
201      IF( ierr == 2 )   CALL ctl_stop( ' isoneutral bilaplacian operator does not exist' )
202      IF( lk_traldf_eiv .AND. .NOT.ln_traldf_iso )   &
203           CALL ctl_stop( '          eddy induced velocity on tracers',   &
204           &              ' the eddy induced velocity on tracers requires isopycnal laplacian diffusion' )
205      IF( nldf == 1 .OR. nldf == 3 ) THEN      ! rotation
206         IF( .NOT.lk_ldfslp )   CALL ctl_stop( '          the rotation of the diffusive tensor require key_ldfslp' )
207      ENDIF
208
209      IF( lk_esopa ) THEN
210         IF(lwp) WRITE(numout,*) '          esopa control: use all lateral physics options'
211         nldf = -1
212      ENDIF
213
214      IF(lwp) THEN
215         WRITE(numout,*)
216         IF( nldf == -2 )   WRITE(numout,*) '          NO lateral diffusion'
217         IF( nldf == -1 )   WRITE(numout,*) '          ESOPA test All scheme used'
218         IF( nldf ==  0 )   WRITE(numout,*) '          laplacian operator'
219         IF( nldf ==  1 )   WRITE(numout,*) '          Rotated laplacian operator'
220         IF( nldf ==  2 )   WRITE(numout,*) '          bilaplacian operator'
221         IF( nldf ==  3 )   WRITE(numout,*) '          Rotated bilaplacian'
222      ENDIF
223
224      ! Reference T & S diffusivity (if necessary)
225      ! ===========================
226      CALL ldf_ano
227      !
228   END SUBROUTINE ldf_ctl
229
230#if defined key_traldf_ano
231   !!----------------------------------------------------------------------
232   !!   'key_traldf_ano'               T & S lateral diffusion on anomalies
233   !!----------------------------------------------------------------------
234
235   SUBROUTINE ldf_ano
236      !!----------------------------------------------------------------------
237      !!                  ***  ROUTINE ldf_ano  ***
238      !!
239      !! ** Purpose :   initializations of
240      !!----------------------------------------------------------------------
241      USE zdf_oce         ! vertical mixing
242      USE trazdf          ! vertical mixing: double diffusion
243      USE zdfddm          ! vertical mixing: double diffusion
244      !!
245      INTEGER  ::   jk              ! Dummy loop indice
246      LOGICAL  ::   llsave          !
247      REAL(wp) ::   zt0, zs0, z12   ! temporary scalar
248      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zt_ref, ztb, zavt   ! 3D workspace
249      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zs_ref, zsb         ! 3D workspace
250      !!----------------------------------------------------------------------
251
252      IF(lwp) THEN
253         WRITE(numout,*)
254         WRITE(numout,*) 'tra:ldf_ano : lateral diffusion acting on anomalies'
255         WRITE(numout,*) '~~~~~~~~~~~'
256      ENDIF
257
258      ! defined the T & S reference profiles
259      ! ------------------------------------
260      zt0 =10.e0                               ! homogeneous ocean
261      zs0 =35.e0
262      zt_ref(:,:,:) = 10.0 * tmask(:,:,:)
263      zs_ref(:,:,:) = 35.0 * tmask(:,:,:)
264      IF(lwp) WRITE(numout,*) '              homogeneous ocean T = ', zt0, ' S = ',zs0
265
266      !                                        ! T & S profile (to be coded +namelist parameter
267
268      ! prepare the ldf computation
269      ! ---------------------------
270      llsave = l_trdtra
271      l_trdtra = .false.      ! desactivate trend computation
272      t0_ldf(:,:,:) = 0.e0
273      s0_ldf(:,:,:) = 0.e0
274      ztb   (:,:,:) = tb (:,:,:)
275      zsb   (:,:,:) = sb (:,:,:)
276      ua    (:,:,:) = ta (:,:,:)
277      va    (:,:,:) = sa (:,:,:)
278      zavt  (:,:,:) = avt(:,:,:)
279      IF( lk_zdfddm ) THEN CALL ctl_stop( ' key_traldf_ano with key_zdfddm not implemented' )
280      ! set tb, sb to reference values and avr to zero
281      tb (:,:,:) = zt_ref(:,:,:)
282      sb (:,:,:) = zs_ref(:,:,:)
283      ta (:,:,:) = 0.e0
284      sa (:,:,:) = 0.e0
285      avt(:,:,:) = 0.e0
286
287      ! Compute the ldf trends
288      ! ----------------------
289      CALL tra_ldf( nit000+1 )      ! horizontal components (+1: no more init)
290      CALL tra_zdf( nit000   )      ! vertical component (if necessary nit000 to performed the init)
291
292      ! finalise the computation and recover all arrays
293      ! -----------------------------------------------
294      l_trdtra = llsave
295      z12 = 2.e0
296      IF( neuler == 1)   z12 = 1.e0
297      IF( ln_zdfexp ) THEN      ! ta,sa are the trends
298         t0_ldf(:,:,:) = ta(:,:,:)
299         s0_ldf(:,:,:) = sa(:,:,:)
300      ELSE
301         DO jk = 1, jpkm1
302            t0_ldf(:,:,jk) = ( ta(:,:,jk) - tb(:,:,jk) ) / ( z12 *rdttra(jk) )
303            s0_ldf(:,:,jk) = ( sa(:,:,jk) - tb(:,:,jk) ) / ( z12 *rdttra(jk) )
304         END DO
305      ENDIF
306      tb    (:,:,:) = ztb (:,:,:)
307      sb    (:,:,:) = zsb (:,:,:)
308      ta    (:,:,:) = ua  (:,:,:)
309      sa    (:,:,:) = va  (:,:,:)
310      avt   (:,:,:) = zavt(:,:,:)
311      !
312   END SUBROUTINE ldf_ano
313
314#else
315   !!----------------------------------------------------------------------
316   !!   default option :   Dummy code   NO T & S background profiles
317   !!----------------------------------------------------------------------
318   SUBROUTINE ldf_ano
319      IF(lwp) THEN
320         WRITE(numout,*)
321         WRITE(numout,*) 'tra:ldf_ano : lateral diffusion acting on the full fields'
322         WRITE(numout,*) '~~~~~~~~~~~'
323      ENDIF
324   END SUBROUTINE ldf_ano
325#endif
326
327   !!======================================================================
328END MODULE traldf
Note: See TracBrowser for help on using the repository browser.