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/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/TOP_SRC/TRP – NEMO

source: branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/TOP_SRC/TRP/trcldf.F90 @ 3118

Last change on this file since 3118 was 3118, checked in by cetlod, 12 years ago

branch dev_NEMO_MERGE_2011/NEMOGCM: minor bug corrections

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