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

source: NEMO/branches/UKMO/r8395_coupling_sequence/NEMOGCM/NEMO/TOP_SRC/TRP/trcnxt.F90 @ 10761

Last change on this file since 10761 was 10761, checked in by jcastill, 5 years ago

Remove svn keys

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