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

source: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trcnxt.F90 @ 2636

Last change on this file since 2636 was 2636, checked in by gm, 13 years ago

dynamic mem: #785 ; move ctl_stop & warn in lib_mpp to avoid a circular dependency + ctl_stop improvment

  • Property svn:keywords set to Id
File size: 7.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 trdmod_oce
33   USE trdtra
34   USE tranxt
35# if defined key_agrif
36   USE agrif_top_update
37   USE agrif_top_interp
38# endif
39
40   IMPLICIT NONE
41   PRIVATE
42
43   PUBLIC   trc_nxt          ! routine called by step.F90
44   PUBLIC   trc_nxt_alloc    ! routine called by nemogcm.F90
45
46   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:) ::   r2dt
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   INTEGER FUNCTION trc_nxt_alloc()
56      !!----------------------------------------------------------------------
57      !!                   ***  ROUTINE trc_nxt_alloc  ***
58      !!----------------------------------------------------------------------
59      USE lib_mpp, ONLY: ctl_warn
60      !!----------------------------------------------------------------------
61      !
62      ALLOCATE( r2dt(jpk), Stat=trc_nxt_alloc)
63      !
64      IF( trc_nxt_alloc /= 0 )   CALL ctl_warn('trc_nxt_alloc : failed to allocate array')
65      !
66   END FUNCTION trc_nxt_alloc
67
68
69   SUBROUTINE trc_nxt( kt )
70      !!----------------------------------------------------------------------
71      !!                   ***  ROUTINE trcnxt  ***
72      !!
73      !! ** Purpose :   Compute the passive tracers fields at the
74      !!      next time-step from their temporal trends and swap the fields.
75      !!
76      !! ** Method  :   Apply lateral boundary conditions on (ua,va) through
77      !!      call to lbc_lnk routine
78      !!   default:
79      !!      arrays swap
80      !!         (trn) = (tra) ; (tra) = (0,0)
81      !!         (trb) = (trn)
82      !!
83      !!   For Arakawa or TVD Scheme :
84      !!      A Asselin time filter applied on now tracers (trn) to avoid
85      !!      the divergence of two consecutive time-steps and tr arrays
86      !!      to prepare the next time_step:
87      !!         (trb) = (trn) + atfp [ (trb) + (tra) - 2 (trn) ]
88      !!         (trn) = (tra) ; (tra) = (0,0)
89      !!
90      !!
91      !! ** Action  : - update trb, trn
92      !!----------------------------------------------------------------------
93      !! * Arguments
94      INTEGER, INTENT( in ) ::   kt     ! ocean time-step index
95      !! * Local declarations
96      INTEGER  ::   jk, jn   ! dummy loop indices
97      REAL(wp) ::   zfact            ! temporary scalar
98      CHARACTER (len=22) :: charout
99      REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE ::  ztrdt 
100      !!----------------------------------------------------------------------
101
102      IF( kt == nit000 .AND. lwp ) THEN
103         WRITE(numout,*)
104         WRITE(numout,*) 'trc_nxt : time stepping on passive tracers'
105      ENDIF
106
107      ! Update after tracer on domain lateral boundaries
108      DO jn = 1, jptra
109         CALL lbc_lnk( tra(:,:,:,jn), 'T', 1. )   
110      END DO
111
112
113#if defined key_obc
114!!      CALL obc_trc( kt )               ! OBC open boundaries
115#endif
116#if defined key_bdy
117!!      CALL bdy_trc( kt )               ! BDY open boundaries
118#endif
119#if defined key_agrif
120      CALL Agrif_trc                   ! AGRIF zoom boundaries
121#endif
122
123
124      ! set time step size (Euler/Leapfrog)
125      IF( neuler == 0 .AND. kt ==  nit000) THEN  ;  r2dt(:) =     rdttrc(:)   ! at nit000             (Euler)
126      ELSEIF( kt <= nit000 + 1 )           THEN  ;  r2dt(:) = 2.* rdttrc(:)   ! at nit000 or nit000+1 (Leapfrog)
127      ENDIF
128
129      ! trends computation initialisation
130      IF( l_trdtrc )  THEN
131         ALLOCATE( ztrdt(jpi,jpj,jpk,jptra) )  !* store now fields before applying the Asselin filter
132         ztrdt(:,:,:,:)  = trn(:,:,:,:)
133      ENDIF
134      ! Leap-Frog + Asselin filter time stepping
135      IF( neuler == 0 .AND. kt == nit000 ) THEN        ! Euler time-stepping at first time-step
136         !                                             ! (only swap)
137         DO jn = 1, jptra
138            DO jk = 1, jpkm1
139               trn(:,:,jk,jn) = tra(:,:,jk,jn)
140            END DO
141         END DO
142         !                                             
143      ELSE
144         ! Leap-Frog + Asselin filter time stepping
145         IF( lk_vvl ) THEN   ;   CALL tra_nxt_vvl( kt, 'TRC', trb, trn, tra, jptra )      ! variable volume level (vvl)
146         ELSE                ;   CALL tra_nxt_fix( kt, 'TRC', trb, trn, tra, jptra )      ! fixed    volume level
147         ENDIF
148      ENDIF
149
150#if defined key_agrif
151      ! Update tracer at AGRIF zoom boundaries
152      IF( .NOT.Agrif_Root() )    CALL Agrif_Update_Trc( kt )      ! children only
153#endif     
154
155      ! trends computation
156      IF( l_trdtrc ) THEN                                      ! trends
157         DO jn = 1, jptra
158            DO jk = 1, jpkm1
159               zfact = 1.e0 / r2dt(jk) 
160               ztrdt(:,:,jk,jn) = ( trb(:,:,jk,jn) - ztrdt(:,:,jk,jn) ) * zfact 
161               CALL trd_tra( kt, 'TRC', jn, jptra_trd_atf, ztrdt )
162            END DO
163         END DO
164         DEALLOCATE( ztrdt )
165      END IF
166      !
167      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
168         WRITE(charout, FMT="('nxt')")
169         CALL prt_ctl_trc_info(charout)
170         CALL prt_ctl_trc(tab4d=trn, mask=tmask, clinfo=ctrcnm)
171      ENDIF
172      !
173   END SUBROUTINE trc_nxt
174
175#else
176   !!----------------------------------------------------------------------
177   !!   Default option                                         Empty module
178   !!----------------------------------------------------------------------
179CONTAINS
180   SUBROUTINE trc_nxt( kt ) 
181      INTEGER, INTENT(in) :: kt
182      WRITE(*,*) 'trc_nxt: You should not have seen this print! error?', kt
183   END SUBROUTINE trc_nxt
184#endif
185   !!======================================================================
186END MODULE trcnxt
Note: See TracBrowser for help on using the repository browser.