Index: NEMO/branches/2019/dev_r10721_KERNEL-02_Storkey_Coward_IMMERSE_first_steps/src/TOP/trcstp.F90
===================================================================
--- NEMO/branches/2019/dev_r10721_KERNEL-02_Storkey_Coward_IMMERSE_first_steps/src/TOP/trcstp.F90	(revision 11506)
+++ NEMO/branches/2019/dev_r10721_KERNEL-02_Storkey_Coward_IMMERSE_first_steps/src/TOP/trcstp.F90	(revision 11527)
@@ -38,9 +38,4 @@
 
    !!----------------------------------------------------------------------
-   !! time level indices
-   !!----------------------------------------------------------------------
-   INTEGER, PUBLIC :: Nbb_trc, Nnn_trc, Naa_trc, Nrhs_trc      !! used by trc_init
-
-   !!----------------------------------------------------------------------
    !! NEMO/TOP 4.0 , NEMO Consortium (2018)
    !! $Id$ 
@@ -49,5 +44,5 @@
 CONTAINS
 
-   SUBROUTINE trc_stp( kt, Kbb_oce, Kmm_oce, Krhs_oce, Kaa_oce )
+   SUBROUTINE trc_stp( kt, Kbb, Kmm, Krhs, Kaa )
       !!-------------------------------------------------------------------
       !!                     ***  ROUTINE trc_stp  ***
@@ -59,5 +54,5 @@
       !!-------------------------------------------------------------------
       INTEGER, INTENT( in ) :: kt                  ! ocean time-step index
-      INTEGER, INTENT( in ) :: Kbb_oce, Kmm_oce, Krhs_oce, Kaa_oce ! time level indices
+      INTEGER, INTENT( in ) :: Kbb, Kmm, Krhs, Kaa ! time level indices
       !
       INTEGER ::   jk, jn   ! dummy loop indices
@@ -81,5 +76,5 @@
       IF( .NOT.ln_linssh ) THEN                                           ! update ocean volume due to ssh temporal evolution
          DO jk = 1, jpk
-            cvol(:,:,jk) = e1e2t(:,:) * e3t(:,:,jk,Kmm_oce) * tmask(:,:,jk)
+            cvol(:,:,jk) = e1e2t(:,:) * e3t(:,:,jk,Kmm) * tmask(:,:,jk)
          END DO
          IF ( ln_ctl .OR. kt == nitrst .OR. ( ln_check_mass .AND. kt == nitend )              &
@@ -91,10 +86,4 @@
       IF( l_trcdm2dc )   CALL trc_mean_qsr( kt )
       !    
-      IF( Kmm_oce /= Nnn_trc .OR. Kaa_oce /= Naa_trc .OR. Krhs_oce /= Nrhs_trc ) THEN
-         ! The OCE and TRC time indices should be the same always. 
-         ! If this is not the case then something has gone wrong.
-         CALL ctl_stop( 'trc_stp : OCE and TRC time indices are different! Something has gone wrong.' )
-      ENDIF
-      !    
       !
       IF(ln_ctl) THEN
@@ -103,22 +92,28 @@
       ENDIF
       !
-      tr(:,:,:,:,Nrhs_trc) = 0.e0
-      !
-      CALL trc_rst_opn  ( kt )       ! Open tracer restart file 
-      IF( lrst_trc )            CALL trc_rst_cal  ( kt, 'WRITE' )   ! calendar
-      CALL trc_wri      ( kt,          Nnn_trc                    )  ! output of passive tracers with iom I/O manager
-      CALL trc_sms      ( kt, Nbb_trc, Nnn_trc, Nrhs_trc          )  ! tracers: sinks and sources
-      CALL trc_trp      ( kt, Nbb_trc, Nnn_trc, Nrhs_trc, Naa_trc )  ! transport of passive tracers
+      tr(:,:,:,:,Krhs) = 0._wp
+      !
+      CALL trc_rst_opn  ( kt )                            ! Open tracer restart file 
+      IF( lrst_trc )  CALL trc_rst_cal  ( kt, 'WRITE' )   ! calendar
+      CALL trc_wri      ( kt,      Kmm            )       ! output of passive tracers with iom I/O manager
+      CALL trc_sms      ( kt, Kbb, Kmm, Krhs      )       ! tracers: sinks and sources
+      CALL trc_trp      ( kt, Kbb, Kmm, Krhs, Kaa )       ! transport of passive tracers
+           !
+           ! Note passive tracers have been time-filtered in trc_trp but the time level
+           ! indices will not be swapped until after tra_atf/dyn_atf/ssh_atf in stp. Subsequent calls here
+           ! anticipate this update which will be: Nrhs= Nbb ; Nbb = Nnn ; Nnn = Naa ; Naa = Nrhs
+           ! and use the filtered levels explicitly.
+           !
       IF( kt == nittrc000 ) THEN
-         CALL iom_close( numrtr )       ! close input tracer restart file
-         IF(lwm) CALL FLUSH( numont )   ! flush namelist output
-      ENDIF
-      IF( lrst_trc )            CALL trc_rst_wri  ( kt, Nbb_trc, Nnn_trc, Nrhs_trc )       ! write tracer restart file
-      IF( lk_trdmxl_trc  )      CALL trd_mxl_trc  ( kt,          Nnn_trc           )       ! trends: Mixed-layer
+         CALL iom_close( numrtr )                         ! close input tracer restart file
+         IF(lwm) CALL FLUSH( numont )                     ! flush namelist output
+      ENDIF
+      IF( lrst_trc )            CALL trc_rst_wri  ( kt, Kmm, Kaa, Kbb  )       ! write tracer restart file
+      IF( lk_trdmxl_trc  )      CALL trd_mxl_trc  ( kt,      Kaa       )       ! trends: Mixed-layer
       !
       IF (ll_trcstat) THEN
          ztrai = 0._wp                                                   !  content of all tracers
          DO jn = 1, jptra
-            ztrai = ztrai + glob_sum( 'trcstp', tr(:,:,:,jn,Nnn_trc) * cvol(:,:,:)   )
+            ztrai = ztrai + glob_sum( 'trcstp', tr(:,:,:,jn,Kaa) * cvol(:,:,:)   )
          END DO
          IF( lwm ) WRITE(numstr,9300) kt,  ztrai / areatot
