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/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/TRA – NEMO

source: branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/TRA/traldf.F90 @ 3115

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

Add in branch 2011/dev_LOCEAN_2011 changes from 2011/dev_r2787_PISCES_improvment, 2011/dev_r2787_LOCEAN_offline_fldread and 2011/dev_r2787_LOCEAN3_TRA_TRP branches, see ticket #877

  • Property svn:keywords set to Id
File size: 16.8 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
40   REAL, SAVE, ALLOCATABLE, DIMENSION(:,:,:) ::   t0_ldf, s0_ldf   !: lateral diffusion trends of T & S for a cst profile
41   !                                                               !  (key_traldf_ano only)
42
43   !! * Substitutions
44#  include "domzgr_substitute.h90"
45#  include "vectopt_loop_substitute.h90"
46   !!----------------------------------------------------------------------
47   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
48   !! $Id$
49   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
50   !!----------------------------------------------------------------------
51CONTAINS
52
53   SUBROUTINE tra_ldf( kt )
54      !!----------------------------------------------------------------------
55      !!                  ***  ROUTINE tra_ldf  ***
56      !!
57      !! ** Purpose :   compute the lateral ocean tracer physics.
58      !!----------------------------------------------------------------------
59      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
60      !!
61      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  ztrdt, ztrds
62      !!----------------------------------------------------------------------
63
64      rldf = 1     ! For active tracers the
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 )                                                                              ! rotated laplacian
74         IF( ln_traldf_grif ) THEN                                                         
75                       CALL tra_ldf_iso_grif( kt, 'TRA', gtsu, gtsv, tsb, tsa, jpts, ahtb0 )      ! Griffies operator
76         ELSE                                                                               
77                       CALL tra_ldf_iso     ( kt, 'TRA', gtsu, gtsv, tsb, tsa, jpts, ahtb0 )      ! Madec operator
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. geopot. 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, 'TRA', gtsu, gtsv, tsb, tsa, jpts, ahtb0 )
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
136      !  Define the lateral mixing oparator for tracers
137      ! ===============================================
138   
139      IF(lwp) THEN                    ! Namelist print
140         WRITE(numout,*)
141         WRITE(numout,*) 'tra_ldf_init : lateral tracer diffusive operator'
142         WRITE(numout,*) '~~~~~~~~~~~'
143         WRITE(numout,*) '   Namelist namtra_ldf already read in ldftra module'
144         WRITE(numout,*) '   see ldf_tra_init report for lateral mixing parameters'
145         WRITE(numout,*)
146      ENDIF
147
148      !                               ! control the input
149      ioptio = 0
150      IF( ln_traldf_lap   )   ioptio = ioptio + 1
151      IF( ln_traldf_bilap )   ioptio = ioptio + 1
152      IF( ioptio >  1 )   CALL ctl_stop( '          use ONE or NONE of the 2 lap/bilap operator type on tracer' )
153      IF( ioptio == 0 )   nldf = -2   ! No lateral diffusion
154      ioptio = 0
155      IF( ln_traldf_level )   ioptio = ioptio + 1
156      IF( ln_traldf_hor   )   ioptio = ioptio + 1
157      IF( ln_traldf_iso   )   ioptio = ioptio + 1
158      IF( ioptio /= 1 )   CALL ctl_stop( '          use only ONE direction (level/hor/iso)' )
159
160      ! defined the type of lateral diffusion from ln_traldf_... logicals
161      ! CAUTION : nldf = 1 is used in trazdf_imp, change it carefully
162      ierr = 0
163      IF( ln_traldf_lap ) THEN       ! laplacian operator
164         IF ( ln_zco ) THEN                ! z-coordinate
165            IF ( ln_traldf_level )   nldf = 0      ! iso-level  (no rotation)
166            IF ( ln_traldf_hor   )   nldf = 0      ! horizontal (no rotation)
167            IF ( ln_traldf_iso   )   nldf = 1      ! isoneutral (   rotation)
168         ENDIF
169         IF ( ln_zps ) THEN             ! z-coordinate
170            IF ( ln_traldf_level )   ierr = 1      ! iso-level not allowed
171            IF ( ln_traldf_hor   )   nldf = 0      ! horizontal (no rotation)
172            IF ( ln_traldf_iso   )   nldf = 1      ! isoneutral (   rotation)
173         ENDIF
174         IF ( ln_sco ) THEN             ! z-coordinate
175            IF ( ln_traldf_level )   nldf = 0      ! iso-level  (no rotation)
176            IF ( ln_traldf_hor   )   nldf = 1      ! horizontal (   rotation)
177            IF ( ln_traldf_iso   )   nldf = 1      ! isoneutral (   rotation)
178         ENDIF
179      ENDIF
180
181      IF( ln_traldf_bilap ) THEN      ! bilaplacian operator
182         IF ( ln_zco ) THEN                ! z-coordinate
183            IF ( ln_traldf_level )   nldf = 2      ! iso-level  (no rotation)
184            IF ( ln_traldf_hor   )   nldf = 2      ! horizontal (no rotation)
185            IF ( ln_traldf_iso   )   ierr = 2      ! isoneutral (   rotation)
186         ENDIF
187         IF ( ln_zps ) THEN             ! z-coordinate
188            IF ( ln_traldf_level )   ierr = 1      ! iso-level not allowed
189            IF ( ln_traldf_hor   )   nldf = 2      ! horizontal (no rotation)
190            IF ( ln_traldf_iso   )   ierr = 2      ! isoneutral (   rotation)
191         ENDIF
192         IF ( ln_sco ) THEN             ! z-coordinate
193            IF ( ln_traldf_level )   nldf = 2      ! iso-level  (no rotation)
194            IF ( ln_traldf_hor   )   nldf = 3      ! horizontal (   rotation)
195            IF ( ln_traldf_iso   )   ierr = 2      ! isoneutral (   rotation)
196         ENDIF
197      ENDIF
198
199      IF( ierr == 1 )   CALL ctl_stop( ' iso-level in z-coordinate - partial step, not allowed' )
200      IF( ierr == 2 )   CALL ctl_stop( ' isoneutral bilaplacian operator does not exist' )
201      IF( lk_traldf_eiv .AND. .NOT.ln_traldf_iso )   &
202           CALL ctl_stop( '          eddy induced velocity on tracers',   &
203           &              ' the eddy induced velocity on tracers requires isopycnal laplacian diffusion' )
204      IF( nldf == 1 .OR. nldf == 3 ) THEN      ! rotation
205         IF( .NOT.lk_ldfslp )   CALL ctl_stop( '          the rotation of the diffusive tensor require key_ldfslp' )
206         l_traldf_rot = .TRUE.                 ! needed for trazdf_imp
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 tra_ldf_init
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 wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
242      USE wrk_nemo, ONLY:   zt_ref => wrk_3d_1, ztb => wrk_3d_2, zavt => wrk_3d_3   ! 3D workspaces
243      USE wrk_nemo, ONLY:   zs_ref => wrk_3d_4, zsb => wrk_3d_5                     ! 3D workspaces
244      !
245      USE zdf_oce         ! vertical mixing
246      USE trazdf          ! vertical mixing: double diffusion
247      USE zdfddm          ! vertical mixing: double diffusion
248      !
249      INTEGER  ::   jk              ! Dummy loop indice
250      INTEGER  ::   ierr            ! local integer
251      LOGICAL  ::   llsave          ! local logical
252      REAL(wp) ::   zt0, zs0, z12   ! local scalar
253      !!----------------------------------------------------------------------
254
255      IF( wrk_in_use(3, 1,2,3,4,5) ) THEN
256         CALL ctl_stop('ldf_ano : requested workspace arrays unavailable')   ;   RETURN
257      ENDIF
258
259      IF(lwp) THEN
260         WRITE(numout,*)
261         WRITE(numout,*) 'tra:ldf_ano : lateral diffusion acting on anomalies'
262         WRITE(numout,*) '~~~~~~~~~~~'
263      ENDIF
264
265      !                              ! allocate trabbl arrays
266      ALLOCATE( t0_ldf(jpi,jpj,jpk) , s0_ldf(jpi,jpj,jpk) , STAT=ierr )
267      IF( lk_mpp    )   CALL mpp_sum( ierr )
268      IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'ldf_ano: unable to allocate arrays' )
269
270      ! defined the T & S reference profiles
271      ! ------------------------------------
272      zt0 =10.e0                               ! homogeneous ocean
273      zs0 =35.e0
274      zt_ref(:,:,:) = 10.0 * tmask(:,:,:)
275      zs_ref(:,:,:) = 35.0 * tmask(:,:,:)
276      IF(lwp) WRITE(numout,*) '              homogeneous ocean T = ', zt0, ' S = ',zs0
277
278      !                                        ! T & S profile (to be coded +namelist parameter
279
280      ! prepare the ldf computation
281      ! ---------------------------
282      llsave = l_trdtra
283      l_trdtra = .false.      ! desactivate trend computation
284      t0_ldf(:,:,:) = 0.e0
285      s0_ldf(:,:,:) = 0.e0
286      ztb   (:,:,:) = tsb (:,:,:,jp_tem)
287      zsb   (:,:,:) = tsb (:,:,:,jp_sal)
288      ua    (:,:,:) = tsa (:,:,:,jp_tem)
289      va    (:,:,:) = tsa (:,:,:,jp_sal)
290      zavt  (:,:,:) = avt(:,:,:)
291      IF( lk_zdfddm ) THEN CALL ctl_stop( ' key_traldf_ano with key_zdfddm not implemented' )
292      ! set tb, sb to reference values and avr to zero
293      tsb (:,:,:,jp_tem) = zt_ref(:,:,:)
294      tsb (:,:,:,jp_sal) = zs_ref(:,:,:)
295      tsa (:,:,:,jp_tem) = 0.e0
296      tsa (:,:,:,jp_sal) = 0.e0
297      avt(:,:,:)         = 0.e0
298
299      ! Compute the ldf trends
300      ! ----------------------
301      CALL tra_ldf( nit000+1 )      ! horizontal components (+1: no more init)
302      CALL tra_zdf( nit000   )      ! vertical component (if necessary nit000 to performed the init)
303
304      ! finalise the computation and recover all arrays
305      ! -----------------------------------------------
306      l_trdtra = llsave
307      z12 = 2.e0
308      IF( neuler == 1)   z12 = 1.e0
309      IF( ln_zdfexp ) THEN      ! ta,sa are the trends
310         t0_ldf(:,:,:) = tsa(:,:,:,jp_tem)
311         s0_ldf(:,:,:) = tsa(:,:,:,jp_sal)
312      ELSE
313         DO jk = 1, jpkm1
314            t0_ldf(:,:,jk) = ( tsa(:,:,jk,jp_tem) - tsb(:,:,jk,jp_tem) ) / ( z12 *rdttra(jk) )
315            s0_ldf(:,:,jk) = ( tsa(:,:,jk,jp_sal) - tsb(:,:,jk,jp_sal) ) / ( z12 *rdttra(jk) )
316         END DO
317      ENDIF
318      tsb(:,:,:,jp_tem) = ztb (:,:,:)
319      tsb(:,:,:,jp_sal) = zsb (:,:,:)
320      tsa(:,:,:,jp_tem) = ua  (:,:,:)
321      tsa(:,:,:,jp_sal) = va  (:,:,:)
322      avt(:,:,:)        = zavt(:,:,:)
323      !
324      IF( wrk_not_released(3, 1,2,3,4,5) )   CALL ctl_stop('ldf_ano: failed to release workspace arrays')
325      !
326   END SUBROUTINE ldf_ano
327
328#else
329   !!----------------------------------------------------------------------
330   !!   default option :   Dummy code   NO T & S background profiles
331   !!----------------------------------------------------------------------
332   SUBROUTINE ldf_ano
333      IF(lwp) THEN
334         WRITE(numout,*)
335         WRITE(numout,*) 'tra:ldf_ano : lateral diffusion acting on the full fields'
336         WRITE(numout,*) '~~~~~~~~~~~'
337      ENDIF
338   END SUBROUTINE ldf_ano
339#endif
340
341   !!======================================================================
342END MODULE traldf
Note: See TracBrowser for help on using the repository browser.