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

source: branches/UKMO/r6232_collate_bgc_diagnostics/NEMOGCM/NEMO/TOP_SRC/TRP/trcnxt.F90 @ 11134

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

Full set of changes as in the original branch

File size: 9.7 KB
RevLine 
[941]1MODULE trcnxt
2   !!======================================================================
3   !!                       ***  MODULE  trcnxt  ***
4   !! Ocean passive tracers:  time stepping on passives tracers
5   !!======================================================================
[2528]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
[1175]21   !!----------------------------------------------------------------------
[941]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
[2528]29   USE trc             ! ocean passive tracers variables
[941]30   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
31   USE prtctl_trc      ! Print control for debbuging
[4990]32   USE trd_oce
[2528]33   USE trdtra
34   USE tranxt
[11134]35   USE trcbdy          ! BDY open boundaries
36   USE bdy_par, only: lk_bdy
37   USE iom
[2528]38# if defined key_agrif
[941]39   USE agrif_top_interp
[2528]40# endif
[941]41
42   IMPLICIT NONE
43   PRIVATE
44
[2715]45   PUBLIC   trc_nxt          ! routine called by step.F90
46   PUBLIC   trc_nxt_alloc    ! routine called by nemogcm.F90
[2528]47
[2715]48   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:) ::   r2dt
49
[941]50   !!----------------------------------------------------------------------
[2528]51   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
[11132]52   !! $Id$
[2715]53   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
[941]54   !!----------------------------------------------------------------------
55CONTAINS
56
[2715]57   INTEGER FUNCTION trc_nxt_alloc()
58      !!----------------------------------------------------------------------
59      !!                   ***  ROUTINE trc_nxt_alloc  ***
60      !!----------------------------------------------------------------------
61      ALLOCATE( r2dt(jpk), STAT=trc_nxt_alloc )
62      !
63      IF( trc_nxt_alloc /= 0 )   CALL ctl_warn('trc_nxt_alloc : failed to allocate array')
64      !
65   END FUNCTION trc_nxt_alloc
66
67
[941]68   SUBROUTINE trc_nxt( kt )
69      !!----------------------------------------------------------------------
70      !!                   ***  ROUTINE trcnxt  ***
71      !!
72      !! ** Purpose :   Compute the passive tracers fields at the
73      !!      next time-step from their temporal trends and swap the fields.
74      !!
75      !! ** Method  :   Apply lateral boundary conditions on (ua,va) through
76      !!      call to lbc_lnk routine
77      !!   default:
78      !!      arrays swap
79      !!         (trn) = (tra) ; (tra) = (0,0)
80      !!         (trb) = (trn)
81      !!
82      !!   For Arakawa or TVD Scheme :
83      !!      A Asselin time filter applied on now tracers (trn) to avoid
84      !!      the divergence of two consecutive time-steps and tr arrays
85      !!      to prepare the next time_step:
86      !!         (trb) = (trn) + atfp [ (trb) + (tra) - 2 (trn) ]
87      !!         (trn) = (tra) ; (tra) = (0,0)
88      !!
89      !!
90      !! ** Action  : - update trb, trn
91      !!----------------------------------------------------------------------
[1271]92      INTEGER, INTENT( in ) ::   kt     ! ocean time-step index
[2715]93      !
[2528]94      INTEGER  ::   jk, jn   ! dummy loop indices
[941]95      REAL(wp) ::   zfact            ! temporary scalar
96      CHARACTER (len=22) :: charout
[3294]97      REAL(wp), POINTER, DIMENSION(:,:,:,:) ::  ztrdt 
[11134]98#if defined key_tracer_budget
99      REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) ::  ztrdt_m1 ! slwa
100#endif
[941]101      !!----------------------------------------------------------------------
[3294]102      !
103      IF( nn_timing == 1 )  CALL timing_start('trc_nxt')
104      !
105      IF( kt == nittrc000 .AND. lwp ) THEN
[941]106         WRITE(numout,*)
107         WRITE(numout,*) 'trc_nxt : time stepping on passive tracers'
108      ENDIF
[11134]109#if defined key_tracer_budget
110      IF( kt == nittrc000 .AND. l_trdtrc ) THEN
111         ALLOCATE( ztrdt_m1(jpi,jpj,jpk,jptra) )  ! slwa
112         IF( ln_rsttr .AND.    &                     ! Restart: read in restart  file
113            iom_varid( numrtr, 'atf_trend_'//TRIM(ctrcnm(1)), ldstop = .FALSE. ) > 0 ) THEN
114            IF(lwp) WRITE(numout,*) '          nittrc000-nn_dttrc ATF tracer trend read in the restart file'
115            DO jn = 1, jptra
116               CALL iom_get( numrtr, jpdom_autoglo, 'atf_trend_'//TRIM(ctrcnm(jn)), ztrdt_m1(:,:,:,jn) )   ! before tracer trend for atf
117            END DO
118         ELSE         
119           ztrdt_m1=0.0
120         ENDIF
121      ENDIF
122#endif
[941]123
[11134]124
[6204]125#if defined key_agrif
126      CALL Agrif_trc                   ! AGRIF zoom boundaries
127#endif
[2528]128      ! Update after tracer on domain lateral boundaries
[941]129      DO jn = 1, jptra
130         CALL lbc_lnk( tra(:,:,:,jn), 'T', 1. )   
[2528]131      END DO
[941]132
133
[11134]134      IF( lk_bdy )  CALL trc_bdy( kt )               ! BDY open boundaries
[2528]135#if defined key_bdy
136!!      CALL bdy_trc( kt )               ! BDY open boundaries
137#endif
[941]138
[2528]139      ! set time step size (Euler/Leapfrog)
[3294]140      IF( neuler == 0 .AND. kt ==  nittrc000 ) THEN  ;  r2dt(:) =     rdttrc(:)   ! at nittrc000             (Euler)
[5385]141      ELSEIF( kt <= nittrc000 + nn_dttrc )     THEN  ;  r2dt(:) = 2.* rdttrc(:)   ! at nit000 or nit000+1 (Leapfrog)
[2528]142      ENDIF
[941]143
[2528]144      ! trends computation initialisation
145      IF( l_trdtrc )  THEN
[3294]146         CALL wrk_alloc( jpi, jpj, jpk, jptra, ztrdt )  !* store now fields before applying the Asselin filter
[2528]147         ztrdt(:,:,:,:)  = trn(:,:,:,:)
148      ENDIF
149      ! Leap-Frog + Asselin filter time stepping
[3294]150      IF( neuler == 0 .AND. kt == nittrc000 ) THEN        ! Euler time-stepping at first time-step
151         !                                                ! (only swap)
[2528]152         DO jn = 1, jptra
153            DO jk = 1, jpkm1
154               trn(:,:,jk,jn) = tra(:,:,jk,jn)
155            END DO
156         END DO
157         !                                             
158      ELSE
159         ! Leap-Frog + Asselin filter time stepping
[5385]160         IF( lk_vvl ) THEN   ;   CALL tra_nxt_vvl( kt, nittrc000, rdttrc, 'TRC', trb, trn, tra,      &
161           &                                                                sbc_trc, sbc_trc_b, jptra )      ! variable volume level (vvl)
162         ELSE                ;   CALL tra_nxt_fix( kt, nittrc000,         'TRC', trb, trn, tra, jptra )      ! fixed    volume level
[2528]163         ENDIF
164      ENDIF
[1175]165
[2528]166      ! trends computation
167      IF( l_trdtrc ) THEN                                      ! trends
168         DO jn = 1, jptra
169            DO jk = 1, jpkm1
170               zfact = 1.e0 / r2dt(jk) 
171               ztrdt(:,:,jk,jn) = ( trb(:,:,jk,jn) - ztrdt(:,:,jk,jn) ) * zfact 
[11134]172!slwa          CALL trd_tra( kt, 'TRC', jn, jptra_atf, ztrdt )
173#if defined key_tracer_budget
174               ztrdt(:,:,jk,jn) = ztrdt(:,:,jk,jn) * e1t(:,:) * e2t(:,:) * e3t_n(:,:,jk)  ! slwa vvl
175               !ztrdt(:,:,jk,jn) = ztrdt(:,:,jk,jn) * e1t(:,:) * e2t(:,:) * e3t_0(:,:,jk)  ! slwa CHANGE for vvl
176#endif
[1175]177            END DO
[11134]178#if defined key_tracer_budget
179! slwa budget code
180              CALL trd_tra( kt, 'TRC', jn, jptra_atf, ztrdt_m1(:,:,:,jn) )
181#else
182              CALL trd_tra( kt, 'TRC', jn, jptra_atf, ztrdt(:,:,:,jn) )
183#endif
[2528]184         END DO
[11134]185#if defined key_tracer_budget
186        ztrdt_m1(:,:,:,:) = ztrdt(:,:,:,:)    ! need previous time step for budget slwa
187#endif
[3294]188         CALL wrk_dealloc( jpi, jpj, jpk, jptra, ztrdt ) 
[2528]189      END IF
[11134]190
191#if defined key_tracer_budget
192      !                                           Write in the tracer restart file
193      !                                          *******************************
194      IF( lrst_trc ) THEN
195         IF(lwp) WRITE(numout,*)
196         IF(lwp) WRITE(numout,*) 'trc : ATF trend at last time step for tracer budget written in tracer restart file ',   &
197            &                    'at it= ', kt,' date= ', ndastp
198         IF(lwp) WRITE(numout,*) '~~~~'
199         DO jn = 1, jptra
200            CALL iom_rstput( kt, nitrst, numrtw, 'atf_trend_'//TRIM(ctrcnm(jn)), ztrdt_m1(:,:,:,jn) )
201         END DO
202      ENDIF
203#endif
204
[2528]205      !
[941]206      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
207         WRITE(charout, FMT="('nxt')")
208         CALL prt_ctl_trc_info(charout)
209         CALL prt_ctl_trc(tab4d=trn, mask=tmask, clinfo=ctrcnm)
210      ENDIF
[2528]211      !
[3294]212      IF( nn_timing == 1 )  CALL timing_stop('trc_nxt')
213      !
[941]214   END SUBROUTINE trc_nxt
215
216#else
217   !!----------------------------------------------------------------------
218   !!   Default option                                         Empty module
219   !!----------------------------------------------------------------------
220CONTAINS
221   SUBROUTINE trc_nxt( kt ) 
222      INTEGER, INTENT(in) :: kt
223      WRITE(*,*) 'trc_nxt: You should not have seen this print! error?', kt
224   END SUBROUTINE trc_nxt
225#endif
226   !!======================================================================
227END MODULE trcnxt
Note: See TracBrowser for help on using the repository browser.