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

source: branches/2015/nemo_v3_6_STABLE/NEMOGCM/NEMO/TOP_SRC/TRP/trcnxt.F90 @ 8398

Last change on this file since 8398 was 8398, checked in by lovato, 7 years ago

3.6_stable : Add ln_top_euler control in trcnxt (#1930)

  • Property svn:keywords set to Id
File size: 11.5 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             ! 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
39   IMPLICIT NONE
40   PRIVATE
41
42   PUBLIC   trc_nxt          ! routine called by step.F90
43   PUBLIC   trc_nxt_alloc    ! routine called by nemogcm.F90
44
45   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:) ::   r2dt
46   REAL(wp)  ::  rfact1, rfact2
47
48   !! * Substitutions
49#  include "domzgr_substitute.h90"
50#  include "vectopt_loop_substitute.h90"
51   !!----------------------------------------------------------------------
52   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
53   !! $Id$
54   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
55   !!----------------------------------------------------------------------
56
57CONTAINS
58
59   INTEGER FUNCTION trc_nxt_alloc()
60      !!----------------------------------------------------------------------
61      !!                   ***  ROUTINE trc_nxt_alloc  ***
62      !!----------------------------------------------------------------------
63      ALLOCATE( r2dt(jpk), STAT=trc_nxt_alloc )
64      !
65      IF( trc_nxt_alloc /= 0 )   CALL ctl_warn('trc_nxt_alloc : failed to allocate array')
66      !
67   END FUNCTION trc_nxt_alloc
68
69
70   SUBROUTINE trc_nxt( kt )
71      !!----------------------------------------------------------------------
72      !!                   ***  ROUTINE trcnxt  ***
73      !!
74      !! ** Purpose :   Compute the passive tracers fields at the
75      !!      next time-step from their temporal trends and swap the fields.
76      !!
77      !! ** Method  :   Apply lateral boundary conditions on (ua,va) through
78      !!      call to lbc_lnk routine
79      !!   default:
80      !!      arrays swap
81      !!         (trn) = (tra) ; (tra) = (0,0)
82      !!         (trb) = (trn)
83      !!
84      !!   For Arakawa or TVD Scheme :
85      !!      A Asselin time filter applied on now tracers (trn) to avoid
86      !!      the divergence of two consecutive time-steps and tr arrays
87      !!      to prepare the next time_step:
88      !!         (trb) = (trn) + atfp [ (trb) + (tra) - 2 (trn) ]
89      !!         (trn) = (tra) ; (tra) = (0,0)
90      !!
91      !!
92      !! ** Action  : - update trb, trn
93      !!----------------------------------------------------------------------
94      INTEGER, INTENT( in ) ::   kt     ! ocean time-step index
95      !
96      INTEGER  ::   jk, jn   ! dummy loop indices
97      REAL(wp) ::   zfact            ! temporary scalar
98      CHARACTER (len=22) :: charout
99      REAL(wp), POINTER, DIMENSION(:,:,:,:) ::  ztrdt 
100      !!----------------------------------------------------------------------
101      !
102      IF( nn_timing == 1 )  CALL timing_start('trc_nxt')
103      !
104      IF( kt == nittrc000 .AND. lwp ) THEN
105         WRITE(numout,*)
106         WRITE(numout,*) 'trc_nxt : time stepping on passive tracers'
107      ENDIF
108
109#if defined key_agrif
110      CALL Agrif_trc                   ! AGRIF zoom boundaries
111#endif
112      ! Update after tracer on domain lateral boundaries
113      DO jn = 1, jptra
114         CALL lbc_lnk( tra(:,:,:,jn), 'T', 1. )   
115      END DO
116
117
118#if defined key_bdy
119!!      CALL bdy_trc( kt )               ! BDY open boundaries
120#endif
121
122
123      ! set time step size (Euler/Leapfrog)
124      IF( (neuler == 0 .AND. kt == nittrc000) .OR. ln_top_euler ) THEN  ;  r2dt(:) =     rdttrc(:)   !    (Euler)
125      ELSEIF( kt <= nittrc000 + nn_dttrc )     THEN  ;  r2dt(:) = 2.* rdttrc(:)   ! at nit000 or nit000+1 (Leapfrog)
126      ENDIF
127
128      ! trends computation initialisation
129      IF( l_trdtrc )  THEN
130         CALL wrk_alloc( jpi, jpj, jpk, jptra, ztrdt )  !* store now fields before applying the Asselin filter
131         ztrdt(:,:,:,:)  = trn(:,:,:,:)
132      ENDIF
133      ! Leap-Frog + Asselin filter time stepping
134      IF( (neuler == 0 .AND. kt == nittrc000) .OR. ln_top_euler ) THEN        ! Euler time-stepping (only swap)
135         !                                                ! (only swap)
136         DO jn = 1, jptra
137            DO jk = 1, jpkm1
138               trn(:,:,jk,jn) = tra(:,:,jk,jn)
139               trb(:,:,jk,jn) = trn(:,:,jk,jn) 
140            END DO
141         END DO
142         !                                             
143      ELSE
144         IF( .NOT. lk_offline ) THEN ! Leap-Frog + Asselin filter time stepping
145            IF( lk_vvl ) THEN   ;   CALL tra_nxt_vvl( kt, nittrc000, rdttrc, 'TRC', trb, trn, tra,      &
146              &                                                                sbc_trc, sbc_trc_b, jptra )      ! variable volume level (vvl)
147            ELSE                ;   CALL tra_nxt_fix( kt, nittrc000,         'TRC', trb, trn, tra, jptra )      ! fixed    volume level
148            ENDIF
149         ELSE
150                                    CALL trc_nxt_off( kt )       ! offline
151         ENDIF
152      ENDIF
153
154      ! trends computation
155      IF( l_trdtrc ) THEN                                      ! trends
156         DO jn = 1, jptra
157            DO jk = 1, jpkm1
158               zfact = 1.e0 / r2dt(jk) 
159               ztrdt(:,:,jk,jn) = ( trb(:,:,jk,jn) - ztrdt(:,:,jk,jn) ) * zfact 
160               CALL trd_tra( kt, 'TRC', jn, jptra_atf, ztrdt )
161            END DO
162         END DO
163         CALL wrk_dealloc( jpi, jpj, jpk, jptra, ztrdt ) 
164      END IF
165      !
166      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
167         WRITE(charout, FMT="('nxt')")
168         CALL prt_ctl_trc_info(charout)
169         CALL prt_ctl_trc(tab4d=trn, mask=tmask, clinfo=ctrcnm)
170      ENDIF
171      !
172      IF( nn_timing == 1 )  CALL timing_stop('trc_nxt')
173      !
174   END SUBROUTINE trc_nxt
175
176   SUBROUTINE trc_nxt_off( kt )
177      !!----------------------------------------------------------------------
178      !!                   ***  ROUTINE tra_nxt_vvl  ***
179      !!
180      !! ** Purpose :   Time varying volume: apply the Asselin time filter 
181      !!                and swap the tracer fields.
182      !!
183      !! ** Method  : - Apply a thickness weighted Asselin time filter on now fields.
184      !!              - save in (ta,sa) a thickness weighted average over the three
185      !!             time levels which will be used to compute rdn and thus the semi-
186      !!             implicit hydrostatic pressure gradient (ln_dynhpg_imp = T)
187      !!              - swap tracer fields to prepare the next time_step.
188      !!                This can be summurized for tempearture as:
189      !!             ztm = ( e3t_n*tn + rbcp*[ e3t_b*tb - 2 e3t_n*tn + e3t_a*ta ] )   ln_dynhpg_imp = T
190      !!                  /( e3t_n    + rbcp*[ e3t_b    - 2 e3t_n    + e3t_a    ] )   
191      !!             ztm = 0                                                       otherwise
192      !!             tb  = ( e3t_n*tn + atfp*[ e3t_b*tb - 2 e3t_n*tn + e3t_a*ta ] )
193      !!                  /( e3t_n    + atfp*[ e3t_b    - 2 e3t_n    + e3t_a    ] )
194      !!             tn  = ta
195      !!             ta  = zt        (NB: reset to 0 after eos_bn2 call)
196      !!
197      !! ** Action  : - (tb,sb) and (tn,sn) ready for the next time step
198      !!              - (ta,sa) time averaged (t,s)   (ln_dynhpg_imp = T)
199      !!----------------------------------------------------------------------
200      INTEGER         , INTENT(in   )                               ::  kt       ! ocean time-step index
201      !!     
202      INTEGER  ::   ji, jj, jk, jn              ! dummy loop indices
203      REAL(wp) ::   ztc_a , ztc_n , ztc_b , ztc_f , ztc_d    ! local scalar
204      REAL(wp) ::   ze3t_b, ze3t_n, ze3t_a, ze3t_f, ze3t_d   !   -      -
205      !!----------------------------------------------------------------------
206      !
207      IF( kt == nittrc000 )  THEN
208         IF(lwp) WRITE(numout,*)
209         IF(lwp) WRITE(numout,*) 'trc_nxt_off : time stepping'
210         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
211         IF( lk_vvl ) THEN
212           rfact1 = atfp * rdttrc(1)
213           rfact2 = rfact1 / rau0
214         ENDIF
215      ENDIF
216      !
217      DO jn = 1, jptra     
218         DO jk = 1, jpkm1
219            DO jj = 1, jpj
220               DO ji = 1, jpi
221                  ze3t_b = fse3t_b(ji,jj,jk)
222                  ze3t_n = fse3t_n(ji,jj,jk)
223                  ze3t_a = fse3t_a(ji,jj,jk)
224                  !                                         ! tracer content at Before, now and after
225                  ztc_b  = trb(ji,jj,jk,jn) * ze3t_b
226                  ztc_n  = trn(ji,jj,jk,jn) * ze3t_n
227                  ztc_a  = tra(ji,jj,jk,jn) * ze3t_a
228                  !
229                  ze3t_d = ze3t_a - 2. * ze3t_n + ze3t_b
230                  ztc_d  = ztc_a  - 2. * ztc_n  + ztc_b
231                  !
232                  ze3t_f = ze3t_n + atfp * ze3t_d
233                  ztc_f  = ztc_n  + atfp * ztc_d
234                  !
235                  IF( lk_vvl .AND. jk == mikt(ji,jj) ) THEN           ! first level
236                     ze3t_f = ze3t_f - rfact2 * ( emp_b(ji,jj)      - emp(ji,jj)   ) 
237                     ztc_f  = ztc_f  - rfact1 * ( sbc_trc(ji,jj,jn) - sbc_trc_b(ji,jj,jn) )
238                  ENDIF
239
240                  ze3t_f = 1.e0 / ze3t_f
241                  trb(ji,jj,jk,jn) = ztc_f * ze3t_f       ! ptb <-- ptn filtered
242                  trn(ji,jj,jk,jn) = tra(ji,jj,jk,jn)     ! ptn <-- pta
243                  !
244               END DO
245            END DO
246         END DO
247         !
248      END DO
249      !
250   END SUBROUTINE trc_nxt_off
251#else
252   !!----------------------------------------------------------------------
253   !!   Default option                                         Empty module
254   !!----------------------------------------------------------------------
255CONTAINS
256   SUBROUTINE trc_nxt( kt ) 
257      INTEGER, INTENT(in) :: kt
258      WRITE(*,*) 'trc_nxt: You should not have seen this print! error?', kt
259   END SUBROUTINE trc_nxt
260#endif
261   !!======================================================================
262END MODULE trcnxt
Note: See TracBrowser for help on using the repository browser.