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

source: branches/2012/dev_r3309_LOCEAN12_Ediag/NEMOGCM/NEMO/TOP_SRC/TRP/trcnxt.F90 @ 3318

Last change on this file since 3318 was 3318, checked in by gm, 12 years ago

Ediag branche: #927 split TRA/DYN trd computation

  • 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   !! 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         ! trends: ocean variables
33   USE trdtra          ! trends: tracer manager
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      ALLOCATE( r2dt(jpk), STAT=trc_nxt_alloc )
60      !
61      IF( trc_nxt_alloc /= 0 )   CALL ctl_warn('trc_nxt_alloc : failed to allocate array')
62      !
63   END FUNCTION trc_nxt_alloc
64
65
66   SUBROUTINE trc_nxt( kt )
67      !!----------------------------------------------------------------------
68      !!                   ***  ROUTINE trcnxt  ***
69      !!
70      !! ** Purpose :   Compute the passive tracers fields at the
71      !!      next time-step from their temporal trends and swap the fields.
72      !!
73      !! ** Method  :   Apply lateral boundary conditions on (ua,va) through
74      !!      call to lbc_lnk routine
75      !!   default:
76      !!      arrays swap
77      !!         (trn) = (tra) ; (tra) = (0,0)
78      !!         (trb) = (trn)
79      !!
80      !!   For Arakawa or TVD Scheme :
81      !!      A Asselin time filter applied on now tracers (trn) to avoid
82      !!      the divergence of two consecutive time-steps and tr arrays
83      !!      to prepare the next time_step:
84      !!         (trb) = (trn) + atfp [ (trb) + (tra) - 2 (trn) ]
85      !!         (trn) = (tra) ; (tra) = (0,0)
86      !!
87      !!
88      !! ** Action  : - update trb, trn
89      !!----------------------------------------------------------------------
90      INTEGER, INTENT( in ) ::   kt     ! ocean time-step index
91      !
92      INTEGER  ::   jk, jn   ! dummy loop indices
93      REAL(wp) ::   zfact            ! temporary scalar
94      CHARACTER (len=22) :: charout
95      REAL(wp), POINTER, DIMENSION(:,:,:,:) ::  ztrdt 
96      !!----------------------------------------------------------------------
97      !
98      IF( nn_timing == 1 )  CALL timing_start('trc_nxt')
99      !
100      IF( kt == nittrc000 .AND. lwp ) THEN
101         WRITE(numout,*)
102         WRITE(numout,*) 'trc_nxt : time stepping on passive tracers'
103      ENDIF
104
105      ! Update after tracer on domain lateral boundaries
106      DO jn = 1, jptra
107         CALL lbc_lnk( tra(:,:,:,jn), 'T', 1. )   
108      END DO
109
110
111#if defined key_obc
112!!      CALL obc_trc( kt )               ! OBC open boundaries
113#endif
114#if defined key_bdy
115!!      CALL bdy_trc( kt )               ! BDY open boundaries
116#endif
117#if defined key_agrif
118      CALL Agrif_trc                   ! AGRIF zoom boundaries
119#endif
120
121
122      ! set time step size (Euler/Leapfrog)
123      IF( neuler == 0 .AND. kt ==  nittrc000 ) THEN  ;  r2dt(:) =     rdttrc(:)   ! at nittrc000             (Euler)
124      ELSEIF( kt <= nittrc000 + 1 )            THEN  ;  r2dt(:) = 2.* rdttrc(:)   ! at nit000 or nit000+1 (Leapfrog)
125      ENDIF
126
127      ! trends computation initialisation
128      IF( l_trdtrc )  THEN
129         CALL wrk_alloc( jpi, jpj, jpk, jptra, ztrdt )  !* store now fields before applying the Asselin filter
130         ztrdt(:,:,:,:)  = trn(:,:,:,:)
131      ENDIF
132      ! Leap-Frog + Asselin filter time stepping
133      IF( neuler == 0 .AND. kt == nittrc000 ) THEN        ! Euler time-stepping at first time-step
134         !                                                ! (only swap)
135         DO jn = 1, jptra
136            DO jk = 1, jpkm1
137               trn(:,:,jk,jn) = tra(:,:,jk,jn)
138            END DO
139         END DO
140         !                                             
141      ELSE
142         ! Leap-Frog + Asselin filter time stepping
143         IF( lk_vvl ) THEN   ;   CALL tra_nxt_vvl( kt, nittrc000, 'TRC', trb, trn, tra, jptra )      ! variable volume level (vvl)
144         ELSE                ;   CALL tra_nxt_fix( kt, nittrc000, 'TRC', trb, trn, tra, jptra )      ! fixed    volume level
145         ENDIF
146      ENDIF
147
148#if defined key_agrif
149      ! Update tracer at AGRIF zoom boundaries
150      IF( .NOT.Agrif_Root() )    CALL Agrif_Update_Trc( kt )      ! children only
151#endif     
152
153      ! trends computation
154      IF( l_trdtrc ) THEN                                      ! trends
155         DO jn = 1, jptra
156            DO jk = 1, jpkm1
157               zfact = 1.e0 / r2dt(jk) 
158               ztrdt(:,:,jk,jn) = ( trb(:,:,jk,jn) - ztrdt(:,:,jk,jn) ) * zfact 
159               CALL trd_tra( kt, 'TRC', jn, jptra_atf, ztrdt )
160            END DO
161         END DO
162         CALL wrk_dealloc( jpi, jpj, jpk, jptra, ztrdt ) 
163      END IF
164      !
165      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
166         WRITE(charout, FMT="('nxt')")
167         CALL prt_ctl_trc_info(charout)
168         CALL prt_ctl_trc(tab4d=trn, mask=tmask, clinfo=ctrcnm)
169      ENDIF
170      !
171      IF( nn_timing == 1 )  CALL timing_stop('trc_nxt')
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.