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

Last change on this file since 480 was 474, checked in by opalod, 18 years ago

nemo_v1_update_061: SM: end of ctl_stop + mpi optimization in _bilap

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