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

source: trunk/NEMOGCM/NEMO/TOP_SRC/TRP/trcadv.F90 @ 7698

Last change on this file since 7698 was 7698, checked in by mocavero, 7 years ago

update trunk with OpenMP parallelization

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