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 @ 2610

Last change on this file since 2610 was 2610, checked in by trackstand2, 13 years ago

Changes to keep Pathscale compiler happy

  • Property svn:keywords set to Id
File size: 7.8 KB
Line 
1MODULE trcnxt
2   !!======================================================================
3   !!                       ***  MODULE  trcnxt  ***
4   !! Ocean passive tracers:  time stepping on passives tracers
5   !!======================================================================
6   !!======================================================================
7   !! History :  7.0  !  1991-11  (G. Madec)  Original code
8   !!                 !  1993-03  (M. Guyon)  symetrical conditions
9   !!                 !  1995-02  (M. Levy)   passive tracers
10   !!                 !  1996-02  (G. Madec & M. Imbard)  opa release 8.0
11   !!            8.0  !  1996-04  (A. Weaver)  Euler forward step
12   !!            8.2  !  1999-02  (G. Madec, N. Grima)  semi-implicit pressure grad.
13   !!  NEMO      1.0  !  2002-08  (G. Madec)  F90: Free form and module
14   !!                 !  2002-08  (G. Madec)  F90: Free form and module
15   !!                 !  2002-11  (C. Talandier, A-M Treguier) Open boundaries
16   !!                 !  2004-03  (C. Ethe) passive tracers
17   !!                 !  2007-02  (C. Deltel) Diagnose ML trends for passive tracers
18   !!            2.0  !  2006-02  (L. Debreu, C. Mazauric) Agrif implementation
19   !!            3.0  !  2008-06  (G. Madec)  time stepping always done in trazdf
20   !!            3.1  !  2009-02  (G. Madec, R. Benshila)  re-introduce the vvl option
21   !!            3.3  !  2010-06  (C. Ethe, G. Madec) Merge TRA-TRC
22   !!----------------------------------------------------------------------
23#if defined key_top
24   !!----------------------------------------------------------------------
25   !!   'key_top'                                                TOP models
26   !!----------------------------------------------------------------------
27   !!   trc_nxt     : time stepping on passive tracers
28   !!----------------------------------------------------------------------
29   !! * Modules used
30   USE oce_trc         ! ocean dynamics and tracers variables
31   USE trc             ! ocean passive tracers variables
32   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
33   USE prtctl_trc      ! Print control for debbuging
34   USE trdmod_oce
35   USE trdtra
36   USE tranxt
37# if defined key_agrif
38   USE agrif_top_update
39   USE agrif_top_interp
40# endif
41
42   IMPLICIT NONE
43   PRIVATE
44
45   !! * Routine accessibility
46   PUBLIC trc_nxt          ! routine called by step.F90
47   PUBLIC trc_nxt_alloc    ! routine called by nemogcm.F90
48
49   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:) ::   r2dt
50   !!----------------------------------------------------------------------
51   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
52   !! $Id$
53   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
54   !!----------------------------------------------------------------------
55
56CONTAINS
57
58   FUNCTION trc_nxt_alloc()
59      !!----------------------------------------------------------------------
60      !!                   ***  ROUTINE trc_nxt_alloc  ***
61      !!----------------------------------------------------------------------
62      INTEGER :: trc_nxt_alloc
63      !!----------------------------------------------------------------------
64
65      ALLOCATE( r2dt(jpk), Stat=trc_nxt_alloc)
66
67      IF(trc_nxt_alloc /= 0)THEN
68         CALL ctl_warn('trc_nxt_alloc : failed to allocate array.')
69      ENDIF
70
71   END FUNCTION trc_nxt_alloc
72
73
74   SUBROUTINE trc_nxt( kt )
75      !!----------------------------------------------------------------------
76      !!                   ***  ROUTINE trcnxt  ***
77      !!
78      !! ** Purpose :   Compute the passive tracers fields at the
79      !!      next time-step from their temporal trends and swap the fields.
80      !!
81      !! ** Method  :   Apply lateral boundary conditions on (ua,va) through
82      !!      call to lbc_lnk routine
83      !!   default:
84      !!      arrays swap
85      !!         (trn) = (tra) ; (tra) = (0,0)
86      !!         (trb) = (trn)
87      !!
88      !!   For Arakawa or TVD Scheme :
89      !!      A Asselin time filter applied on now tracers (trn) to avoid
90      !!      the divergence of two consecutive time-steps and tr arrays
91      !!      to prepare the next time_step:
92      !!         (trb) = (trn) + atfp [ (trb) + (tra) - 2 (trn) ]
93      !!         (trn) = (tra) ; (tra) = (0,0)
94      !!
95      !!
96      !! ** Action  : - update trb, trn
97      !!----------------------------------------------------------------------
98      !! * Arguments
99      INTEGER, INTENT( in ) ::   kt     ! ocean time-step index
100      !! * Local declarations
101      INTEGER  ::   jk, jn   ! dummy loop indices
102      REAL(wp) ::   zfact            ! temporary scalar
103      CHARACTER (len=22) :: charout
104      REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE ::  ztrdt 
105      !!----------------------------------------------------------------------
106
107      IF( kt == nit000 .AND. lwp ) THEN
108         WRITE(numout,*)
109         WRITE(numout,*) 'trc_nxt : time stepping on passive tracers'
110      ENDIF
111
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_obc
119!!      CALL obc_trc( kt )               ! OBC open boundaries
120#endif
121#if defined key_bdy
122!!      CALL bdy_trc( kt )               ! BDY open boundaries
123#endif
124#if defined key_agrif
125      CALL Agrif_trc                   ! AGRIF zoom boundaries
126#endif
127
128
129      ! set time step size (Euler/Leapfrog)
130      IF( neuler == 0 .AND. kt ==  nit000) THEN  ;  r2dt(:) =     rdttrc(:)   ! at nit000             (Euler)
131      ELSEIF( kt <= nit000 + 1 )           THEN  ;  r2dt(:) = 2.* rdttrc(:)   ! at nit000 or nit000+1 (Leapfrog)
132      ENDIF
133
134      ! trends computation initialisation
135      IF( l_trdtrc )  THEN
136         ALLOCATE( ztrdt(jpi,jpj,jpk,jptra) )  !* store now fields before applying the Asselin filter
137         ztrdt(:,:,:,:)  = trn(:,:,:,:)
138      ENDIF
139      ! Leap-Frog + Asselin filter time stepping
140      IF( neuler == 0 .AND. kt == nit000 ) THEN        ! Euler time-stepping at first time-step
141         !                                             ! (only swap)
142         DO jn = 1, jptra
143            DO jk = 1, jpkm1
144               trn(:,:,jk,jn) = tra(:,:,jk,jn)
145            END DO
146         END DO
147         !                                             
148      ELSE
149         ! Leap-Frog + Asselin filter time stepping
150         IF( lk_vvl ) THEN   ;   CALL tra_nxt_vvl( kt, 'TRC', trb, trn, tra, jptra )      ! variable volume level (vvl)
151         ELSE                ;   CALL tra_nxt_fix( kt, 'TRC', trb, trn, tra, jptra )      ! fixed    volume level
152         ENDIF
153      ENDIF
154
155#if defined key_agrif
156      ! Update tracer at AGRIF zoom boundaries
157      IF( .NOT.Agrif_Root() )    CALL Agrif_Update_Trc( kt )      ! children only
158#endif     
159
160      ! trends computation
161      IF( l_trdtrc ) THEN                                      ! trends
162         DO jn = 1, jptra
163            DO jk = 1, jpkm1
164               zfact = 1.e0 / r2dt(jk) 
165               ztrdt(:,:,jk,jn) = ( trb(:,:,jk,jn) - ztrdt(:,:,jk,jn) ) * zfact 
166               CALL trd_tra( kt, 'TRC', jn, jptra_trd_atf, ztrdt )
167            END DO
168         END DO
169         DEALLOCATE( ztrdt )
170      END IF
171      !
172      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
173         WRITE(charout, FMT="('nxt')")
174         CALL prt_ctl_trc_info(charout)
175         CALL prt_ctl_trc(tab4d=trn, mask=tmask, clinfo=ctrcnm)
176      ENDIF
177      !
178   END SUBROUTINE trc_nxt
179
180#else
181   !!----------------------------------------------------------------------
182   !!   Default option                                         Empty module
183   !!----------------------------------------------------------------------
184CONTAINS
185   SUBROUTINE trc_nxt( kt ) 
186      INTEGER, INTENT(in) :: kt
187      WRITE(*,*) 'trc_nxt: You should not have seen this print! error?', kt
188   END SUBROUTINE trc_nxt
189#endif
190   !!======================================================================
191END MODULE trcnxt
Note: See TracBrowser for help on using the repository browser.