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

source: branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/TRA/traldf.F90 @ 2236

Last change on this file since 2236 was 2236, checked in by cetlod, 13 years ago

First guess of NEMO_v3.3

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