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.
trcldf.F90 in branches/2017/dev_merge_2017/NEMOGCM/NEMO/TOP_SRC/TRP – NEMO

source: branches/2017/dev_merge_2017/NEMOGCM/NEMO/TOP_SRC/TRP/trcldf.F90 @ 9125

Last change on this file since 9125 was 9125, checked in by timgraham, 6 years ago

Removed wrk_arrays from whole code. No change in SETTE results from this.

  • Property svn:keywords set to Id
File size: 15.7 KB
Line 
1MODULE trcldf
2   !!======================================================================
3   !!                       ***  MODULE  trcldf  ***
4   !! Ocean Passive tracers : lateral diffusive trends
5   !!=====================================================================
6   !! History :  1.0  ! 2005-11  (G. Madec)  Original code
7   !!            3.0  ! 2008-01  (C. Ethe, G. Madec)  merge TRC-TRA
8   !!            3.7  ! 2014-03  (G. Madec)  LDF simplification
9   !!----------------------------------------------------------------------
10#if defined key_top
11   !!----------------------------------------------------------------------
12   !!   'key_top'                                                TOP models
13   !!----------------------------------------------------------------------
14   !!   trc_ldf       : update the tracer trend with the lateral diffusion
15   !!   trc_ldf_ini   : initialization, namelist read, and parameters control
16   !!----------------------------------------------------------------------
17   USE trc            ! ocean passive tracers variables
18   USE oce_trc        ! ocean dynamics and active tracers
19   USE ldftra         ! lateral diffusion: eddy diffusivity & EIV coeff.
20   USE ldfslp         ! Lateral diffusion: slopes of neutral surfaces
21   USE traldf_lap_blp ! lateral diffusion: lap/bilaplacian iso-level      operator  (tra_ldf_lap/_blp   routine)
22   USE traldf_iso     ! lateral diffusion: laplacian iso-neutral standard operator  (tra_ldf_iso        routine)
23   USE traldf_triad   ! lateral diffusion: laplacian iso-neutral triad    operator  (tra_ldf_     triad routine)
24   USE trd_oce        ! trends: ocean variables
25   USE trdtra         ! trends manager: tracers
26   !
27   USE prtctl_trc     ! Print control
28
29   IMPLICIT NONE
30   PRIVATE
31
32   PUBLIC   trc_ldf   
33   PUBLIC   trc_ldf_ini   
34   !
35   LOGICAL , PUBLIC ::   ln_trcldf_NONE      !: No operator (no explicit lateral diffusion)
36   LOGICAL , PUBLIC ::   ln_trcldf_lap       !:   laplacian operator
37   LOGICAL , PUBLIC ::   ln_trcldf_blp       !: bilaplacian operator
38   LOGICAL , PUBLIC ::   ln_trcldf_lev       !: iso-level   direction
39   LOGICAL , PUBLIC ::   ln_trcldf_hor       !: horizontal  direction (rotation to geopotential)
40   LOGICAL , PUBLIC ::   ln_trcldf_iso       !: iso-neutral direction (standard)
41   LOGICAL , PUBLIC ::   ln_trcldf_triad     !: iso-neutral direction (triad)
42   REAL(wp), PUBLIC ::   rn_ahtrc_0          !:   laplacian diffusivity coefficient for passive tracer [m2/s]
43   REAL(wp), PUBLIC ::   rn_bhtrc_0          !: bilaplacian      -          --     -       -   [m4/s]
44   REAL(wp), PUBLIC ::   rn_fact_lap         !: Enhanced zonal diffusivity coefficent in the equatorial domain
45   !
46   !                      !!: ** lateral mixing namelist (nam_trcldf) **
47   REAL(wp) ::  rldf       ! ratio between active and passive tracers diffusive coefficient
48   
49   INTEGER  ::  nldf       ! type of lateral diffusion used defined from ln_trcldf_... namlist logicals)
50   
51   !! * Substitutions
52#  include "vectopt_loop_substitute.h90"
53   !!----------------------------------------------------------------------
54   !! NEMO/TOP 3.7 , NEMO Consortium (2014)
55   !! $Id$
56   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
57   !!----------------------------------------------------------------------
58CONTAINS
59
60   SUBROUTINE trc_ldf( kt )
61      !!----------------------------------------------------------------------
62      !!                  ***  ROUTINE tra_ldf  ***
63      !!
64      !! ** Purpose :   compute the lateral ocean tracer physics.
65      !!
66      !!----------------------------------------------------------------------
67      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
68      !
69      INTEGER            :: ji, jj, jk, jn
70      REAL(wp)           :: zdep
71      CHARACTER (len=22) :: charout
72      REAL(wp), DIMENSION(jpi,jpj,jpk)   ::   zahu, zahv
73      REAL(wp), POINTER, DIMENSION(:,:,:,:) ::   ztrtrd
74      !!----------------------------------------------------------------------
75      !
76      IF( ln_timing )   CALL timing_start('trc_ldf')
77      !
78      IF( l_trdtrc )  THEN
79         ALLOCATE( ztrtrd(jpi,jpj,jpk,jptra) )
80         ztrtrd(:,:,:,:)  = tra(:,:,:,:)
81      ENDIF
82      !                                  !* set the lateral diffusivity coef. for passive tracer     
83      zahu(:,:,:) = rldf * ahtu(:,:,:) 
84      zahv(:,:,:) = rldf * ahtv(:,:,:)
85      !                                  !* Enhanced zonal diffusivity coefficent in the equatorial domain
86      DO jk= 1, jpk
87         DO jj = 1, jpj
88            DO ji = 1, jpi
89               IF( gdept_n(ji,jj,jk) > 200. .AND. gphit(ji,jj) < 5. .AND. gphit(ji,jj) > -5. ) THEN
90                  zdep = MAX( gdept_n(ji,jj,jk) - 1000., 0. ) / 1000.
91                  zahu(ji,jj,jk) = zahu(ji,jj,jk) * MAX( 1., rn_fact_lap * EXP( -zdep ) )
92               ENDIF
93            END DO
94         END DO
95      END DO
96      !
97      SELECT CASE ( nldf )                     !* compute lateral mixing trend and add it to the general trend
98      !
99      CASE ( np_lap   )                               ! iso-level laplacian
100         CALL tra_ldf_lap  ( kt, nittrc000,'TRC', zahu, zahv, gtru, gtrv, gtrui, gtrvi, trb,      tra, jptra,  1   )
101      CASE ( np_lap_i )                               ! laplacian : standard iso-neutral operator (Madec)
102         CALL tra_ldf_iso  ( kt, nittrc000,'TRC', zahu, zahv, gtru, gtrv, gtrui, gtrvi, trb, trb, tra, jptra,  1   )
103      CASE ( np_lap_it )                              ! laplacian : triad iso-neutral operator (griffies)
104         CALL tra_ldf_triad( kt, nittrc000,'TRC', zahu, zahv, gtru, gtrv, gtrui, gtrvi, trb, trb, tra, jptra,  1   )
105      CASE ( np_blp , np_blp_i , np_blp_it )          ! bilaplacian: all operator (iso-level, -neutral)
106         CALL tra_ldf_blp  ( kt, nittrc000,'TRC', zahu, zahv, gtru, gtrv, gtrui, gtrvi, trb     , tra, jptra, nldf )
107      END SELECT
108      !
109      IF( l_trdtrc )   THEN                    ! send the trends for further diagnostics
110        DO jn = 1, jptra
111           ztrtrd(:,:,:,jn) = tra(:,:,:,jn) - ztrtrd(:,:,:,jn)
112           CALL trd_tra( kt, 'TRC', jn, jptra_ldf, ztrtrd(:,:,:,jn) )
113        END DO
114        DEALLOCATE( ztrtrd )
115      ENDIF
116      !               
117      IF( ln_ctl ) THEN                        ! print mean trends (used for debugging)
118         WRITE(charout, FMT="('ldf ')")
119         CALL prt_ctl_trc_info(charout)
120         CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
121      ENDIF
122      !
123      IF( ln_timing )   CALL timing_stop('trc_ldf')
124      !
125   END SUBROUTINE trc_ldf
126
127
128   SUBROUTINE trc_ldf_ini
129      !!----------------------------------------------------------------------
130      !!                  ***  ROUTINE ldf_ctl  ***
131      !!
132      !! ** Purpose :   Define the operator for the lateral diffusion
133      !!
134      !! ** Method  :   set nldf from the namtra_ldf logicals
135      !!      nldf ==  0   laplacian operator
136      !!      nldf ==  1   Rotated laplacian operator
137      !!      nldf ==  2   bilaplacian operator
138      !!      nldf ==  3   Rotated bilaplacian
139      !!----------------------------------------------------------------------
140      INTEGER ::   ioptio, ierr   ! temporary integers
141      INTEGER ::   ios            ! Local integer output status for namelist read
142      !!
143      NAMELIST/namtrc_ldf/ ln_trcldf_lap, ln_trcldf_blp,                                  &
144         &                 ln_trcldf_lev, ln_trcldf_hor, ln_trcldf_iso, ln_trcldf_triad,  &
145         &                 rn_ahtrc_0   , rn_bhtrc_0   , rn_fact_lap 
146      !!----------------------------------------------------------------------
147      !
148      REWIND( numnat_ref )             !  namtrc_ldf in reference namelist
149      READ  ( numnat_ref, namtrc_ldf, IOSTAT = ios, ERR = 903)
150903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc_ldf in reference namelist', lwp )
151      !
152      REWIND( numnat_cfg )             !  namtrc_ldf in configuration namelist
153      READ  ( numnat_cfg, namtrc_ldf, IOSTAT = ios, ERR = 904 )
154904   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc_ldf in configuration namelist', lwp )
155      IF(lwm) WRITE ( numont, namtrc_ldf )
156      !
157      IF(lwp) THEN                     ! Namelist print
158         WRITE(numout,*)
159         WRITE(numout,*) 'trc_ldf_ini : lateral tracer diffusive operator'
160         WRITE(numout,*) '~~~~~~~~~~~'
161         WRITE(numout,*) '   Namelist namtrc_ldf : set lateral mixing parameters (type, direction, coefficients)'
162         WRITE(numout,*) '      operator'
163         WRITE(numout,*) '         no explicit diffusion       ln_trcldf_NONE  = ', ln_trcldf_NONE
164         WRITE(numout,*) '           laplacian                 ln_trcldf_lap   = ', ln_trcldf_lap
165         WRITE(numout,*) '         bilaplacian                 ln_trcldf_blp   = ', ln_trcldf_blp
166         WRITE(numout,*) '      direction of action'
167         WRITE(numout,*) '         iso-level                   ln_trcldf_lev   = ', ln_trcldf_lev
168         WRITE(numout,*) '         horizontal (geopotential)   ln_trcldf_hor   = ', ln_trcldf_hor
169         WRITE(numout,*) '         iso-neutral (standard)      ln_trcldf_iso   = ', ln_trcldf_iso
170         WRITE(numout,*) '         iso-neutral (triad)         ln_trcldf_triad = ', ln_trcldf_triad
171         WRITE(numout,*) '      diffusivity coefficient'
172         WRITE(numout,*) '           laplacian                 rn_ahtrc_0      = ', rn_ahtrc_0
173         WRITE(numout,*) '         bilaplacian                 rn_bhtrc_0      = ', rn_bhtrc_0
174         WRITE(numout,*) '      enhanced zonal diffusivity     rn_fact_lap     = ', rn_fact_lap
175
176      ENDIF
177      !     
178      !                                ! control the namelist parameters
179      ioptio = 0
180      IF( ln_trcldf_NONE ) THEN   ;   nldf = np_no_ldf   ;   ioptio = ioptio + 1   ;   ENDIF
181      IF( ln_trcldf_lap  ) THEN   ;                          ioptio = ioptio + 1   ;   ENDIF
182      IF( ln_trcldf_blp  ) THEN   ;                          ioptio = ioptio + 1   ;   ENDIF
183      IF( ioptio /=  1   )   CALL ctl_stop( 'trc_ldf_ini: use ONE of the 3 operator options (NONE/lap/blp)' )
184     
185      IF( ln_trcldf_lap .AND. .NOT.ln_traldf_lap )   CALL ctl_stop( 'trc_ldf_ini:   laplacian should be used on both TRC and TRA' )
186      IF( ln_trcldf_blp .AND. .NOT.ln_traldf_blp )   CALL ctl_stop( 'trc_ldf_ini: bilaplacian should be used on both TRC and TRA' )
187      !
188      IF( .NOT.ln_trcldf_NONE ) THEN   ! direction ==>> type of operator
189         ioptio = 0
190         IF( ln_trcldf_lev )   ioptio = ioptio + 1
191         IF( ln_trcldf_hor )   ioptio = ioptio + 1
192         IF( ln_trcldf_iso )   ioptio = ioptio + 1
193         IF( ioptio /= 1   )   CALL ctl_stop( 'trc_ldf_ini: use ONE direction (level/hor/iso)' )
194         !
195         ! defined the type of lateral diffusion from ln_trcldf_... logicals
196         ! CAUTION : nldf = 1 is used in trazdf_imp, change it carefully
197         ierr = 0
198         IF( ln_trcldf_lap ) THEN      !==  laplacian operator  ==!
199            IF( ln_zco ) THEN                ! z-coordinate
200               IF( ln_trcldf_lev   )   nldf = np_lap     ! iso-level = horizontal (no rotation)
201               IF( ln_trcldf_hor   )   nldf = np_lap     ! iso-level = horizontal (no rotation)
202               IF( ln_trcldf_iso   )   nldf = np_lap_i   ! iso-neutral: standard  (   rotation)
203               IF( ln_trcldf_triad )   nldf = np_lap_it  ! iso-neutral: triad     (   rotation)
204            ENDIF
205            IF( ln_zps ) THEN             ! z-coordinate with partial step
206               IF( ln_trcldf_lev   )   ierr = 1          ! iso-level not allowed
207               IF( ln_trcldf_hor   )   nldf = np_lap     ! horizontal (no rotation)
208               IF( ln_trcldf_iso   )   nldf = np_lap_i   ! iso-neutral: standard (rotation)
209               IF( ln_trcldf_triad )   nldf = np_lap_it  ! iso-neutral: triad    (rotation)
210            ENDIF
211            IF( ln_sco ) THEN             ! s-coordinate
212               IF( ln_trcldf_lev   )   nldf = np_lap     ! iso-level  (no rotation)
213               IF( ln_trcldf_hor   )   nldf = np_lap_it  ! horizontal (   rotation)       !!gm   a checker....
214               IF( ln_trcldf_iso   )   nldf = np_lap_i   ! iso-neutral: standard (rotation)
215               IF( ln_trcldf_triad )   nldf = np_lap_it  ! iso-neutral: triad    (rotation)
216            ENDIF
217            !                                ! diffusivity ratio: passive / active tracers
218            IF( ABS(rn_aht_0) < 2._wp*TINY(1._wp) ) THEN
219               IF( ABS(rn_ahtrc_0) < 2._wp*TINY(1._wp) ) THEN
220                  rldf = 1.0_wp
221               ELSE
222                  CALL ctl_stop( 'trc_ldf_ctl : cannot define rldf, rn_aht_0==0, rn_ahtrc_0 /=0' )
223               ENDIF
224            ELSE
225               rldf = rn_ahtrc_0 / rn_aht_0
226            ENDIF
227         ENDIF
228         !
229         IF( ln_trcldf_blp ) THEN      !==  bilaplacian operator  ==!
230            IF ( ln_zco ) THEN                ! z-coordinate
231               IF ( ln_trcldf_lev   )   nldf = np_blp     ! iso-level = horizontal (no rotation)
232               IF ( ln_trcldf_hor   )   nldf = np_blp     ! iso-level = horizontal (no rotation)
233               IF ( ln_trcldf_iso   )   nldf = np_blp_i   ! iso-neutral: standard (rotation)
234               IF ( ln_trcldf_triad )   nldf = np_blp_it  ! iso-neutral: triad    (rotation)
235            ENDIF
236            IF ( ln_zps ) THEN             ! z-coordinate with partial step
237               IF ( ln_trcldf_lev   )   ierr = 1         ! iso-level not allowed
238               IF ( ln_trcldf_hor   )   nldf = np_blp     ! horizontal (no rotation)
239               IF ( ln_trcldf_iso   )   nldf = np_blp_i   ! iso-neutral: standard (rotation)
240               IF ( ln_trcldf_triad )   nldf = np_blp_it  ! iso-neutral: triad    (rotation)
241            ENDIF
242            IF ( ln_sco ) THEN             ! s-coordinate
243               IF ( ln_trcldf_lev   )   nldf = np_blp     ! iso-level  (no rotation)
244               IF ( ln_trcldf_hor   )   nldf = np_blp_it  ! horizontal (   rotation)       !!gm   a checker....
245               IF ( ln_trcldf_iso   )   nldf = np_blp_i   ! iso-neutral: standard (rotation)
246               IF ( ln_trcldf_triad )   nldf = np_blp_it  ! iso-neutral: triad    (rotation)
247            ENDIF
248            !                                ! diffusivity ratio: passive / active tracers
249            IF( ABS(rn_bht_0) < 2._wp*TINY(1._wp) ) THEN
250               IF( ABS(rn_bhtrc_0) < 2._wp*TINY(1._wp) ) THEN
251                  rldf = 1.0_wp
252               ELSE
253                  CALL ctl_stop( 'trc_ldf_ctl : cannot define rldf, rn_aht_0==0, rn_ahtrc_0 /=0' )
254               ENDIF
255            ELSE
256               rldf = SQRT(  ABS( rn_bhtrc_0 / rn_bht_0 )  )
257            ENDIF
258         ENDIF
259         !
260         IF( ierr == 1 )   CALL ctl_stop( 'trc_ldf_ini: iso-level in z-partial step, not allowed' )
261      ENDIF
262      !
263      IF( ln_ldfeiv .AND. .NOT.ln_trcldf_iso )   CALL ctl_stop( 'trc_ldf_ini: eiv requires isopycnal laplacian diffusion' )
264      IF( nldf == 1 .OR. nldf == 3 )   l_ldfslp = .TRUE.    ! slope of neutral surfaces required
265      !
266      IF(lwp) THEN
267         WRITE(numout,*)
268         SELECT CASE( nldf )
269         CASE( np_no_ldf )   ;   WRITE(numout,*) '      ===>>   NO lateral diffusion'
270         CASE( np_lap    )   ;   WRITE(numout,*) '      ===>>   laplacian iso-level operator'
271         CASE( np_lap_i  )   ;   WRITE(numout,*) '      ===>>   Rotated laplacian operator (standard)'
272         CASE( np_lap_it )   ;   WRITE(numout,*) '      ===>>   Rotated laplacian operator (triad)'
273         CASE( np_blp    )   ;   WRITE(numout,*) '      ===>>   bilaplacian iso-level operator'
274         CASE( np_blp_i  )   ;   WRITE(numout,*) '      ===>>   Rotated bilaplacian operator (standard)'
275         CASE( np_blp_it )   ;   WRITE(numout,*) '      ===>>   Rotated bilaplacian operator (triad)'
276         END SELECT
277      ENDIF
278      !
279   END SUBROUTINE trc_ldf_ini
280
281#endif
282   !!======================================================================
283END MODULE trcldf
Note: See TracBrowser for help on using the repository browser.