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 @ 13982

Last change on this file since 13982 was 13982, checked in by smasson, 3 years ago

trunk: merge dev_r13923_Tiling_Cleanup_MPI3_LoopFusion into the trunk

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