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

source: trunk/NEMOGCM/NEMO/TOP_SRC/TRP/trcldf.F90 @ 2715

Last change on this file since 2715 was 2715, checked in by rblod, 13 years ago

First attempt to put dynamic allocation on the trunk

  • Property svn:keywords set to Id
File size: 11.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 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         CALL tra_ldf_iso   ( kt, 'TRC', gtru, gtrv, trb, tra, jptra, rn_ahtb_0 )
79         WRITE(charout, FMT="('ldf1 ')") ;  CALL prt_ctl_trc_info(charout)
80                                            CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
81         CALL tra_ldf_bilap ( kt, 'TRC', gtru, gtrv, trb, tra, jptra            )
82         WRITE(charout, FMT="('ldf2 ')") ;  CALL prt_ctl_trc_info(charout)
83                                            CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
84         CALL tra_ldf_bilapg( kt, 'TRC',             trb, tra, jptra            )
85         WRITE(charout, FMT="('ldf3 ')") ;  CALL prt_ctl_trc_info(charout)
86                                            CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
87      END SELECT
88      !
89      IF( l_trdtrc )   THEN                      ! save the horizontal diffusive trends for further diagnostics
90        DO jn = 1, jptra
91           ztrtrd(:,:,:,jn) = tra(:,:,:,jn) - ztrtrd(:,:,:,jn)
92           CALL trd_tra( kt, 'TRC', jn, jptra_trd_ldf, ztrtrd(:,:,:,jn) )
93        END DO
94        DEALLOCATE( ztrtrd ) 
95      ENDIF
96      !                                          ! print mean trends (used for debugging)
97      IF( ln_ctl )   THEN
98         WRITE(charout, FMT="('ldf ')") ;  CALL prt_ctl_trc_info(charout)
99                                           CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
100      ENDIF
101      !
102   END SUBROUTINE trc_ldf
103
104
105   SUBROUTINE ldf_ctl
106      !!----------------------------------------------------------------------
107      !!                  ***  ROUTINE ldf_ctl  ***
108      !!
109      !! ** Purpose :   Choice of the operator for the lateral tracer diffusion
110      !!
111      !! ** Method  :   set nldf from the namtra_ldf logicals
112      !!      nldf == -2   No lateral diffusion 
113      !!      nldf == -1   ESOPA test: ALL operators are used
114      !!      nldf ==  0   laplacian operator
115      !!      nldf ==  1   Rotated laplacian operator
116      !!      nldf ==  2   bilaplacian operator
117      !!      nldf ==  3   Rotated bilaplacian
118      !!----------------------------------------------------------------------
119      INTEGER ::   ioptio, ierr         ! temporary integers
120      !!----------------------------------------------------------------------
121
122      !  Define the lateral mixing oparator for tracers
123      ! ===============================================
124   
125      !                               ! control the input
126      ioptio = 0
127      IF( ln_trcldf_lap   )   ioptio = ioptio + 1
128      IF( ln_trcldf_bilap )   ioptio = ioptio + 1
129      IF( ioptio >  1 )   CALL ctl_stop( '          use ONE or NONE of the 2 lap/bilap operator type on tracer' )
130      IF( ioptio == 0 )   nldf = -2   ! No lateral diffusion
131      ioptio = 0
132      IF( ln_trcldf_level )   ioptio = ioptio + 1
133      IF( ln_trcldf_hor   )   ioptio = ioptio + 1
134      IF( ln_trcldf_iso   )   ioptio = ioptio + 1
135      IF( ioptio /= 1 )   CALL ctl_stop( '          use only ONE direction (level/hor/iso)' )
136
137      ! defined the type of lateral diffusion from ln_trcldf_... logicals
138      ! CAUTION : nldf = 1 is used in trazdf_imp, change it carefully
139      ierr = 0
140      IF( ln_trcldf_lap ) THEN       ! laplacian operator
141         IF ( ln_zco ) THEN                ! z-coordinate
142            IF ( ln_trcldf_level )   nldf = 0      ! iso-level  (no rotation)
143            IF ( ln_trcldf_hor   )   nldf = 0      ! horizontal (no rotation)
144            IF ( ln_trcldf_iso   )   nldf = 1      ! isoneutral (   rotation)
145         ENDIF
146         IF ( ln_zps ) THEN             ! z-coordinate
147            IF ( ln_trcldf_level )   ierr = 1      ! iso-level not allowed
148            IF ( ln_trcldf_hor   )   nldf = 0      ! horizontal (no rotation)
149            IF ( ln_trcldf_iso   )   nldf = 1      ! isoneutral (   rotation)
150         ENDIF
151         IF ( ln_sco ) THEN             ! z-coordinate
152            IF ( ln_trcldf_level )   nldf = 0      ! iso-level  (no rotation)
153            IF ( ln_trcldf_hor   )   nldf = 1      ! horizontal (   rotation)
154            IF ( ln_trcldf_iso   )   nldf = 1      ! isoneutral (   rotation)
155         ENDIF
156      ENDIF
157
158      IF( ln_trcldf_bilap ) THEN      ! bilaplacian operator
159         IF ( ln_zco ) THEN                ! z-coordinate
160            IF ( ln_trcldf_level )   nldf = 2      ! iso-level  (no rotation)
161            IF ( ln_trcldf_hor   )   nldf = 2      ! horizontal (no rotation)
162            IF ( ln_trcldf_iso   )   ierr = 2      ! isoneutral (   rotation)
163         ENDIF
164         IF ( ln_zps ) THEN             ! z-coordinate
165            IF ( ln_trcldf_level )   ierr = 1      ! iso-level not allowed
166            IF ( ln_trcldf_hor   )   nldf = 2      ! horizontal (no rotation)
167            IF ( ln_trcldf_iso   )   ierr = 2      ! isoneutral (   rotation)
168         ENDIF
169         IF ( ln_sco ) THEN             ! z-coordinate
170            IF ( ln_trcldf_level )   nldf = 2      ! iso-level  (no rotation)
171            IF ( ln_trcldf_hor   )   nldf = 3      ! horizontal (   rotation)
172            IF ( ln_trcldf_iso   )   ierr = 2      ! isoneutral (   rotation)
173         ENDIF
174      ENDIF
175
176      IF( ierr == 1 )   CALL ctl_stop( ' iso-level in z-coordinate - partial step, not allowed' )
177      IF( ierr == 2 )   CALL ctl_stop( ' isoneutral bilaplacian operator does not exist' )
178      IF( lk_traldf_eiv .AND. .NOT.ln_trcldf_iso )   &
179           CALL ctl_stop( '          eddy induced velocity on tracers',   &
180           &              ' the eddy induced velocity on tracers requires isopycnal laplacian diffusion' )
181      IF( nldf == 1 .OR. nldf == 3 ) THEN      ! rotation
182         IF( .NOT.lk_ldfslp )   CALL ctl_stop( '          the rotation of the diffusive tensor require key_ldfslp' )
183#if defined key_offline
184         l_traldf_rot = .TRUE.                 ! needed for trazdf_imp
185#endif
186      ENDIF
187
188      IF( lk_esopa ) THEN
189         IF(lwp) WRITE(numout,*) '          esopa control: use all lateral physics options'
190         nldf = -1
191      ENDIF
192
193      IF( .NOT. ln_trcldf_diff ) THEN
194         IF(lwp) WRITE(numout,*) '          No lateral diffusion on passive tracers'
195         nldf = -2
196      ENDIF
197
198      IF(lwp) THEN
199         WRITE(numout,*)
200         IF( nldf == -2 )   WRITE(numout,*) '          NO lateral diffusion'
201         IF( nldf == -1 )   WRITE(numout,*) '          ESOPA test All scheme used'
202         IF( nldf ==  0 )   WRITE(numout,*) '          laplacian operator'
203         IF( nldf ==  1 )   WRITE(numout,*) '          Rotated laplacian operator'
204         IF( nldf ==  2 )   WRITE(numout,*) '          bilaplacian operator'
205         IF( nldf ==  3 )   WRITE(numout,*) '          Rotated bilaplacian'
206      ENDIF
207
208      !
209   END SUBROUTINE ldf_ctl
210#else
211   !!----------------------------------------------------------------------
212   !!   Default option                                         Empty module
213   !!----------------------------------------------------------------------
214CONTAINS
215   SUBROUTINE trc_ldf( kt )
216      INTEGER, INTENT(in) :: kt
217      WRITE(*,*) 'trc_ldf: You should not have seen this print! error?', kt
218   END SUBROUTINE trc_ldf
219#endif
220   !!======================================================================
221END MODULE trcldf
Note: See TracBrowser for help on using the repository browser.