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

source: branches/2011/dev_r2782_NOCS_Griffies/NEMOGCM/NEMO/TOP_SRC/TRP/trcldf.F90 @ 2840

Last change on this file since 2840 was 2840, checked in by agn, 13 years ago

branches/2011/dev_r2782_NOCS_Griffies ticket #838 bugfixes + preliminary support for s-coords

  • Property svn:keywords set to Id
File size: 11.4 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_lap      ! lateral mixing            (tra_ldf_lap routine)
26   USE trdmod_oce
27   USE trdtra
28   USE prtctl_trc      ! Print control
29
30   IMPLICIT NONE
31   PRIVATE
32
33   PUBLIC   trc_ldf    ! called by step.F90
34   !                                                 !!: ** lateral mixing namelist (nam_trcldf) **
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      IF( l_trdtrc )  THEN
64         ALLOCATE( ztrtrd(jpi,jpj,jpk,jptra) )  ! temporary save of trends
65         ztrtrd(:,:,:,:)  = tra(:,:,:,:)
66      ENDIF
67
68      SELECT CASE ( nldf )                       ! compute lateral mixing trend and add it to the general trend
69      CASE ( 0 )   ;   CALL tra_ldf_lap   ( kt, 'TRC', gtru, gtrv, trb, tra, jptra            )  ! iso-level laplacian
70      CASE ( 1 )   ;   CALL tra_ldf_iso   ( kt, 'TRC', gtru, gtrv, trb, tra, jptra, rn_ahtb_0 )  ! rotated laplacian
71      CASE ( 2 )   ;   CALL tra_ldf_bilap ( kt, 'TRC', gtru, gtrv, trb, tra, jptra            )  ! iso-level bilaplacian
72      CASE ( 3 )   ;   CALL tra_ldf_bilapg( kt, 'TRC',             trb, tra, jptra            )  ! s-coord. horizontal bilaplacian
73         !
74      CASE ( -1 )                                     ! esopa: test all possibility with control print
75         CALL tra_ldf_lap   ( kt, 'TRC', gtru, gtrv, trb, tra, jptra            )
76         WRITE(charout, FMT="('ldf0 ')") ;  CALL prt_ctl_trc_info(charout)
77                                            CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
78         IF( ln_traldf_grif ) THEN
79            CALL tra_ldf_iso_grif( kt, 'TRC', gtru, gtrv, trb, tra, jptra, rn_ahtb_0 )
80         ELSE
81            CALL tra_ldf_iso   ( kt, 'TRC', gtru, gtrv, trb, tra, jptra, rn_ahtb_0 )
82         ENDIF
83         WRITE(charout, FMT="('ldf1 ')") ;  CALL prt_ctl_trc_info(charout)
84                                            CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
85         CALL tra_ldf_bilap ( kt, 'TRC', gtru, gtrv, trb, tra, jptra            )
86         WRITE(charout, FMT="('ldf2 ')") ;  CALL prt_ctl_trc_info(charout)
87                                            CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
88         CALL tra_ldf_bilapg( kt, 'TRC',             trb, tra, jptra            )
89         WRITE(charout, FMT="('ldf3 ')") ;  CALL prt_ctl_trc_info(charout)
90                                            CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
91      END SELECT
92      !
93      IF( l_trdtrc )   THEN                      ! save the horizontal diffusive trends for further diagnostics
94        DO jn = 1, jptra
95           ztrtrd(:,:,:,jn) = tra(:,:,:,jn) - ztrtrd(:,:,:,jn)
96           CALL trd_tra( kt, 'TRC', jn, jptra_trd_ldf, ztrtrd(:,:,:,jn) )
97        END DO
98        DEALLOCATE( ztrtrd ) 
99      ENDIF
100      !                                          ! print mean trends (used for debugging)
101      IF( ln_ctl )   THEN
102         WRITE(charout, FMT="('ldf ')") ;  CALL prt_ctl_trc_info(charout)
103                                           CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
104      ENDIF
105      !
106   END SUBROUTINE trc_ldf
107
108
109   SUBROUTINE ldf_ctl
110      !!----------------------------------------------------------------------
111      !!                  ***  ROUTINE ldf_ctl  ***
112      !!
113      !! ** Purpose :   Choice of the operator for the lateral tracer diffusion
114      !!
115      !! ** Method  :   set nldf from the namtra_ldf logicals
116      !!      nldf == -2   No lateral diffusion 
117      !!      nldf == -1   ESOPA test: ALL operators are used
118      !!      nldf ==  0   laplacian operator
119      !!      nldf ==  1   Rotated laplacian operator
120      !!      nldf ==  2   bilaplacian operator
121      !!      nldf ==  3   Rotated bilaplacian
122      !!----------------------------------------------------------------------
123      INTEGER ::   ioptio, ierr         ! temporary integers
124      !!----------------------------------------------------------------------
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      !
213   END SUBROUTINE ldf_ctl
214#else
215   !!----------------------------------------------------------------------
216   !!   Default option                                         Empty module
217   !!----------------------------------------------------------------------
218CONTAINS
219   SUBROUTINE trc_ldf( kt )
220      INTEGER, INTENT(in) :: kt
221      WRITE(*,*) 'trc_ldf: You should not have seen this print! error?', kt
222   END SUBROUTINE trc_ldf
223#endif
224   !!======================================================================
225END MODULE trcldf
Note: See TracBrowser for help on using the repository browser.