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

source: branches/2011/dev_r2787_LOCEAN3_TRA_TRP/NEMOGCM/NEMO/TOP_SRC/TRP/trcldf.F90 @ 2819

Last change on this file since 2819 was 2819, checked in by cetlod, 13 years ago

Improvment of branch dev_r2787_LOCEAN3_TRA_TRP

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