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 branches/2015/dev_r5836_NOC3_vvl_by_default/NEMOGCM/NEMO/TOP_SRC/TRP – NEMO

source: branches/2015/dev_r5836_NOC3_vvl_by_default/NEMOGCM/NEMO/TOP_SRC/TRP/trcadv.F90 @ 5845

Last change on this file since 5845 was 5845, checked in by gm, 8 years ago

#1613: vvl by default: suppression of domzgr_substitute.h90

  • Property svn:keywords set to Id
File size: 15.6 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   !!----------------------------------------------------------------------
10#if defined key_top
11   !!----------------------------------------------------------------------
12   !!   'key_top'                                                TOP models
13   !!----------------------------------------------------------------------
14   !!   trc_adv       : compute ocean tracer advection trend
15   !!   trc_adv_ini   : control the different options of advection scheme
16   !!----------------------------------------------------------------------
17   USE oce_trc        ! ocean dynamics and active tracers
18   USE trc            ! ocean passive tracers variables
19   USE traadv_cen     ! centered scheme           (tra_adv_cen  routine)
20   USE traadv_fct     ! FCT      scheme           (tra_adv_fct  routine)
21   USE traadv_mus     ! MUSCL    scheme           (tra_adv_mus  routine)
22   USE traadv_ubs     ! UBS      scheme           (tra_adv_ubs  routine)
23   USE traadv_qck     ! QUICKEST scheme           (tra_adv_qck  routine)
24   USE traadv_mle     ! ML eddy induced velocity  (tra_adv_mle  routine)
25   USE ldftra         ! lateral diffusion coefficient on tracers
26   USE ldfslp         ! Lateral diffusion: slopes of neutral surfaces
27   !
28   USE prtctl_trc     ! Print control
29
30   IMPLICIT NONE
31   PRIVATE
32
33   PUBLIC   trc_adv       
34   PUBLIC   trc_adv_alloc 
35   PUBLIC   trc_adv_ini 
36
37   !                            !!* Namelist namtrc_adv *
38   LOGICAL ::   ln_trcadv_cen    ! centered scheme flag
39   INTEGER ::      nn_cen_h, nn_cen_v   ! =2/4 : horizontal and vertical choices of the order of CEN scheme
40   LOGICAL ::   ln_trcadv_fct    ! FCT scheme flag
41   INTEGER ::      nn_fct_h, nn_fct_v   ! =2/4 : horizontal and vertical choices of the order of FCT scheme
42   INTEGER ::      nn_fct_zts           ! >=1 : 2nd order FCT with vertical sub-timestepping
43   LOGICAL ::   ln_trcadv_mus    ! MUSCL scheme flag
44   LOGICAL ::      ln_mus_ups           ! use upstream scheme in vivcinity of river mouths
45   LOGICAL ::   ln_trcadv_ubs    ! UBS scheme flag
46   INTEGER ::      nn_ubs_v             ! =2/4 : vertical choice of the order of UBS scheme
47   LOGICAL ::   ln_trcadv_qck    ! QUICKEST scheme flag
48
49   !                                        ! choices of advection scheme:
50   INTEGER, PARAMETER ::   np_NO_adv  = 0   ! no T-S advection
51   INTEGER, PARAMETER ::   np_CEN     = 1   ! 2nd/4th order centered scheme
52   INTEGER, PARAMETER ::   np_FCT     = 2   ! 2nd/4th order Flux Corrected Transport scheme
53   INTEGER, PARAMETER ::   np_FCT_zts = 3   ! 2nd order FCT scheme with vertical sub-timestepping
54   INTEGER, PARAMETER ::   np_MUS     = 4   ! MUSCL scheme
55   INTEGER, PARAMETER ::   np_UBS     = 5   ! 3rd order Upstream Biased Scheme
56   INTEGER, PARAMETER ::   np_QCK     = 6   ! QUICK scheme
57
58   INTEGER ::              nadv             ! chosen advection scheme
59   !
60   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:) ::   r2dt  ! vertical profile time-step, = 2 rdttra
61   !                                                    ! except at nitrrc000 (=rdttra) if neuler=0
62
63   !! * Substitutions
64#  include "vectopt_loop_substitute.h90"
65   !!----------------------------------------------------------------------
66   !! NEMO/TOP 3.7 , NEMO Consortium (2015)
67   !! $Id$
68   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
69   !!----------------------------------------------------------------------
70CONTAINS
71
72   INTEGER FUNCTION trc_adv_alloc()
73      !!----------------------------------------------------------------------
74      !!                  ***  ROUTINE trc_adv_alloc  ***
75      !!----------------------------------------------------------------------
76      !
77      ALLOCATE( r2dt(jpk), STAT=trc_adv_alloc )
78      !
79      IF( trc_adv_alloc /= 0 ) CALL ctl_warn('trc_adv_alloc : failed to allocate array.')
80      !
81   END FUNCTION trc_adv_alloc
82
83
84   SUBROUTINE trc_adv( kt )
85      !!----------------------------------------------------------------------
86      !!                  ***  ROUTINE trc_adv  ***
87      !!
88      !! ** Purpose :   compute the ocean tracer advection trend.
89      !!
90      !! ** Method  : - Update the tracer with the advection term following nadv
91      !!----------------------------------------------------------------------
92      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
93      !
94      INTEGER ::   jk   ! dummy loop index
95      CHARACTER (len=22) ::   charout
96      REAL(wp), POINTER, DIMENSION(:,:,:) :: zun, zvn, zwn  ! effective velocity
97      !!----------------------------------------------------------------------
98      !
99      IF( nn_timing == 1 )   CALL timing_start('trc_adv')
100      !
101      CALL wrk_alloc( jpi,jpj,jpk,   zun, zvn, zwn )
102      !
103      IF( ( neuler == 0 .AND. kt == nittrc000 ) .OR. ln_top_euler ) THEN     ! at nittrc000
104         r2dt(:) =  rdttrc(:)           ! = rdttrc (use or restarting with Euler time stepping)
105      ELSEIF( kt <= nittrc000 + nn_dttrc ) THEN          ! at nittrc000 or nittrc000+1
106         r2dt(:) = 2. * rdttrc(:)       ! = 2 rdttrc (leapfrog)
107      ENDIF
108      !                                               !==  effective transport  ==!
109      DO jk = 1, jpkm1
110         zun(:,:,jk) = e2u  (:,:) * e3u_n(:,:,jk) * un(:,:,jk)                   ! eulerian transport
111         zvn(:,:,jk) = e1v  (:,:) * e3v_n(:,:,jk) * vn(:,:,jk)
112         zwn(:,:,jk) = e1e2t(:,:)                 * wn(:,:,jk)
113      END DO
114      !
115      IF( ln_vvl_ztilde .OR. ln_vvl_layer ) THEN                                 ! add z-tilde and/or vvl corrections
116         zun(:,:,:) = zun(:,:,:) + un_td(:,:,:)
117         zvn(:,:,:) = zvn(:,:,:) + vn_td(:,:,:)
118      ENDIF
119      !
120      IF( ln_ldfeiv .AND. .NOT. ln_traldf_triad )   & 
121         &              CALL ldf_eiv_trp( kt, nittrc000, zun, zvn, zwn, 'TRC' )  ! add the eiv transport
122      !
123      IF( ln_mle    )   CALL tra_adv_mle( kt, nittrc000, zun, zvn, zwn, 'TRC' )  ! add the mle transport
124      !
125      zun(:,:,jpk) = 0._wp                                                       ! no transport trough the bottom
126      zvn(:,:,jpk) = 0._wp
127      zwn(:,:,jpk) = 0._wp
128      !
129      !
130      SELECT CASE ( nadv )                      !==  compute advection trend and add it to general trend  ==!
131      !
132      CASE ( np_CEN )                                    ! Centered : 2nd / 4th order
133         CALL tra_adv_cen    ( kt, nittrc000,'TRC',       zun, zvn, zwn     , trn, tra, jptra, nn_cen_h, nn_cen_v )
134      CASE ( np_FCT )                                    ! FCT      : 2nd / 4th order
135         CALL tra_adv_fct    ( kt, nittrc000,'TRC', r2dt, zun, zvn, zwn, trb, trn, tra, jptra, nn_fct_h, nn_fct_v )
136      CASE ( np_FCT_zts )                                ! 2nd order FCT with vertical time-splitting
137         CALL tra_adv_fct_zts( kt, nittrc000,'TRC', r2dt, zun, zvn, zwn, trb, trn, tra, jptra        , nn_fct_zts )
138      CASE ( np_MUS )                                    ! MUSCL
139         CALL tra_adv_mus    ( kt, nittrc000,'TRC', r2dt, zun, zvn, zwn, trb,      tra, jptra        , ln_mus_ups ) 
140      CASE ( np_UBS )                                    ! UBS
141         CALL tra_adv_ubs    ( kt, nittrc000,'TRC', r2dt, zun, zvn, zwn, trb, trn, tra, jptra        , nn_ubs_v   )
142      CASE ( np_QCK )                                    ! QUICKEST
143         CALL tra_adv_qck    ( kt, nittrc000,'TRC', r2dt, zun, zvn, zwn, trb, trn, tra, jptra                     )
144      !
145      END SELECT
146      !                 
147      IF( ln_ctl )   THEN                             !== print mean trends (used for debugging)
148         WRITE(charout, FMT="('adv ')")  ;  CALL prt_ctl_trc_info(charout)
149                                            CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
150      END IF
151      !
152      CALL wrk_dealloc( jpi,jpj,jpk,   zun, zvn, zwn )
153      !
154      IF( nn_timing == 1 )  CALL timing_stop('trc_adv')
155      !
156   END SUBROUTINE trc_adv
157
158
159   SUBROUTINE trc_adv_ini
160      !!---------------------------------------------------------------------
161      !!                  ***  ROUTINE trc_adv_ini  ***
162      !!               
163      !! ** Purpose : Control the consistency between namelist options for
164      !!              passive tracer advection schemes and set nadv
165      !!----------------------------------------------------------------------
166      INTEGER ::   ioptio
167      INTEGER ::  ios                 ! Local integer output status for namelist read
168      !!
169      NAMELIST/namtrc_adv/ ln_trcadv_cen, nn_cen_h, nn_cen_v,               &   ! CEN
170         &                 ln_trcadv_fct, nn_fct_h, nn_fct_v, nn_fct_zts,   &   ! FCT
171         &                 ln_trcadv_mus,                     ln_mus_ups,   &   ! MUSCL
172         &                 ln_trcadv_ubs,           nn_ubs_v,               &   ! UBS
173         &                 ln_trcadv_qck                                        ! QCK
174      !!----------------------------------------------------------------------
175      !
176      REWIND( numnat_ref )              !  namtrc_adv in reference namelist
177      READ  ( numnat_ref, namtrc_adv, IOSTAT = ios, ERR = 901)
178901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_adv in reference namelist', lwp )
179
180      REWIND( numnat_cfg )              ! namtrc_adv in configuration namelist
181      READ  ( numnat_cfg, namtrc_adv, IOSTAT = ios, ERR = 902 )
182902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_adv in configuration namelist', lwp )
183      IF(lwm) WRITE ( numont, namtrc_adv )
184
185      IF(lwp) THEN                    ! Namelist print
186         WRITE(numout,*)
187         WRITE(numout,*) 'trc_adv_ini : choice/control of the tracer advection scheme'
188         WRITE(numout,*) '~~~~~~~~~~~'
189         WRITE(numout,*) '   Namelist namtrc_adv : chose a advection scheme for tracers'
190         WRITE(numout,*) '      centered scheme                           ln_trcadv_cen = ', ln_trcadv_cen
191         WRITE(numout,*) '            horizontal 2nd/4th order               nn_cen_h   = ', nn_fct_h
192         WRITE(numout,*) '            vertical   2nd/4th order               nn_cen_v   = ', nn_fct_v
193         WRITE(numout,*) '      Flux Corrected Transport scheme           ln_trcadv_fct = ', ln_trcadv_fct
194         WRITE(numout,*) '            horizontal 2nd/4th order               nn_fct_h   = ', nn_fct_h
195         WRITE(numout,*) '            vertical   2nd/4th order               nn_fct_v   = ', nn_fct_v
196         WRITE(numout,*) '            2nd order + vertical sub-timestepping  nn_fct_zts = ', nn_fct_zts
197         WRITE(numout,*) '      MUSCL scheme                              ln_trcadv_mus = ', ln_trcadv_mus
198         WRITE(numout,*) '            + upstream scheme near river mouths    ln_mus_ups = ', ln_mus_ups
199         WRITE(numout,*) '      UBS scheme                                ln_trcadv_ubs = ', ln_trcadv_ubs
200         WRITE(numout,*) '            vertical   2nd/4th order               nn_ubs_v   = ', nn_ubs_v
201         WRITE(numout,*) '      QUICKEST scheme                           ln_trcadv_qck = ', ln_trcadv_qck
202      ENDIF
203      !
204
205      ioptio = 0                       !==  Parameter control  ==!
206      IF( ln_trcadv_cen )   ioptio = ioptio + 1
207      IF( ln_trcadv_fct )   ioptio = ioptio + 1
208      IF( ln_trcadv_mus )   ioptio = ioptio + 1
209      IF( ln_trcadv_ubs )   ioptio = ioptio + 1
210      IF( ln_trcadv_qck )   ioptio = ioptio + 1
211
212      !
213      IF( ioptio == 0 ) THEN
214         nadv = np_NO_adv
215         CALL ctl_warn( 'trc_adv_init: You are running without tracer advection.' )
216      ENDIF
217      IF( ioptio /= 1 )   CALL ctl_stop( 'Choose ONE advection scheme in namelist namtrc_adv' )
218      !
219      IF( ln_trcadv_cen .AND. ( nn_cen_h /= 2 .AND. nn_cen_h /= 4 )   &
220                        .AND. ( nn_cen_v /= 2 .AND. nn_cen_v /= 4 )   ) THEN
221        CALL ctl_stop( 'trc_adv_init: CEN scheme, choose 2nd or 4th order' )
222      ENDIF
223      IF( ln_trcadv_fct .AND. ( nn_fct_h /= 2 .AND. nn_fct_h /= 4 )   &
224                        .AND. ( nn_fct_v /= 2 .AND. nn_fct_v /= 4 )   ) THEN
225        CALL ctl_stop( 'trc_adv_init: FCT scheme, choose 2nd or 4th order' )
226      ENDIF
227      IF( ln_trcadv_fct .AND. nn_fct_zts > 0 ) THEN
228         IF( nn_fct_h == 4 ) THEN
229            nn_fct_h = 2
230            CALL ctl_stop( 'trc_adv_init: force 2nd order FCT scheme, 4th order does not exist with sub-timestepping' )
231         ENDIF
232         IF( lk_vvl ) THEN
233            CALL ctl_stop( 'trc_adv_init: vertical sub-timestepping not allow in non-linear free surface' )
234         ENDIF
235         IF( nn_fct_zts == 1 )   CALL ctl_warn( 'trc_adv_init: FCT with ONE sub-timestep = FCT without sub-timestep' )
236      ENDIF
237      IF( ln_trcadv_ubs .AND. ( nn_ubs_v /= 2 .AND. nn_ubs_v /= 4 )   ) THEN
238        CALL ctl_stop( 'trc_adv_init: UBS scheme, choose 2nd or 4th order' )
239      ENDIF
240      IF( ln_trcadv_ubs .AND. nn_ubs_v == 4 ) THEN
241         CALL ctl_warn( 'trc_adv_init: UBS scheme, only 2nd FCT scheme available on the vertical. It will be used' )
242      ENDIF
243      IF( ln_isfcav ) THEN                                                       ! ice-shelf cavities
244         IF(  ln_trcadv_cen .AND. nn_cen_v /= 4    .OR.   &                            ! NO 4th order with ISF
245            & ln_trcadv_fct .AND. nn_fct_v /= 4   )   CALL ctl_stop( 'tra_adv_init: 4th order COMPACT scheme not allowed with ISF' )
246      ENDIF
247      !
248      !                                !==  used advection scheme  ==!
249      !                                      ! set nadv
250      IF( ln_trcadv_cen                      )   nadv = np_CEN
251      IF( ln_trcadv_fct                      )   nadv = np_FCT
252      IF( ln_trcadv_fct .AND. nn_fct_zts > 0 )   nadv = np_FCT_zts
253      IF( ln_trcadv_mus                      )   nadv = np_MUS
254      IF( ln_trcadv_ubs                      )   nadv = np_UBS
255      IF( ln_trcadv_qck                      )   nadv = np_QCK
256      !
257      IF(lwp) THEN                   ! Print the choice
258         WRITE(numout,*)
259         IF( nadv == np_NO_adv  )   WRITE(numout,*) '         NO passive tracer advection'
260         IF( nadv == np_CEN     )   WRITE(numout,*) '         CEN      scheme is used. Horizontal order: ', nn_cen_h,   &
261            &                                                                        ' Vertical   order: ', nn_cen_v
262         IF( nadv == np_FCT     )   WRITE(numout,*) '         FCT      scheme is used. Horizontal order: ', nn_fct_h,   &
263            &                                                                       ' Vertical   order: ', nn_fct_v
264         IF( nadv == np_FCT_zts )   WRITE(numout,*) '         use 2nd order FCT with ', nn_fct_zts,'vertical sub-timestepping'
265         IF( nadv == np_MUS     )   WRITE(numout,*) '         MUSCL    scheme is used'
266         IF( nadv == np_UBS     )   WRITE(numout,*) '         UBS      scheme is used'
267         IF( nadv == np_QCK     )   WRITE(numout,*) '         QUICKEST scheme is used'
268      ENDIF
269      !
270   END SUBROUTINE trc_adv_ini
271   
272#else
273   !!----------------------------------------------------------------------
274   !!   Default option                                         Empty module
275   !!----------------------------------------------------------------------
276CONTAINS
277   SUBROUTINE trc_adv( kt )
278      INTEGER, INTENT(in) :: kt
279      WRITE(*,*) 'trc_adv: You should not have seen this print! error?', kt
280   END SUBROUTINE trc_adv
281#endif
282
283  !!======================================================================
284END MODULE trcadv
Note: See TracBrowser for help on using the repository browser.