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/UKMO/r5936_hadgem3_cplseq/NEMOGCM/NEMO/TOP_SRC/TRP – NEMO

source: branches/UKMO/r5936_hadgem3_cplseq/NEMOGCM/NEMO/TOP_SRC/TRP/trcldf.F90 @ 7131

Last change on this file since 7131 was 7131, checked in by jcastill, 7 years ago

Remove svn keywords

File size: 15.2 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 ldfslp        ! lateral diffusion: iso-neutral slope
20   USE traldf_lap    ! lateral diffusion: laplacian iso-level            operator  (tra_ldf_lap   routine)
21   USE traldf_iso    ! lateral diffusion: laplacian iso-neutral standard operator  (tra_ldf_iso   routine)
22   USE traldf_triad  ! lateral diffusion: laplacian iso-neutral triad    operator  (tra_ldf_triad routine)
23   USE traldf_blp    ! lateral diffusion (iso-level lap/blp)                       (tra_ldf_lap   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_lap       !:   laplacian operator
36   LOGICAL , PUBLIC ::   ln_trcldf_blp       !: bilaplacian operator
37   LOGICAL , PUBLIC ::   ln_trcldf_lev       !: iso-level   direction
38   LOGICAL , PUBLIC ::   ln_trcldf_hor       !: horizontal  direction (rotation to geopotential)
39   LOGICAL , PUBLIC ::   ln_trcldf_iso       !: iso-neutral direction (standard)
40   LOGICAL , PUBLIC ::   ln_trcldf_triad     !: iso-neutral direction (triad)
41   REAL(wp), PUBLIC ::   rn_ahtrc_0          !:   laplacian diffusivity coefficient for passive tracer [m2/s]
42   REAL(wp), PUBLIC ::   rn_bhtrc_0          !: bilaplacian      -          --     -       -   [m4/s]
43   !
44                                                 !!: ** lateral mixing namelist (nam_trcldf) **
45   REAL(wp) ::  rldf    ! ratio between active and passive tracers diffusive coefficient
46   INTEGER  ::  nldf = 0   ! type of lateral diffusion used defined from ln_trcldf_... namlist logicals)
47   
48   !! * Substitutions
49#  include "domzgr_substitute.h90"
50#  include "vectopt_loop_substitute.h90"
51   !!----------------------------------------------------------------------
52   !! NEMO/TOP 3.7 , NEMO Consortium (2014)
53   !! $Id$
54   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
55   !!----------------------------------------------------------------------
56CONTAINS
57
58   SUBROUTINE trc_ldf( kt )
59      !!----------------------------------------------------------------------
60      !!                  ***  ROUTINE tra_ldf  ***
61      !!
62      !! ** Purpose :   compute the lateral ocean tracer physics.
63      !!
64      !!----------------------------------------------------------------------
65      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
66      !!
67      INTEGER            :: jn
68      CHARACTER (len=22) :: charout
69      REAL(wp), POINTER, DIMENSION(:,:,:)   ::   zahu, zahv
70      REAL(wp), POINTER, DIMENSION(:,:,:,:) ::   ztrtrd
71      !!----------------------------------------------------------------------
72      !
73      IF( nn_timing == 1 )   CALL timing_start('trc_ldf')
74      !
75      IF( l_trdtrc )  THEN
76         CALL wrk_alloc( jpi,jpj,jpk,jptra,   ztrtrd )
77         ztrtrd(:,:,:,:)  = tra(:,:,:,:)
78      ENDIF
79      !
80      !                                        !* set the lateral diffusivity coef. for passive tracer     
81      CALL wrk_alloc( jpi,jpj,jpk,   zahu, zahv )
82      zahu(:,:,:) = rldf * ahtu(:,:,:)
83      zahv(:,:,:) = rldf * ahtv(:,:,:)
84
85      SELECT CASE ( nldf )                     !* compute lateral mixing trend and add it to the general trend
86      !
87      CASE ( np_lap   )                               ! iso-level laplacian
88         CALL tra_ldf_lap  ( kt, nittrc000,'TRC', zahu, zahv, gtru, gtrv, gtrui, gtrvi, trb,      tra, jptra,  1   )
89         !
90      CASE ( np_lap_i )                               ! laplacian : standard iso-neutral operator (Madec)
91         CALL tra_ldf_iso  ( kt, nittrc000,'TRC', zahu, zahv, gtru, gtrv, gtrui, gtrvi, trb, trb, tra, jptra,  1   )
92         !
93      CASE ( np_lap_it )                              ! laplacian : triad iso-neutral operator (griffies)
94         CALL tra_ldf_triad( kt, nittrc000,'TRC', zahu, zahv, gtru, gtrv, gtrui, gtrvi, trb, trb, tra, jptra,  1   )
95         !
96      CASE ( np_blp , np_blp_i , np_blp_it )          ! bilaplacian: all operator (iso-level, -neutral)
97         CALL tra_ldf_blp  ( kt, nittrc000,'TRC', zahu, zahv, gtru, gtrv, gtrui, gtrvi, trb     , tra, jptra, nldf )
98         !
99      END SELECT
100      !
101      IF( l_trdtrc )   THEN                    ! save the horizontal diffusive trends for further diagnostics
102        DO jn = 1, jptra
103           ztrtrd(:,:,:,jn) = tra(:,:,:,jn) - ztrtrd(:,:,:,jn)
104           CALL trd_tra( kt, 'TRC', jn, jptra_ldf, ztrtrd(:,:,:,jn) )
105        END DO
106        CALL wrk_dealloc( jpi, jpj, jpk, jptra, ztrtrd )
107      ENDIF
108      !                                        ! print mean trends (used for debugging)
109      IF( ln_ctl ) THEN
110         WRITE(charout, FMT="('ldf ')")   ;   CALL prt_ctl_trc_info(charout)
111                                              CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
112      ENDIF
113      !
114      CALL wrk_dealloc( jpi,jpj,jpk,   zahu, zahv )
115      !
116      IF( nn_timing == 1 )   CALL timing_stop('trc_ldf')
117      !
118   END SUBROUTINE trc_ldf
119
120
121   SUBROUTINE trc_ldf_ini
122      !!----------------------------------------------------------------------
123      !!                  ***  ROUTINE ldf_ctl  ***
124      !!
125      !! ** Purpose :   Define the operator for the lateral diffusion
126      !!
127      !! ** Method  :   set nldf from the namtra_ldf logicals
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      INTEGER ::   ios            ! Local integer output status for namelist read
135      !
136      NAMELIST/namtrc_ldf/ ln_trcldf_lap, ln_trcldf_blp,                                  &
137         &                 ln_trcldf_lev, ln_trcldf_hor, ln_trcldf_iso, ln_trcldf_triad,  &
138         &                 rn_ahtrc_0   , rn_bhtrc_0
139      !!----------------------------------------------------------------------
140      REWIND( numnat_ref )              !  namtrc_ldf in reference namelist
141      READ  ( numnat_ref, namtrc_ldf, IOSTAT = ios, ERR = 903)
142903   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_ldf in reference namelist', lwp )
143
144      REWIND( numnat_cfg )              !  namtrc_ldf in configuration namelist
145      READ  ( numnat_cfg, namtrc_ldf, IOSTAT = ios, ERR = 904 )
146904   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_ldf in configuration namelist', lwp )
147      IF(lwm) WRITE ( numont, namtrc_ldf )
148
149      IF(lwp) THEN                    ! Namelist print
150         WRITE(numout,*)
151         WRITE(numout,*) 'trc_ldf_ini : lateral tracer diffusive operator'
152         WRITE(numout,*) '~~~~~~~~~~~'
153         WRITE(numout,*) '   Namelist namtrc_ldf : set lateral mixing parameters (type, direction, coefficients)'
154         WRITE(numout,*) '      operator'
155         WRITE(numout,*) '           laplacian                 ln_trcldf_lap   = ', ln_trcldf_lap
156         WRITE(numout,*) '         bilaplacian                 ln_trcldf_blp   = ', ln_trcldf_blp
157         WRITE(numout,*) '      direction of action'
158         WRITE(numout,*) '         iso-level                   ln_trcldf_lev   = ', ln_trcldf_lev
159         WRITE(numout,*) '         horizontal (geopotential)   ln_trcldf_hor   = ', ln_trcldf_hor
160         WRITE(numout,*) '         iso-neutral (standard)      ln_trcldf_iso   = ', ln_trcldf_iso
161         WRITE(numout,*) '         iso-neutral (triad)         ln_trcldf_triad = ', ln_trcldf_triad
162         WRITE(numout,*) '      diffusivity coefficient'
163         WRITE(numout,*) '           laplacian                 rn_ahtrc_0      = ', rn_ahtrc_0
164         WRITE(numout,*) '         bilaplacian                 rn_bhtrc_0      = ', rn_bhtrc_0
165      ENDIF
166      !     
167      !                                ! control the namelist parameters
168      ioptio = 0
169      IF( ln_trcldf_lap )   ioptio = ioptio + 1
170      IF( ln_trcldf_blp )   ioptio = ioptio + 1
171      IF( ioptio >  1   )   CALL ctl_stop( 'trc_ldf_ctl: use ONE or NONE of the 2 lap/bilap operator type on tracer' )
172      IF( ioptio == 0   )   nldf = np_no_ldf   ! No lateral diffusion
173     
174      IF( ln_trcldf_lap .AND. ln_trcldf_blp )   CALL ctl_stop( 'trc_ldf_ctl: bilaplacian should be used on both TRC and TRA' )
175      IF( ln_trcldf_blp .AND. ln_trcldf_lap )   CALL ctl_stop( 'trc_ldf_ctl:   laplacian should be used on both TRC and TRA' )
176     
177      ioptio = 0
178      IF( ln_trcldf_lev )   ioptio = ioptio + 1
179      IF( ln_trcldf_hor )   ioptio = ioptio + 1
180      IF( ln_trcldf_iso )   ioptio = ioptio + 1
181      IF( ioptio /= 1   )   CALL ctl_stop( 'trc_ldf_ctl: use only ONE direction (level/hor/iso)' )
182
183      ! defined the type of lateral diffusion from ln_trcldf_... logicals
184      ! CAUTION : nldf = 1 is used in trazdf_imp, change it carefully
185      ierr = 0
186      IF( ln_trcldf_lap ) THEN      !==  laplacian operator  ==!
187         IF ( ln_zco ) THEN                ! z-coordinate
188            IF ( ln_trcldf_lev   )   nldf = np_lap     ! iso-level = horizontal (no rotation)
189            IF ( ln_trcldf_hor   )   nldf = np_lap     ! iso-level = horizontal (no rotation)
190            IF ( ln_trcldf_iso   )   nldf = np_lap_i   ! iso-neutral: standard  (   rotation)
191            IF ( ln_trcldf_triad )   nldf = np_lap_it  ! iso-neutral: triad     (   rotation)
192         ENDIF
193         IF ( ln_zps ) THEN             ! z-coordinate with partial step
194            IF ( ln_trcldf_lev   )   ierr = 1         ! iso-level not allowed
195            IF ( ln_trcldf_hor   )   nldf = np_lap     ! horizontal (no rotation)
196            IF ( ln_trcldf_iso   )   nldf = np_lap_i   ! iso-neutral: standard (rotation)
197            IF ( ln_trcldf_triad )   nldf = np_lap_it  ! iso-neutral: triad    (rotation)
198         ENDIF
199         IF ( ln_sco ) THEN             ! s-coordinate
200            IF ( ln_trcldf_lev   )   nldf = np_lap     ! iso-level  (no rotation)
201            IF ( ln_trcldf_hor   )   nldf = np_lap_it  ! horizontal (   rotation)       !!gm   a checker....
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         !                                ! diffusivity ratio: passive / active tracers
206         IF( ABS(rn_aht_0) < 2._wp*TINY(1.e0) ) THEN
207            IF( ABS(rn_ahtrc_0) < 2._wp*TINY(1.e0) ) THEN
208               rldf = 1.0_wp
209            ELSE
210               CALL ctl_stop( 'STOP', 'trc_ldf_ctl : cannot define rldf, rn_aht_0==0, rn_ahtrc_0 /=0' )
211            ENDIF
212         ELSE
213            rldf = rn_ahtrc_0 / rn_aht_0
214         ENDIF
215      ENDIF
216      !
217      IF( ln_trcldf_blp ) THEN      !==  bilaplacian operator  ==!
218         IF ( ln_zco ) THEN                ! z-coordinate
219            IF ( ln_trcldf_lev   )   nldf = np_blp     ! iso-level = horizontal (no rotation)
220            IF ( ln_trcldf_hor   )   nldf = np_blp     ! iso-level = horizontal (no rotation)
221            IF ( ln_trcldf_iso   )   nldf = np_blp_i   ! iso-neutral: standard (rotation)
222            IF ( ln_trcldf_triad )   nldf = np_blp_it  ! iso-neutral: triad    (rotation)
223         ENDIF
224         IF ( ln_zps ) THEN             ! z-coordinate with partial step
225            IF ( ln_trcldf_lev   )   ierr = 1         ! iso-level not allowed
226            IF ( ln_trcldf_hor   )   nldf = np_blp     ! horizontal (no rotation)
227            IF ( ln_trcldf_iso   )   nldf = np_blp_i   ! iso-neutral: standard (rotation)
228            IF ( ln_trcldf_triad )   nldf = np_blp_it  ! iso-neutral: triad    (rotation)
229         ENDIF
230         IF ( ln_sco ) THEN             ! s-coordinate
231            IF ( ln_trcldf_lev   )   nldf = np_blp     ! iso-level  (no rotation)
232            IF ( ln_trcldf_hor   )   nldf = np_blp_it  ! horizontal (   rotation)       !!gm   a checker....
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         !                                ! diffusivity ratio: passive / active tracers
237         IF( ABS(rn_bht_0) < 2._wp*TINY(1.e0) ) THEN
238            IF( ABS(rn_bhtrc_0) < 2._wp*TINY(1.e0) ) THEN
239               rldf = 1.0_wp
240            ELSE
241               CALL ctl_stop( 'STOP', 'trc_ldf_ctl : cannot define rldf, rn_aht_0==0, rn_ahtrc_0 /=0' )
242            ENDIF
243         ELSE
244            rldf = SQRT(  ABS( rn_bhtrc_0 / rn_bht_0 )  )
245         ENDIF
246      ENDIF
247      !
248      IF( ierr == 1 )   CALL ctl_stop( ' iso-level in z-coordinate - partial step, not allowed' )
249      IF( ln_ldfeiv .AND. .NOT.ln_trcldf_iso )   &
250           CALL ctl_stop( '          eddy induced velocity on tracers',   &
251           &              ' the eddy induced velocity on tracers requires isopycnal laplacian diffusion' )
252      IF( nldf == 1 .OR. nldf == 3 ) THEN      ! rotation
253         IF( .NOT.l_ldfslp )   CALL ctl_stop( '          the rotation of the diffusive tensor require l_ldfslp' )
254      ENDIF
255      !
256      IF(lwp) THEN
257         WRITE(numout,*)
258         IF( nldf == np_no_ldf )   WRITE(numout,*) '          NO lateral diffusion'
259         IF( nldf == np_lap    )   WRITE(numout,*) '          laplacian iso-level operator'
260         IF( nldf == np_lap_i  )   WRITE(numout,*) '          Rotated laplacian operator (standard)'
261         IF( nldf == np_lap_it )   WRITE(numout,*) '          Rotated laplacian operator (triad)'
262         IF( nldf == np_blp    )   WRITE(numout,*) '          bilaplacian iso-level operator'
263         IF( nldf == np_blp_i  )   WRITE(numout,*) '          Rotated bilaplacian operator (standard)'
264         IF( nldf == np_blp_it )   WRITE(numout,*) '          Rotated bilaplacian operator (triad)'
265      ENDIF
266      !
267   END SUBROUTINE trc_ldf_ini
268#else
269   !!----------------------------------------------------------------------
270   !!   Default option                                         Empty module
271   !!----------------------------------------------------------------------
272CONTAINS
273   SUBROUTINE trc_ldf( kt )
274      INTEGER, INTENT(in) :: kt
275      WRITE(*,*) 'trc_ldf: You should not have seen this print! error?', kt
276   END SUBROUTINE trc_ldf
277#endif
278   !!======================================================================
279END MODULE trcldf
Note: See TracBrowser for help on using the repository browser.