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.
trcnxt.F90 in NEMO/branches/2018/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/TRP – NEMO

source: NEMO/branches/2018/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/TRP/trcnxt.F90 @ 10115

Last change on this file since 10115 was 10115, checked in by cbricaud, 6 years ago

phase 3.6 coarsening branch with nemo_3.6_rev9192

  • Property svn:keywords set to Id
File size: 12.1 KB
Line 
1MODULE trcnxt
2   !!======================================================================
3   !!                       ***  MODULE  trcnxt  ***
4   !! Ocean passive tracers:  time stepping on passives tracers
5   !!======================================================================
6   !! History :  7.0  !  1991-11  (G. Madec)  Original code
7   !!                 !  1993-03  (M. Guyon)  symetrical conditions
8   !!                 !  1995-02  (M. Levy)   passive tracers
9   !!                 !  1996-02  (G. Madec & M. Imbard)  opa release 8.0
10   !!            8.0  !  1996-04  (A. Weaver)  Euler forward step
11   !!            8.2  !  1999-02  (G. Madec, N. Grima)  semi-implicit pressure grad.
12   !!  NEMO      1.0  !  2002-08  (G. Madec)  F90: Free form and module
13   !!                 !  2002-08  (G. Madec)  F90: Free form and module
14   !!                 !  2002-11  (C. Talandier, A-M Treguier) Open boundaries
15   !!                 !  2004-03  (C. Ethe) passive tracers
16   !!                 !  2007-02  (C. Deltel) Diagnose ML trends for passive tracers
17   !!            2.0  !  2006-02  (L. Debreu, C. Mazauric) Agrif implementation
18   !!            3.0  !  2008-06  (G. Madec)  time stepping always done in trazdf
19   !!            3.1  !  2009-02  (G. Madec, R. Benshila)  re-introduce the vvl option
20   !!            3.3  !  2010-06  (C. Ethe, G. Madec) Merge TRA-TRC
21   !!----------------------------------------------------------------------
22#if defined key_top
23   !!----------------------------------------------------------------------
24   !!   'key_top'                                                TOP models
25   !!----------------------------------------------------------------------
26   !!   trc_nxt     : time stepping on passive tracers
27   !!----------------------------------------------------------------------
28   USE oce_trc         ! ocean dynamics and tracers variables
29   USE trc, ONLY : nittrc000, tra, jptra,rdttrc,trb, trn,tra,ctrcnm,sbc_trc,sbc_trc_b ! ocean passive tracers variables
30   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
31   USE prtctl_trc      ! Print control for debbuging
32   USE trd_oce
33   USE trdtra
34   USE tranxt
35# if defined key_agrif
36   USE agrif_top_interp
37# endif
38   USE crs, ONLY : ln_crs_top
39   USE ieee_arithmetic
40#if defined key_crs
41   USE crslbclnk , ONLY : crs_lbc_lnk
42#endif
43
44   IMPLICIT NONE
45   PRIVATE
46
47   PUBLIC   trc_nxt          ! routine called by step.F90
48   PUBLIC   trc_nxt_alloc    ! routine called by nemogcm.F90
49
50   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:) ::   r2dt
51   REAL(wp)  ::  rfact1, rfact2
52
53   !! * Substitutions
54#  include "domzgr_substitute.h90"
55#  include "vectopt_loop_substitute.h90"
56   !!----------------------------------------------------------------------
57   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
58   !! $Id$
59   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
60   !!----------------------------------------------------------------------
61CONTAINS
62
63   INTEGER FUNCTION trc_nxt_alloc()
64      !!----------------------------------------------------------------------
65      !!                   ***  ROUTINE trc_nxt_alloc  ***
66      !!----------------------------------------------------------------------
67      ALLOCATE( r2dt(jpk), STAT=trc_nxt_alloc )
68      !
69      IF( trc_nxt_alloc /= 0 )   CALL ctl_warn('trc_nxt_alloc : failed to allocate array')
70      !
71   END FUNCTION trc_nxt_alloc
72
73
74   SUBROUTINE trc_nxt( kt )
75      !!----------------------------------------------------------------------
76      !!                   ***  ROUTINE trcnxt  ***
77      !!
78      !! ** Purpose :   Compute the passive tracers fields at the
79      !!      next time-step from their temporal trends and swap the fields.
80      !!
81      !! ** Method  :   Apply lateral boundary conditions on (ua,va) through
82      !!      call to lbc_lnk routine
83      !!   default:
84      !!      arrays swap
85      !!         (trn) = (tra) ; (tra) = (0,0)
86      !!         (trb) = (trn)
87      !!
88      !!   For Arakawa or TVD Scheme :
89      !!      A Asselin time filter applied on now tracers (trn) to avoid
90      !!      the divergence of two consecutive time-steps and tr arrays
91      !!      to prepare the next time_step:
92      !!         (trb) = (trn) + atfp [ (trb) + (tra) - 2 (trn) ]
93      !!         (trn) = (tra) ; (tra) = (0,0)
94      !!
95      !!
96      !! ** Action  : - update trb, trn
97      !!----------------------------------------------------------------------
98      INTEGER, INTENT( in ) ::   kt     ! ocean time-step index
99      !
100      INTEGER  ::   ji,jj,jk, jn   ! dummy loop indices
101      REAL(wp) ::   zfact            ! temporary scalar
102      CHARACTER (len=22) :: charout
103      REAL(wp), POINTER, DIMENSION(:,:,:,:) ::  ztrdt 
104      !!----------------------------------------------------------------------
105      !
106      IF( nn_timing == 1 )  CALL timing_start('trc_nxt')
107      !
108      IF( kt == nittrc000 .AND. lwp ) THEN
109         WRITE(numout,*)
110         WRITE(numout,*) 'trc_nxt : time stepping on passive tracers'
111      ENDIF
112
113#if defined key_agrif
114      CALL Agrif_trc                   ! AGRIF zoom boundaries
115#endif
116      ! Update after tracer on domain lateral boundaries
117      DO jn = 1, jptra
118#if defined key_crs
119         CALL crs_lbc_lnk( tra(:,:,:,jn), 'T', 1. )   
120#else
121         CALL lbc_lnk( tra(:,:,:,jn), 'T', 1. )   
122#endif
123      END DO
124
125
126#if defined key_bdy
127!!      CALL bdy_trc( kt )               ! BDY open boundaries
128#endif
129
130
131      ! set time step size (Euler/Leapfrog)
132      IF( neuler == 0 .AND. kt ==  nittrc000 ) THEN  ;  r2dt(:) =     rdttrc(:)   ! at nittrc000             (Euler)
133      ELSEIF( kt <= nittrc000 + nn_dttrc )     THEN  ;  r2dt(:) = 2.* rdttrc(:)   ! at nit000 or nit000+1 (Leapfrog)
134      ENDIF
135
136      ! trends computation initialisation
137      IF( l_trdtrc )  THEN
138         CALL wrk_alloc( jpi, jpj, jpk, jptra, ztrdt )  !* store now fields before applying the Asselin filter
139         ztrdt(:,:,:,:)  = trn(:,:,:,:)
140      ENDIF
141      ! Leap-Frog + Asselin filter time stepping
142      IF( neuler == 0 .AND. kt == nittrc000 ) THEN        ! Euler time-stepping at first time-step
143         !                                                ! (only swap)
144         DO jn = 1, jptra
145            DO jk = 1, jpkm1
146               trn(:,:,jk,jn) = tra(:,:,jk,jn)
147            END DO
148         END DO
149         !                                             
150      ELSE
151         IF( .NOT. lk_offline ) THEN ! Leap-Frog + Asselin filter time stepping
152
153            IF( lk_vvl ) THEN   
154               IF( ln_crs_top )THEN
155                  CALL tra_nxt_vvl_crs( kt, nittrc000, rdttrc, 'TRC', trb, trn, tra,      &
156                 &                                              sbc_trc, sbc_trc_b, jptra )      ! variable volume level (vvl)
157               ELSE
158                  CALL tra_nxt_vvl( kt, nittrc000, rdttrc, 'TRC', trb, trn, tra,      &
159                 &                                          sbc_trc, sbc_trc_b, jptra )      ! variable volume level (vvl)
160               ENDIF
161            ELSE                   
162               CALL tra_nxt_fix( kt, nittrc000,         'TRC', trb, trn, tra, jptra )      ! fixed    volume level
163            ENDIF
164
165         ELSE
166                                    CALL trc_nxt_off( kt )       ! offline
167         ENDIF
168
169
170      ENDIF
171
172      ! trends computation
173      IF( l_trdtrc ) THEN                                      ! trends
174         DO jn = 1, jptra
175            DO jk = 1, jpkm1
176               zfact = 1.e0 / r2dt(jk) 
177               ztrdt(:,:,jk,jn) = ( trb(:,:,jk,jn) - ztrdt(:,:,jk,jn) ) * zfact 
178               CALL trd_tra( kt, 'TRC', jn, jptra_atf, ztrdt )
179            END DO
180         END DO
181         CALL wrk_dealloc( jpi, jpj, jpk, jptra, ztrdt ) 
182      END IF
183      !
184      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
185         WRITE(charout, FMT="('nxt')")
186         CALL prt_ctl_trc_info(charout)
187         CALL prt_ctl_trc(tab4d=trn, mask=tmask, clinfo=ctrcnm)
188      ENDIF
189      !
190      IF( nn_timing == 1 )  CALL timing_stop('trc_nxt')
191      !
192   END SUBROUTINE trc_nxt
193
194   SUBROUTINE trc_nxt_off( kt )
195      !!----------------------------------------------------------------------
196      !!                   ***  ROUTINE tra_nxt_vvl  ***
197      !!
198      !! ** Purpose :   Time varying volume: apply the Asselin time filter 
199      !!                and swap the tracer fields.
200      !!
201      !! ** Method  : - Apply a thickness weighted Asselin time filter on now fields.
202      !!              - save in (ta,sa) a thickness weighted average over the three
203      !!             time levels which will be used to compute rdn and thus the semi-
204      !!             implicit hydrostatic pressure gradient (ln_dynhpg_imp = T)
205      !!              - swap tracer fields to prepare the next time_step.
206      !!                This can be summurized for tempearture as:
207      !!             ztm = ( e3t_n*tn + rbcp*[ e3t_b*tb - 2 e3t_n*tn + e3t_a*ta ] )   ln_dynhpg_imp = T
208      !!                  /( e3t_n    + rbcp*[ e3t_b    - 2 e3t_n    + e3t_a    ] )   
209      !!             ztm = 0                                                       otherwise
210      !!             tb  = ( e3t_n*tn + atfp*[ e3t_b*tb - 2 e3t_n*tn + e3t_a*ta ] )
211      !!                  /( e3t_n    + atfp*[ e3t_b    - 2 e3t_n    + e3t_a    ] )
212      !!             tn  = ta
213      !!             ta  = zt        (NB: reset to 0 after eos_bn2 call)
214      !!
215      !! ** Action  : - (tb,sb) and (tn,sn) ready for the next time step
216      !!              - (ta,sa) time averaged (t,s)   (ln_dynhpg_imp = T)
217      !!----------------------------------------------------------------------
218      INTEGER         , INTENT(in   )                               ::  kt       ! ocean time-step index
219      !!     
220      INTEGER  ::   ji, jj, jk, jn              ! dummy loop indices
221      REAL(wp) ::   ztc_a , ztc_n , ztc_b , ztc_f , ztc_d    ! local scalar
222      REAL(wp) ::   ze3t_b, ze3t_n, ze3t_a, ze3t_f, ze3t_d   !   -      -
223      !!----------------------------------------------------------------------
224      !
225      IF( kt == nittrc000 )  THEN
226         IF(lwp) WRITE(numout,*)
227         IF(lwp) WRITE(numout,*) 'trc_nxt_off : time stepping'
228         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
229         IF( lk_vvl ) THEN
230           rfact1 = atfp * rdttrc(1)
231           rfact2 = rfact1 / rau0
232         ENDIF
233      ENDIF
234      !
235      DO jn = 1, jptra
236         DO jk = 1, jpkm1
237            DO jj = 1, jpj
238               DO ji = 1, jpi
239                  ze3t_b = fse3t_b(ji,jj,jk)
240                  ze3t_n = fse3t_n(ji,jj,jk)
241                  ze3t_a = fse3t_a(ji,jj,jk)
242                  !                                         ! tracer content at Before, now and after
243                  ztc_b  = trb(ji,jj,jk,jn) * ze3t_b
244                  ztc_n  = trn(ji,jj,jk,jn) * ze3t_n
245                  ztc_a  = tra(ji,jj,jk,jn) * ze3t_a
246                  !
247                  ze3t_d = ze3t_a - 2. * ze3t_n + ze3t_b
248                  ztc_d  = ztc_a  - 2. * ztc_n  + ztc_b
249                  !
250                  ze3t_f = ze3t_n + atfp * ze3t_d
251                  ztc_f  = ztc_n  + atfp * ztc_d
252                  !
253                  IF( lk_vvl .AND. jk == mikt(ji,jj) ) THEN           ! first level
254                     ze3t_f = ze3t_f - rfact2 * ( emp_b(ji,jj)      - emp(ji,jj)   )
255                     ztc_f  = ztc_f  - rfact1 * ( sbc_trc(ji,jj,jn) - sbc_trc_b(ji,jj,jn) )
256                  ENDIF
257
258                  ze3t_f = 1.e0 / ze3t_f
259                  trb(ji,jj,jk,jn) = ztc_f * ze3t_f       ! ptb <-- ptn filtered
260                  trn(ji,jj,jk,jn) = tra(ji,jj,jk,jn)     ! ptn <-- pta
261                  !
262               END DO
263            END DO
264         END DO
265         !
266      END DO
267      !
268   END SUBROUTINE trc_nxt_off
269
270#else
271   !!----------------------------------------------------------------------
272   !!   Default option                                         Empty module
273   !!----------------------------------------------------------------------
274CONTAINS
275   SUBROUTINE trc_nxt( kt ) 
276      INTEGER, INTENT(in) :: kt
277      WRITE(*,*) 'trc_nxt: You should not have seen this print! error?', kt
278   END SUBROUTINE trc_nxt
279#endif
280   !!======================================================================
281END MODULE trcnxt
Note: See TracBrowser for help on using the repository browser.