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_r9838_ENHANCE04_MLF/src/TOP/TRP – NEMO

source: NEMO/branches/2018/dev_r9838_ENHANCE04_MLF/src/TOP/TRP/trcnxt.F90 @ 9863

Last change on this file since 9863 was 9863, checked in by gm, 6 years ago

#1911 (ENHANCE-04): simplified implementation of the Euler stepping at nit000

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