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

source: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/TRP/trcnxt.F90 @ 7256

Last change on this file since 7256 was 7256, checked in by cbricaud, 7 years ago

phaze NEMO routines in CRS branch with nemo_v3_6_STABLE branch at rev 7213 (09-09-2016) (merge -r 5519:7213 )

  • Property svn:keywords set to Id
File size: 8.0 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
41   IMPLICIT NONE
42   PRIVATE
43
44   PUBLIC   trc_nxt          ! routine called by step.F90
45   PUBLIC   trc_nxt_alloc    ! routine called by nemogcm.F90
46
47   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:) ::   r2dt
48
49   !!----------------------------------------------------------------------
50   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
51   !! $Id$
52   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
53   !!----------------------------------------------------------------------
54CONTAINS
55
56   INTEGER FUNCTION trc_nxt_alloc()
57      !!----------------------------------------------------------------------
58      !!                   ***  ROUTINE trc_nxt_alloc  ***
59      !!----------------------------------------------------------------------
60      ALLOCATE( r2dt(jpk), STAT=trc_nxt_alloc )
61      !
62      IF( trc_nxt_alloc /= 0 )   CALL ctl_warn('trc_nxt_alloc : failed to allocate array')
63      !
64   END FUNCTION trc_nxt_alloc
65
66
67   SUBROUTINE trc_nxt( kt )
68      !!----------------------------------------------------------------------
69      !!                   ***  ROUTINE trcnxt  ***
70      !!
71      !! ** Purpose :   Compute the passive tracers fields at the
72      !!      next time-step from their temporal trends and swap the fields.
73      !!
74      !! ** Method  :   Apply lateral boundary conditions on (ua,va) through
75      !!      call to lbc_lnk routine
76      !!   default:
77      !!      arrays swap
78      !!         (trn) = (tra) ; (tra) = (0,0)
79      !!         (trb) = (trn)
80      !!
81      !!   For Arakawa or TVD Scheme :
82      !!      A Asselin time filter applied on now tracers (trn) to avoid
83      !!      the divergence of two consecutive time-steps and tr arrays
84      !!      to prepare the next time_step:
85      !!         (trb) = (trn) + atfp [ (trb) + (tra) - 2 (trn) ]
86      !!         (trn) = (tra) ; (tra) = (0,0)
87      !!
88      !!
89      !! ** Action  : - update trb, trn
90      !!----------------------------------------------------------------------
91      INTEGER, INTENT( in ) ::   kt     ! ocean time-step index
92      !
93      INTEGER  ::   ji,jj,jk, jn   ! dummy loop indices
94      REAL(wp) ::   zfact            ! temporary scalar
95      CHARACTER (len=22) :: charout
96      REAL(wp), POINTER, DIMENSION(:,:,:,:) ::  ztrdt 
97      !!----------------------------------------------------------------------
98      !
99      IF( nn_timing == 1 )  CALL timing_start('trc_nxt')
100      !
101      IF( kt == nittrc000 .AND. lwp ) THEN
102         WRITE(numout,*)
103         WRITE(numout,*) 'trc_nxt : time stepping on passive tracers'
104      ENDIF
105
106#if defined key_agrif
107      CALL Agrif_trc                   ! AGRIF zoom boundaries
108#endif
109      ! Update after tracer on domain lateral boundaries
110      DO jn = 1, jptra
111         CALL lbc_lnk( tra(:,:,:,jn), 'T', 1. )   
112      END DO
113
114
115#if defined key_bdy
116!!      CALL bdy_trc( kt )               ! BDY open boundaries
117#endif
118
119
120      ! set time step size (Euler/Leapfrog)
121      IF( neuler == 0 .AND. kt ==  nittrc000 ) THEN  ;  r2dt(:) =     rdttrc(:)   ! at nittrc000             (Euler)
122      ELSEIF( kt <= nittrc000 + nn_dttrc )     THEN  ;  r2dt(:) = 2.* rdttrc(:)   ! at nit000 or nit000+1 (Leapfrog)
123      ENDIF
124
125      ! trends computation initialisation
126      IF( l_trdtrc )  THEN
127         CALL wrk_alloc( jpi, jpj, jpk, jptra, ztrdt )  !* store now fields before applying the Asselin filter
128         ztrdt(:,:,:,:)  = trn(:,:,:,:)
129      ENDIF
130      ! Leap-Frog + Asselin filter time stepping
131      IF( neuler == 0 .AND. kt == nittrc000 ) THEN        ! Euler time-stepping at first time-step
132         !                                                ! (only swap)
133         DO jn = 1, jptra
134            DO jk = 1, jpkm1
135               trn(:,:,jk,jn) = tra(:,:,jk,jn)
136            END DO
137         END DO
138         !                                             
139      ELSE
140         ! Leap-Frog + Asselin filter time stepping
141         IF( lk_vvl ) THEN   
142
143            IF( ln_crs_top )THEN
144               CALL tra_nxt_vvl_crs( kt, nittrc000, rdttrc, 'TRC', trb, trn, tra,      &
145              &                                              sbc_trc, sbc_trc_b, jptra )      ! variable volume level (vvl)
146            ELSE
147               CALL tra_nxt_vvl( kt, nittrc000, rdttrc, 'TRC', trb, trn, tra,      &
148              &                                          sbc_trc, sbc_trc_b, jptra )      ! variable volume level (vvl)
149            ENDIF
150         ELSE                   ;   CALL tra_nxt_fix( kt, nittrc000,         'TRC', trb, trn, tra, jptra )      ! fixed    volume level
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#else
177   !!----------------------------------------------------------------------
178   !!   Default option                                         Empty module
179   !!----------------------------------------------------------------------
180CONTAINS
181   SUBROUTINE trc_nxt( kt ) 
182      INTEGER, INTENT(in) :: kt
183      WRITE(*,*) 'trc_nxt: You should not have seen this print! error?', kt
184   END SUBROUTINE trc_nxt
185#endif
186   !!======================================================================
187END MODULE trcnxt
Note: See TracBrowser for help on using the repository browser.