Index: NEMO/branches/2019/dev_r11078_OSMOSIS_IMMERSE_Nurser/src/TOP/TRP/trcldf.F90
===================================================================
--- NEMO/branches/2019/dev_r11078_OSMOSIS_IMMERSE_Nurser/src/TOP/TRP/trcldf.F90	(revision 12178)
+++ NEMO/branches/2019/dev_r11078_OSMOSIS_IMMERSE_Nurser/src/TOP/TRP/trcldf.F90	(revision 12928)
@@ -43,5 +43,5 @@
    
    !! * Substitutions
-#  include "vectopt_loop_substitute.h90"
+#  include "do_loop_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 4.0 , NEMO Consortium (2018)
@@ -51,5 +51,5 @@
 CONTAINS
 
-   SUBROUTINE trc_ldf( kt )
+   SUBROUTINE trc_ldf( kt, Kbb, Kmm, ptr, Krhs )
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE tra_ldf  ***
@@ -58,11 +58,13 @@
       !!
       !!----------------------------------------------------------------------
-      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
+      INTEGER,                                    INTENT(in   ) :: kt              ! ocean time-step index
+      INTEGER,                                    INTENT(in   ) :: Kbb, Kmm, Krhs  ! ocean time-level index
+      REAL(wp), DIMENSION(jpi,jpj,jpk,jptra,jpt), INTENT(inout) :: ptr             ! passive tracers and RHS of tracer equation
       !
       INTEGER            :: ji, jj, jk, jn
       REAL(wp)           :: zdep
       CHARACTER (len=22) :: charout
-      REAL(wp), DIMENSION(jpi,jpj,jpk)   ::   zahu, zahv
-      REAL(wp), POINTER, DIMENSION(:,:,:,:) ::   ztrtrd
+      REAL(wp),          DIMENSION(jpi,jpj,jpk) ::   zahu, zahv
+      REAL(wp), POINTER, DIMENSION(:,:,:,:)     ::   ztrtrd
       !!----------------------------------------------------------------------
       !
@@ -73,5 +75,5 @@
       IF( l_trdtrc )  THEN
          ALLOCATE( ztrtrd(jpi,jpj,jpk,jptra) )
-         ztrtrd(:,:,:,:)  = tra(:,:,:,:)
+         ztrtrd(:,:,:,:)  = ptr(:,:,:,:,Krhs)
       ENDIF
       !                                  !* set the lateral diffusivity coef. for passive tracer      
@@ -79,39 +81,39 @@
       zahv(:,:,:) = rldf * ahtv(:,:,:)
       !                                  !* Enhanced zonal diffusivity coefficent in the equatorial domain
-      DO jk= 1, jpk
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               IF( gdept_n(ji,jj,jk) > 200. .AND. gphit(ji,jj) < 5. .AND. gphit(ji,jj) > -5. ) THEN
-                  zdep = MAX( gdept_n(ji,jj,jk) - 1000., 0. ) / 1000.
-                  zahu(ji,jj,jk) = zahu(ji,jj,jk) * MAX( 1., rn_fact_lap * EXP( -zdep ) )
-               ENDIF
-            END DO
-         END DO
-      END DO
+      DO_3D_11_11( 1, jpk )
+         IF( gdept(ji,jj,jk,Kmm) > 200. .AND. gphit(ji,jj) < 5. .AND. gphit(ji,jj) > -5. ) THEN
+            zdep = MAX( gdept(ji,jj,jk,Kmm) - 1000., 0. ) / 1000.
+            zahu(ji,jj,jk) = zahu(ji,jj,jk) * MAX( 1., rn_fact_lap * EXP( -zdep ) )
+         ENDIF
+      END_3D
       !
       SELECT CASE ( nldf_trc )                 !* compute lateral mixing trend and add it to the general trend
       !
