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.
trcadv.F90 in NEMO/trunk/src/TOP/TRP – NEMO

source: NEMO/trunk/src/TOP/TRP/trcadv.F90

Last change on this file was 15073, checked in by clem, 3 years ago

nn_hls=2 and debug mode: make agrif work and be repro

  • Property svn:keywords set to Id
File size: 14.8 KB
Line 
1MODULE trcadv
2   !!==============================================================================
3   !!                       ***  MODULE  trcadv  ***
4   !! Ocean passive tracers:  advection trend
5   !!==============================================================================
6   !! History :  2.0  !  2005-11  (G. Madec)  Original code
7   !!            3.0  !  2010-06  (C. Ethe)   Adapted to passive tracers
8   !!            3.7  !  2014-05  (G. Madec, C. Ethe)  Add 2nd/4th order cases for CEN and FCT schemes
9   !!            4.0  !  2017-09  (G. Madec)  remove vertical time-splitting option
10   !!----------------------------------------------------------------------
11#if defined key_top
12   !!----------------------------------------------------------------------
13   !!   'key_top'                                                TOP models
14   !!----------------------------------------------------------------------
15   !!   trc_adv       : compute ocean tracer advection trend
16   !!   trc_adv_ini   : control the different options of advection scheme
17   !!----------------------------------------------------------------------
18   USE par_trc        ! need jptra, number of passive tracers
19   USE oce_trc        ! ocean dynamics and active tracers
20   USE trc            ! ocean passive tracers variables
21   USE sbcwave        ! wave module
22   USE sbc_oce        ! surface boundary condition: ocean
23   USE traadv_cen     ! centered scheme           (tra_adv_cen  routine)
24   USE traadv_fct     ! FCT      scheme           (tra_adv_fct  routine)
25   USE traadv_mus     ! MUSCL    scheme           (tra_adv_mus  routine)
26   USE traadv_ubs     ! UBS      scheme           (tra_adv_ubs  routine)
27   USE traadv_qck     ! QUICKEST scheme           (tra_adv_qck  routine)
28   USE tramle         ! ML eddy induced transport (tra_adv_mle  routine)
29   USE ldftra         ! lateral diffusion: eddy diffusivity & EIV coeff.
30   USE ldfslp         ! Lateral diffusion: slopes of neutral surfaces
31   !
32   USE prtctl         ! control print
33   USE timing         ! Timing
34
35   IMPLICIT NONE
36   PRIVATE
37
38   PUBLIC   trc_adv       ! called by trctrp.F90
39   PUBLIC   trc_adv_ini   ! called by trcini.F90
40
41   !                            !!* Namelist namtrc_adv *
42   LOGICAL ::   ln_trcadv_OFF    ! no advection on passive tracers
43   LOGICAL ::   ln_trcadv_cen    ! centered scheme flag
44   INTEGER ::      nn_cen_h, nn_cen_v   ! =2/4 : horizontal and vertical choices of the order of CEN scheme
45   LOGICAL ::   ln_trcadv_fct    ! FCT scheme flag
46   INTEGER ::      nn_fct_h, nn_fct_v   ! =2/4 : horizontal and vertical choices of the order of FCT scheme
47   LOGICAL ::   ln_trcadv_mus    ! MUSCL scheme flag
48   LOGICAL ::      ln_mus_ups           ! use upstream scheme in vivcinity of river mouths
49   LOGICAL ::   ln_trcadv_ubs    ! UBS scheme flag
50   INTEGER ::      nn_ubs_v             ! =2/4 : vertical choice of the order of UBS scheme
51   LOGICAL ::   ln_trcadv_qck    ! QUICKEST scheme flag
52
53   INTEGER ::   nadv             ! choice of the type of advection scheme
54   !                             ! associated indices:
55   INTEGER, PARAMETER ::   np_NO_adv  = 0   ! no T-S advection
56   INTEGER, PARAMETER ::   np_CEN     = 1   ! 2nd/4th order centered scheme
57   INTEGER, PARAMETER ::   np_FCT     = 2   ! 2nd/4th order Flux Corrected Transport scheme
58   INTEGER, PARAMETER ::   np_MUS     = 3   ! MUSCL scheme
59   INTEGER, PARAMETER ::   np_UBS     = 4   ! 3rd order Upstream Biased Scheme
60   INTEGER, PARAMETER ::   np_QCK     = 5   ! QUICK scheme
61   
62   !! * Substitutions
63#  include "do_loop_substitute.h90"
64#  include "domzgr_substitute.h90"
65   !!----------------------------------------------------------------------
66   !! NEMO/TOP 4.0 , NEMO Consortium (2018)
67   !! $Id$
68   !! Software governed by the CeCILL license (see ./LICENSE)
69   !!----------------------------------------------------------------------
70CONTAINS
71
72   SUBROUTINE trc_adv( kt, Kbb, Kmm, ptr, Krhs  )
73      !!----------------------------------------------------------------------
74      !!                  ***  ROUTINE trc_adv  ***
75      !!
76      !! ** Purpose :   compute the ocean tracer advection trend.
77      !!
78      !! ** Method  : - Update after tracers (tr(Krhs)) with the advection term following nadv
79      !!----------------------------------------------------------------------
80      INTEGER                                   , INTENT(in)    :: kt   ! ocean time-step index
81      INTEGER                                   , INTENT(in)    :: Kbb, Kmm, Krhs ! time level indices
82      REAL(wp), DIMENSION(jpi,jpj,jpk,jptra,jpt), INTENT(inout) :: ptr            ! passive tracers and RHS of tracer equation
83      !
84      INTEGER ::   ji, jj, jk   ! dummy loop index
85      CHARACTER (len=22) ::   charout
86      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zuu, zvv, zww  ! effective velocity
87      !!----------------------------------------------------------------------
88      !
89      IF( ln_timing )   CALL timing_start('trc_adv')
90      !
91      !                                         !==  effective transport  ==!
92      IF( l_offline ) THEN
93         DO_3D( nn_hls, nn_hls-1, nn_hls, nn_hls-1, 1, jpk )
94            zuu(ji,jj,jk) = uu(ji,jj,jk,Kmm)             ! already in (uu(Kmm),vv(Kmm),ww)
95            zvv(ji,jj,jk) = vv(ji,jj,jk,Kmm)
96         END_3D
97         DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpk )
98            zww(ji,jj,jk) = ww(ji,jj,jk)
99         END_3D
100      ELSE                                         ! build the effective transport
101         DO_2D( nn_hls, nn_hls-1, nn_hls, nn_hls-1 )
102            zuu(ji,jj,jpk) = 0._wp
103            zvv(ji,jj,jpk) = 0._wp
104         END_2D
105         DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 )
106            zww(ji,jj,jpk) = 0._wp
107         END_2D
108         IF( ln_wave .AND. ln_sdw )  THEN
109            DO_3D( nn_hls, nn_hls-1, nn_hls, nn_hls-1, 1, jpkm1 )                            ! eulerian transport + Stokes Drift
110               zuu(ji,jj,jk) = e2u  (ji,jj) * e3u(ji,jj,jk,Kmm) * ( uu(ji,jj,jk,Kmm) + usd(ji,jj,jk) )
111               zvv(ji,jj,jk) = e1v  (ji,jj) * e3v(ji,jj,jk,Kmm) * ( vv(ji,jj,jk,Kmm) + vsd(ji,jj,jk) )
112            END_3D
113            DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 )
114               zww(ji,jj,jk) = e1e2t(ji,jj)                     * ( ww(ji,jj,jk)     + wsd(ji,jj,jk) )
115            END_3D
116         ELSE
117            DO_3D( nn_hls, nn_hls-1, nn_hls, nn_hls-1, 1, jpkm1 )
118               zuu(ji,jj,jk) = e2u  (ji,jj) * e3u(ji,jj,jk,Kmm) * uu(ji,jj,jk,Kmm)           ! eulerian transport
119               zvv(ji,jj,jk) = e1v  (ji,jj) * e3v(ji,jj,jk,Kmm) * vv(ji,jj,jk,Kmm)
120            END_3D
121            DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 )
122               zww(ji,jj,jk) = e1e2t(ji,jj)                     * ww(ji,jj,jk)
123            END_3D
124         ENDIF
125         !
126         IF( ln_vvl_ztilde .OR. ln_vvl_layer ) THEN                                          ! add z-tilde and/or vvl corrections
127            DO_3D( nn_hls, nn_hls-1, nn_hls, nn_hls-1, 1, jpkm1 )
128               zuu(ji,jj,jk) = zuu(ji,jj,jk) + un_td(ji,jj,jk)
129               zvv(ji,jj,jk) = zvv(ji,jj,jk) + vn_td(ji,jj,jk)
130            END_3D
131         ENDIF
132         !
133         IF( ln_ldfeiv .AND. .NOT. ln_traldf_triad )   & 
134            &              CALL ldf_eiv_trp( kt, nittrc000, zuu, zvv, zww, 'TRC', Kmm, Krhs )  ! add the eiv transport
135         !
136         IF( ln_mle    )   CALL tra_mle_trp( kt, nittrc000, zuu, zvv, zww, 'TRC', Kmm       )  ! add the mle transport
137         !
138      ENDIF
139      !
140      SELECT CASE ( nadv )                      !==  compute advection trend and add it to general trend  ==!
141      !
142      CASE ( np_CEN )                                 ! Centered : 2nd / 4th order
143         CALL tra_adv_cen   ( kt, nittrc000,'TRC',          zuu, zvv, zww,      Kmm, ptr, jptra, Krhs, nn_cen_h, nn_cen_v )
144      CASE ( np_FCT )                                 ! FCT      : 2nd / 4th order
145            CALL tra_adv_fct( kt, nittrc000,'TRC', rDt_trc, zuu, zvv, zww, Kbb, Kmm, ptr, jptra, Krhs, nn_fct_h, nn_fct_v )
146      CASE ( np_MUS )                                 ! MUSCL
147            CALL tra_adv_mus( kt, nittrc000,'TRC', rDt_trc, zuu, zvv, zww, Kbb, Kmm, ptr, jptra, Krhs, ln_mus_ups         )
148      CASE ( np_UBS )                                 ! UBS
149         CALL tra_adv_ubs   ( kt, nittrc000,'TRC', rDt_trc, zuu, zvv, zww, Kbb, Kmm, ptr, jptra, Krhs, nn_ubs_v           )
150      CASE ( np_QCK )                                 ! QUICKEST
151         CALL tra_adv_qck   ( kt, nittrc000,'TRC', rDt_trc, zuu, zvv, zww, Kbb, Kmm, ptr, jptra, Krhs                     )
152      !
153      END SELECT
154      !                 
155      IF( sn_cfctl%l_prttrc ) THEN        !== print mean trends (used for debugging)
156         WRITE(charout, FMT="('adv ')")
157         CALL prt_ctl_info( charout, cdcomp = 'top' )
158         CALL prt_ctl( tab4d_1=tr(:,:,:,:,Krhs), mask1=tmask, clinfo=ctrcnm, clinfo3='trd' )
159      END IF
160      !
161      IF( ln_timing )   CALL timing_stop('trc_adv')
162      !
163   END SUBROUTINE trc_adv
164
165
166   SUBROUTINE trc_adv_ini
167      !!---------------------------------------------------------------------
168      !!                  ***  ROUTINE trc_adv_ini  ***
169      !!               
170      !! ** Purpose :   Control the consistency between namelist options for
171      !!              passive tracer advection schemes and set nadv
172      !!----------------------------------------------------------------------
173      INTEGER ::   ioptio, ios   ! Local integer
174      !!
175      NAMELIST/namtrc_adv/ ln_trcadv_OFF,                        &   ! No advection
176         &                 ln_trcadv_cen, nn_cen_h, nn_cen_v,    &   ! CEN
177         &                 ln_trcadv_fct, nn_fct_h, nn_fct_v,    &   ! FCT
178         &                 ln_trcadv_mus, ln_mus_ups,            &   ! MUSCL
179         &                 ln_trcadv_ubs,           nn_ubs_v,    &   ! UBS
180         &                 ln_trcadv_qck                             ! QCK
181      !!----------------------------------------------------------------------
182      !
183      !                                !==  Namelist  ==!
184      READ  ( numnat_ref, namtrc_adv, IOSTAT = ios, ERR = 901)
185901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc_adv in reference namelist' )
186      READ  ( numnat_cfg, namtrc_adv, IOSTAT = ios, ERR = 902 )
187902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtrc_adv in configuration namelist' )
188      IF(lwm) WRITE ( numont, namtrc_adv )
189      !
190      IF(lwp) THEN                           ! Namelist print
191         WRITE(numout,*)
192         WRITE(numout,*) 'trc_adv_ini : choice/control of the tracer advection scheme'
193         WRITE(numout,*) '~~~~~~~~~~~'
194         WRITE(numout,*) '   Namelist namtrc_adv : chose a advection scheme for tracers'
195         WRITE(numout,*) '      No advection on passive tracers           ln_trcadv_OFF = ', ln_trcadv_OFF
196         WRITE(numout,*) '      centered scheme                           ln_trcadv_cen = ', ln_trcadv_cen
197         WRITE(numout,*) '            horizontal 2nd/4th order               nn_cen_h   = ', nn_fct_h
198         WRITE(numout,*) '            vertical   2nd/4th order               nn_cen_v   = ', nn_fct_v
199         WRITE(numout,*) '      Flux Corrected Transport scheme           ln_trcadv_fct = ', ln_trcadv_fct
200         WRITE(numout,*) '            horizontal 2nd/4th order               nn_fct_h   = ', nn_fct_h
201         WRITE(numout,*) '            vertical   2nd/4th order               nn_fct_v   = ', nn_fct_v
202         WRITE(numout,*) '      MUSCL scheme                              ln_trcadv_mus = ', ln_trcadv_mus
203         WRITE(numout,*) '            + upstream scheme near river mouths    ln_mus_ups = ', ln_mus_ups
204         WRITE(numout,*) '      UBS scheme                                ln_trcadv_ubs = ', ln_trcadv_ubs
205         WRITE(numout,*) '            vertical   2nd/4th order               nn_ubs_v   = ', nn_ubs_v
206         WRITE(numout,*) '      QUICKEST scheme                           ln_trcadv_qck = ', ln_trcadv_qck
207      ENDIF
208      !
209      !                                !==  Parameter control & set nadv ==!
210      ioptio = 0
211      IF( ln_trcadv_OFF ) THEN   ;   ioptio = ioptio + 1   ;   nadv = np_NO_adv   ;   ENDIF
212      IF( ln_trcadv_cen ) THEN   ;   ioptio = ioptio + 1   ;   nadv = np_CEN      ;   ENDIF
213      IF( ln_trcadv_fct ) THEN   ;   ioptio = ioptio + 1   ;   nadv = np_FCT      ;   ENDIF
214      IF( ln_trcadv_mus ) THEN   ;   ioptio = ioptio + 1   ;   nadv = np_MUS      ;   ENDIF
215      IF( ln_trcadv_ubs ) THEN   ;   ioptio = ioptio + 1   ;   nadv = np_UBS      ;   ENDIF
216      IF( ln_trcadv_qck ) THEN   ;   ioptio = ioptio + 1   ;   nadv = np_QCK      ;   ENDIF
217      !
218      IF( ioptio /= 1 )   CALL ctl_stop( 'trc_adv_ini: Choose ONE advection option in namelist namtrc_adv' )
219      !
220      IF( ln_trcadv_cen .AND. ( nn_cen_h /= 2 .AND. nn_cen_h /= 4 )   &
221                        .AND. ( nn_cen_v /= 2 .AND. nn_cen_v /= 4 )   ) THEN
222        CALL ctl_stop( 'trc_adv_ini: CEN scheme, choose 2nd or 4th order' )
223      ENDIF
224      IF( ln_trcadv_fct .AND. ( nn_fct_h /= 2 .AND. nn_fct_h /= 4 )   &
225                        .AND. ( nn_fct_v /= 2 .AND. nn_fct_v /= 4 )   ) THEN
226        CALL ctl_stop( 'trc_adv_ini: FCT scheme, choose 2nd or 4th order' )
227      ENDIF
228      IF( ln_trcadv_ubs .AND. ( nn_ubs_v /= 2 .AND. nn_ubs_v /= 4 )   ) THEN
229        CALL ctl_stop( 'trc_adv_ini: UBS scheme, choose 2nd or 4th order' )
230      ENDIF
231      IF( ln_trcadv_ubs .AND. nn_ubs_v == 4 ) THEN
232         CALL ctl_warn( 'trc_adv_ini: UBS scheme, only 2nd FCT scheme available on the vertical. It will be used' )
233      ENDIF
234      IF( ln_isfcav ) THEN                                                       ! ice-shelf cavities
235         IF(  ln_trcadv_cen .AND. nn_cen_v == 4    .OR.   &                            ! NO 4th order with ISF
236            & ln_trcadv_fct .AND. nn_fct_v == 4   )   CALL ctl_stop( 'tra_adv_ini: 4th order COMPACT scheme not allowed with ISF' )
237      ENDIF
238      !
239      !                                !==  Print the choice  ==! 
240      IF(lwp) THEN
241         WRITE(numout,*)
242         SELECT CASE ( nadv )
243         CASE( np_NO_adv  )   ;   WRITE(numout,*) '      ===>>   NO passive tracer advection'
244         CASE( np_CEN     )   ;   WRITE(numout,*) '      ===>>   CEN      scheme is used. Horizontal order: ', nn_cen_h,   &
245            &                                                                     ' Vertical   order: ', nn_cen_v
246         CASE( np_FCT     )   ;   WRITE(numout,*) '      ===>>   FCT      scheme is used. Horizontal order: ', nn_fct_h,   &
247            &                                                                      ' Vertical   order: ', nn_fct_v
248         CASE( np_MUS     )   ;   WRITE(numout,*) '      ===>>   MUSCL    scheme is used'
249         CASE( np_UBS     )   ;   WRITE(numout,*) '      ===>>   UBS      scheme is used'
250         CASE( np_QCK     )   ;   WRITE(numout,*) '      ===>>   QUICKEST scheme is used'
251         END SELECT
252      ENDIF
253      !
254   END SUBROUTINE trc_adv_ini
255   
256#endif
257
258  !!======================================================================
259END MODULE trcadv
Note: See TracBrowser for help on using the repository browser.