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

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

trunk: merge dev_r14312_MPI_Interface into the trunk, #2598

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