-      CASE ( np_lap   )                               ! iso-level laplacian
-         CALL tra_ldf_lap  ( kt, nittrc000,'TRC', zahu, zahv, gtru, gtrv, gtrui, gtrvi, trb,      tra, jptra,    1     )
-      CASE ( np_lap_i )                               ! laplacian : standard iso-neutral operator (Madec)
-         CALL tra_ldf_iso  ( kt, nittrc000,'TRC', zahu, zahv, gtru, gtrv, gtrui, gtrvi, trb, trb, tra, jptra,    1     )
-      CASE ( np_lap_it )                              ! laplacian : triad iso-neutral operator (griffies)
-         CALL tra_ldf_triad( kt, nittrc000,'TRC', zahu, zahv, gtru, gtrv, gtrui, gtrvi, trb, trb, tra, jptra,    1     )
-      CASE ( np_blp , np_blp_i , np_blp_it )          ! bilaplacian: all operator (iso-level, -neutral)
-         CALL tra_ldf_blp  ( kt, nittrc000,'TRC', zahu, zahv, gtru, gtrv, gtrui, gtrvi, trb     , tra, jptra, nldf_trc )
+      CASE ( np_lap   )                                                                                    ! iso-level laplacian
+         CALL tra_ldf_lap  ( kt, Kmm, nittrc000,'TRC', zahu, zahv, gtru, gtrv, gtrui, gtrvi,            &
+           &                     ptr(:,:,:,:,Kbb), ptr(:,:,:,:,Krhs),                   jptra, 1 )
+      CASE ( np_lap_i )                                                                                    ! laplacian : standard iso-neutral operator (Madec)
+         CALL tra_ldf_iso  ( kt, Kmm, nittrc000,'TRC', zahu, zahv, gtru, gtrv, gtrui, gtrvi,            &
+           &                     ptr(:,:,:,:,Kbb), ptr(:,:,:,:,Kbb), ptr(:,:,:,:,Krhs), jptra, 1 )
+      CASE ( np_lap_it )                                                                                   ! laplacian : triad iso-neutral operator (griffies)
+         CALL tra_ldf_triad( kt, Kmm, nittrc000,'TRC', zahu, zahv, gtru, gtrv, gtrui, gtrvi,            &
+           &                     ptr(:,:,:,:,Kbb), ptr(:,:,:,:,Kbb), ptr(:,:,:,:,Krhs), jptra, 1 )
+      CASE ( np_blp , np_blp_i , np_blp_it )                                                               ! bilaplacian: all operator (iso-level, -neutral)
+         CALL tra_ldf_blp  ( kt, Kmm, nittrc000,'TRC', zahu, zahv, gtru, gtrv, gtrui, gtrvi,            &
+           &                     ptr(:,:,:,:,Kbb) , ptr(:,:,:,:,Krhs),                 jptra, nldf_trc )
       END SELECT
       !
       IF( l_trdtrc )   THEN                    ! send the trends for further diagnostics
         DO jn = 1, jptra
-           ztrtrd(:,:,:,jn) = tra(:,:,:,jn) - ztrtrd(:,:,:,jn)
-           CALL trd_tra( kt, 'TRC', jn, jptra_ldf, ztrtrd(:,:,:,jn) )
+           ztrtrd(:,:,:,jn) = ptr(:,:,:,jn,Krhs) - ztrtrd(:,:,:,jn)
+           CALL trd_tra( kt, Kmm, Krhs, 'TRC', jn, jptra_ldf, ztrtrd(:,:,:,jn) )
         END DO
         DEALLOCATE( ztrtrd )
       ENDIF
       !                
-      IF( ln_ctl ) THEN                        ! print mean trends (used for debugging)
+      IF( sn_cfctl%l_prttrc ) THEN ! print mean trends (used for debugging)
          WRITE(charout, FMT="('ldf ')")
          CALL prt_ctl_trc_info(charout)
-         CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
+         CALL prt_ctl_trc( tab4d=ptr(:,:,:,:,Krhs), mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
       ENDIF
       !
@@ -143,9 +145,7 @@
       ENDIF
       !
-      REWIND( numnat_ref )             !  namtrc_ldf in reference namelist 
       READ  ( numnat_ref, namtrc_ldf, IOSTAT = ios, ERR = 903)
 903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc_ldf in reference namelist' )
       !
-      REWIND( numnat_cfg )             !  namtrc_ldf in configuration namelist 
       READ  ( numnat_cfg, namtrc_ldf, IOSTAT = ios, ERR = 904 )
 904   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtrc_ldf in configuration namelist' )
@@ -167,5 +167,5 @@
       IF( ln_trcldf_OFF  ) THEN   ;   nldf_trc = np_no_ldf   ;   ioptio = ioptio + 1   ;   ENDIF
       IF( ln_trcldf_tra  ) THEN   ;   nldf_trc = nldf_tra    ;   ioptio = ioptio + 1   ;   ENDIF
-      IF( ioptio /=  1   )   CALL ctl_stop( 'trc_ldf_ini: use ONE of the 2 operator options (NONE/tra)' )
+      IF( ioptio /=  1   )   CALL ctl_stop( 'trc_ldf_ini: use ONE of the 2 operator options (OFF/tra)' )
       
       !                                ! multiplier : passive/active tracers ration
