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_crs.F90 in branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/TRP – NEMO

source: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/TRP/trcldf_crs.F90 @ 8088

Last change on this file since 8088 was 8088, checked in by cbricaud, 7 years ago

compute r_fact_lap_crs for passive tracer diffusion in CRS mode

  • Property svn:executable set to *
File size: 14.3 KB
Line 
1MODULE trcldf_crs
2   !!======================================================================
3   !!                       ***  MODULE  trcldf  ***
4   !! Ocean Passive 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#if defined key_top
10   !!----------------------------------------------------------------------
11   !!   'key_top'                                                TOP models
12   !!----------------------------------------------------------------------
13   !!----------------------------------------------------------------------
14   !!   trc_ldf     : update the tracer trend with the lateral diffusion
15   !!       ldf_ctl : initialization, namelist read, and parameters control
16   !!----------------------------------------------------------------------
17   USE oce_trc         ! ocean dynamics and active tracers
18   USE trc             ! ocean passive tracers variables
19   USE trcnam_trp      ! passive tracers transport namelist variables
20   !USE ldftra_oce      ! lateral diffusion coefficient on tracers
21   USE ldftra_oce,ONLY: ln_traldf_grif,rn_aht_0,rn_ahtb_0,lk_traldf_eiv     ! lateral diffusion coefficient on tracers
22   USE ldfslp          ! ???
23   USE traldf_bilapg   ! lateral mixing            (tra_ldf_bilapg routine)
24   USE traldf_bilap    ! lateral mixing            (tra_ldf_bilap routine)
25   USE traldf_iso_crs      ! lateral mixing            (tra_ldf_iso routine)
26   USE traldf_iso_grif ! lateral mixing          (tra_ldf_iso_grif routine)
27   USE traldf_lap_crs      ! lateral mixing            (tra_ldf_lap routine)
28   USE trd_oce
29   USE trdtra
30   USE prtctl_trc      ! Print control
31   !USE crs
32   USE trc_oce, ONLY : lk_offline 
33
34   IMPLICIT NONE
35   PRIVATE
36
37   PUBLIC   trc_ldf_crs    ! called by step.F90
38   !                                                 !!: ** lateral mixing namelist (nam_trcldf) **
39   REAL(wp) ::  rldf_rat    ! ratio between active and passive tracers diffusive coefficient
40   INTEGER  ::  nldf = 0   ! type of lateral diffusion used defined from ln_trcldf_... namlist logicals)
41   !! * Substitutions
42#  include "domzgr_substitute.h90"
43#  include "vectopt_loop_substitute.h90"
44   !!----------------------------------------------------------------------
45   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
46   !! $Id: trcldf.F90 3294 2012-01-28 16:44:18Z rblod $
47   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
48   !!----------------------------------------------------------------------
49
50CONTAINS
51
52   SUBROUTINE trc_ldf_crs( kt )
53      !!----------------------------------------------------------------------
54      !!                  ***  ROUTINE tra_ldf  ***
55      !!
56      !! ** Purpose :   compute the lateral ocean tracer physics.
57      !!
58      !!----------------------------------------------------------------------
59      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
60      !!
61      INTEGER            :: ji,jj,jk,jn
62      REAL(wp)           :: zdep
63      CHARACTER (len=22) :: charout
64      REAL(wp), POINTER, DIMENSION(:,:,:,:) ::   ztrtrd
65      !!----------------------------------------------------------------------
66      !
67      IF( nn_timing == 1 )   CALL timing_start('trc_ldf')
68      !
69      IF( kt == nittrc000 )   CALL ldf_ctl          ! initialisation & control of options
70
71      rldf = rldf_rat
72      !
73      r_fact_lap(:,:,:) = 1.
74      DO jk= 1, jpk
75         DO jj = 1, jpj
76            DO ji = 1, jpi
77               IF( fsdept(ji,jj,jk) > 200. .AND. gphit(ji,jj) < 5. .AND. gphit(ji,jj) > -5. ) THEN
78                  zdep = MAX( fsdept(ji,jj,jk) - 1000., 0. ) / 1000.
79                  r_fact_lap(ji,jj,jk) = MAX( 1., rn_fact_lap * EXP( -zdep ) )
80               ENDIF
81            END DO
82         END DO
83      END DO
84
85      IF( l_trdtrc )  THEN
86         CALL wrk_alloc( jpi, jpj, jpk, jptra, ztrtrd )
87         ztrtrd(:,:,:,:)  = tra(:,:,:,:)
88      ENDIF
89
90!      WRITE(numout,*) 'nldf', nldf
91      SELECT CASE ( nldf )                       ! compute lateral mixing trend and add it to the general trend
92      CASE ( 0 )   ;   CALL tra_ldf_lap_crs   ( kt, nittrc000, 'TRC', gtru, gtrv, trb, tra, jptra            )  ! iso-level laplacian
93      CASE ( 1 )                                                                                            ! rotated laplacian
94                       IF( ln_traldf_grif ) THEN
95                          CALL tra_ldf_iso_grif( kt, nittrc000, 'TRC', gtru, gtrv, trb, tra, jptra, rn_ahtb_0 )
96                       ELSE
97                          CALL tra_ldf_iso_crs     ( kt, nittrc000, 'TRC', gtru ,gtrv , trb, tra, jptra, rn_ahtb_0 )
98                       ENDIF
99      CASE ( 2 )   ;   CALL tra_ldf_bilap ( kt, nittrc000, 'TRC', gtru, gtrv, gtrui, gtrvi, trb, tra, jptra            )  ! iso-level bilaplacian
100      CASE ( 3 )   ;   CALL tra_ldf_bilapg( kt, nittrc000, 'TRC',             trb, tra, jptra            )  ! s-coord. horizontal bilaplacian
101         !
102      CASE ( -1 )                                     ! esopa: test all possibility with control print
103         CALL tra_ldf_lap_crs   ( kt, nittrc000, 'TRC', gtru, gtrv, trb, tra, jptra            )
104         WRITE(charout, FMT="('ldf0 ')") ;  CALL prt_ctl_trc_info(charout)
105                                            CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
106         IF( ln_traldf_grif ) THEN
107            CALL tra_ldf_iso_grif( kt, nittrc000, 'TRC', gtru, gtrv, trb, tra, jptra, rn_ahtb_0 )
108         ELSE
109            CALL tra_ldf_iso_crs     ( kt, nittrc000, 'TRC', gtru, gtrv, trb, tra, jptra, rn_ahtb_0 )
110         ENDIF
111         WRITE(charout, FMT="('ldf1 ')") ;  CALL prt_ctl_trc_info(charout)
112                                            CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
113         CALL tra_ldf_bilap ( kt, nittrc000, 'TRC', gtru, gtrv, gtrui, gtrvi, trb, tra, jptra            )
114         WRITE(charout, FMT="('ldf2 ')") ;  CALL prt_ctl_trc_info(charout)
115                                            CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
116         CALL tra_ldf_bilapg( kt, nittrc000, 'TRC',             trb, tra, jptra            )
117         WRITE(charout, FMT="('ldf3 ')") ;  CALL prt_ctl_trc_info(charout)
118                                            CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
119      END SELECT
120      !
121      IF( l_trdtrc )   THEN                      ! save the horizontal diffusive trends for further diagnostics
122        DO jn = 1, jptra
123           ztrtrd(:,:,:,jn) = tra(:,:,:,jn) - ztrtrd(:,:,:,jn)
124           CALL trd_tra( kt, 'TRC', jn, jptra_ldf, ztrtrd(:,:,:,jn) )
125        END DO
126        CALL wrk_dealloc( jpi, jpj, jpk, jptra, ztrtrd )
127      ENDIF
128      !                                          ! print mean trends (used for debugging)
129      IF( ln_ctl )   THEN
130         WRITE(charout, FMT="('ldf ')") ;  CALL prt_ctl_trc_info(charout)
131                                           CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
132      ENDIF
133      !
134      IF( nn_timing == 1 )   CALL timing_stop('trc_ldf')
135      !
136   END SUBROUTINE trc_ldf_crs
137
138
139   SUBROUTINE ldf_ctl
140      !!----------------------------------------------------------------------
141      !!                  ***  ROUTINE ldf_ctl  ***
142      !!
143      !! ** Purpose :   Choice of the operator for the lateral tracer diffusion
144      !!
145      !! ** Method  :   set nldf from the namtra_ldf logicals
146      !!      nldf == -2   No lateral diffusion
147      !!      nldf == -1   ESOPA test: ALL operators are used
148      !!      nldf ==  0   laplacian operator
149      !!      nldf ==  1   Rotated laplacian operator
150      !!      nldf ==  2   bilaplacian operator
151      !!      nldf ==  3   Rotated bilaplacian
152      !!----------------------------------------------------------------------
153      INTEGER ::   ioptio, ierr         ! temporary integers
154      !!----------------------------------------------------------------------
155
156      IF (ABS(rn_aht_0) < 2._wp*TINY(1.e0)) THEN
157       !  IF (ABS(rn_ahtrc_0) < 2._wp*TINY(1.e0)) THEN  !! cc
158       !     rldf_rat = 1.0_wp
159       !  ELSE
160       !     CALL ctl_stop( 'STOP', 'ldf_ctl : cannot define rldf_rat, rn_aht_0==0, rn_ahtrc_0 /=0' )
161       !  END IF
162          rldf_rat = 1.0_wp !!cc
163      ELSE
164         rldf_rat = rn_ahtrc_0 / rn_aht_0
165      END IF
166      !  Define the lateral mixing oparator for tracers
167      ! ===============================================
168
169      !                               ! control the input
170      ioptio = 0
171      IF( ln_trcldf_lap   )   ioptio = ioptio + 1
172      IF( ln_trcldf_bilap )   ioptio = ioptio + 1
173      IF( ioptio >  1 )   CALL ctl_stop( '          use ONE or NONE of the 2 lap/bilap operator type on tracer' )
174      IF( ioptio == 0 )   nldf = -2   ! No lateral diffusion
175      ioptio = 0
176      IF( ln_trcldf_level )   ioptio = ioptio + 1
177      IF( ln_trcldf_hor   )   ioptio = ioptio + 1
178      IF( ln_trcldf_iso   )   ioptio = ioptio + 1
179      IF( ioptio /= 1 )   CALL ctl_stop( '          use only ONE direction (level/hor/iso)' )
180
181      ! defined the type of lateral diffusion from ln_trcldf_... logicals
182      ! CAUTION : nldf = 1 is used in trazdf_imp, change it carefully
183      ierr = 0
184      IF( ln_trcldf_lap ) THEN       ! laplacian operator
185         IF ( ln_zco ) THEN                ! z-coordinate
186            IF ( ln_trcldf_level )   nldf = 0      ! iso-level  (no rotation)
187            IF ( ln_trcldf_hor   )   nldf = 0      ! horizontal (no rotation)
188            IF ( ln_trcldf_iso   )   nldf = 1      ! isoneutral (   rotation)
189         ENDIF
190         IF ( ln_zps ) THEN             ! z-coordinate
191            IF ( ln_trcldf_level )   ierr = 1      ! iso-level not allowed
192            IF ( ln_trcldf_hor   )   nldf = 0      ! horizontal (no rotation)
193            IF ( ln_trcldf_iso   )   nldf = 1      ! isoneutral (   rotation)
194         ENDIF
195         IF ( ln_sco ) THEN             ! z-coordinate
196            IF ( ln_trcldf_level )   nldf = 0      ! iso-level  (no rotation)
197            IF ( ln_trcldf_hor   )   nldf = 1      ! horizontal (   rotation)
198            IF ( ln_trcldf_iso   )   nldf = 1      ! isoneutral (   rotation)
199         ENDIF
200      ENDIF
201
202      IF( ln_trcldf_bilap ) THEN      ! bilaplacian operator
203         IF ( ln_zco ) THEN                ! z-coordinate
204            IF ( ln_trcldf_level )   nldf = 2      ! iso-level  (no rotation)
205            IF ( ln_trcldf_hor   )   nldf = 2      ! horizontal (no rotation)
206            IF ( ln_trcldf_iso   )   ierr = 2      ! isoneutral (   rotation)
207         ENDIF
208         IF ( ln_zps ) THEN             ! z-coordinate
209            IF ( ln_trcldf_level )   ierr = 1      ! iso-level not allowed
210            IF ( ln_trcldf_hor   )   nldf = 2      ! horizontal (no rotation)
211            IF ( ln_trcldf_iso   )   ierr = 2      ! isoneutral (   rotation)
212         ENDIF
213         IF ( ln_sco ) THEN             ! z-coordinate
214            IF ( ln_trcldf_level )   nldf = 2      ! iso-level  (no rotation)
215            IF ( ln_trcldf_hor   )   nldf = 3      ! horizontal (   rotation)
216            IF ( ln_trcldf_iso   )   ierr = 2      ! isoneutral (   rotation)
217         ENDIF
218      ENDIF
219
220      IF( ierr == 1 )   CALL ctl_stop( ' iso-level in z-coordinate - partial step, not allowed' )
221      IF( ierr == 2 )   CALL ctl_stop( ' isoneutral bilaplacian operator does not exist' )
222      IF( lk_traldf_eiv .AND. .NOT.ln_trcldf_iso )   &
223           CALL ctl_stop( '          eddy induced velocity on tracers',   &
224           &              ' the eddy induced velocity on tracers requires isopycnal laplacian diffusion' )
225      IF( nldf == 1 .OR. nldf == 3 ) THEN      ! rotation
226         IF( .NOT.lk_ldfslp )   CALL ctl_stop( '          the rotation of the diffusive tensor require key_ldfslp' )
227#if defined key_offline
228         l_traldf_rot = .TRUE.                 ! needed for trazdf_imp
229#endif
230      ENDIF
231
232      IF( lk_esopa ) THEN
233         IF(lwp) WRITE(numout,*) '          esopa control: use all lateral physics options'
234         nldf = -1
235      ENDIF
236
237      IF(lwp) THEN
238         WRITE(numout,*)
239         IF( nldf == -2 )   WRITE(numout,*) '          NO lateral diffusion'
240         IF( nldf == -1 )   WRITE(numout,*) '          ESOPA test All scheme used'
241         IF( nldf ==  0 )   WRITE(numout,*) '          laplacian operator'
242         IF( nldf ==  1 )   WRITE(numout,*) '          Rotated laplacian operator'
243         IF( nldf ==  2 )   WRITE(numout,*) '          bilaplacian operator'
244         IF( nldf ==  3 )   WRITE(numout,*) '          Rotated bilaplacian'
245      ENDIF
246
247      IF( ln_trcldf_bilap ) THEN
248         IF(lwp) WRITE(numout,*) '          biharmonic tracer diffusion'
249         IF( rn_ahtrc_0 > 0 .AND. .NOT. lk_esopa )   CALL ctl_stop( 'The horizontal diffusivity coef. rn_ahtrc_0 must be negative' )
250      ELSE
251         IF(lwp) WRITE(numout,*) '          harmonic tracer diffusion (default)'
252         IF( rn_ahtrc_0 < 0 .AND. .NOT. lk_esopa )   CALL ctl_stop('The horizontal diffusivity coef. rn_ahtrc_0 must be positive' )
253      ENDIF
254
255      ! ratio between active and passive tracers diffusive coef.
256      IF (ABS(rn_aht_0) < 2._wp*TINY(1.e0)) THEN
257       !  IF (ABS(rn_ahtrc_0) < 2._wp*TINY(1.e0)) THEN   !!cc
258       !     rldf_rat = 1.0_wp
259       !  ELSE
260       !     CALL ctl_stop( 'STOP', 'ldf_ctl : cannot define rldf_rat, rn_aht_0==0, rn_ahtrc_0 /=0' )
261       !  END IF
262          rldf_rat = 1.0_wp   !!cc
263      ELSE
264         rldf_rat = rn_ahtrc_0 / rn_aht_0
265      END IF
266      IF( rldf_rat < 0 ) THEN
267         IF( .NOT.lk_offline ) THEN
268            CALL ctl_stop( 'Choose the same type of diffusive scheme both for active & passive tracers' )
269         ELSE
270            CALL ctl_stop( 'Change the sign of rn_aht_0 in namelist to -/+1' )
271         ENDIF
272      ENDIF
273      !
274   END SUBROUTINE ldf_ctl
275#else
276   !!----------------------------------------------------------------------
277   !!   Default option                                         Empty module
278   !!----------------------------------------------------------------------
279CONTAINS
280   SUBROUTINE trc_ldf_crs( kt )
281      INTEGER, INTENT(in) :: kt
282      WRITE(*,*) 'trc_ldf: You should not have seen this print! error?', kt
283   END SUBROUTINE trc_ldf_crs
284#endif
285   !!======================================================================
286END MODULE trcldf_crs
Note: See TracBrowser for help on using the repository browser.