Index: /branches/2017/dev_merge_2017/NEMOGCM/NEMO/OFF_SRC/dtadyn.F90
===================================================================
--- /branches/2017/dev_merge_2017/NEMOGCM/NEMO/OFF_SRC/dtadyn.F90	(revision 9211)
+++ /branches/2017/dev_merge_2017/NEMOGCM/NEMO/OFF_SRC/dtadyn.F90	(revision 9212)
@@ -85,7 +85,6 @@
    INTEGER, SAVE  :: nprevrec, nsecdyn
 
-
    !!----------------------------------------------------------------------
-   !! NEMO/OFF 3.3 , NEMO Consortium (2010)
+   !! NEMO/OFF 4.0 , NEMO Consortium (2017)
    !! $Id$
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -104,8 +103,9 @@
       !!             - interpolates data if needed
       !!----------------------------------------------------------------------
-      USE oce, ONLY:  zhdivtr => ua
       INTEGER, INTENT(in) ::   kt   ! ocean time-step index
+      !
       INTEGER             ::   ji, jj, jk
-      REAL(wp), ALLOCATABLE, DIMENSION(:,:)   :: zemp
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:)   ::   zemp
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   zhdivtr
       !!----------------------------------------------------------------------
       !
@@ -138,17 +138,16 @@
       !
       IF( .NOT.ln_linssh ) THEN
-         ALLOCATE( zemp(jpi,jpj) )
-         zhdivtr(:,:,:) = sf_dyn(jf_div)%fnow(:,:,:) * tmask(:,:,:)    ! effective u-transport
-         emp_b (:,:)    = sf_dyn(jf_empb)%fnow(:,:,1) * tmask(:,:,1)    ! E-P
-         zemp   (:,:)   = 0.5_wp * ( emp(:,:) + emp_b(:,:) ) + rnf(:,:) + fwbcorr * tmask(:,:,1)
+         ALLOCATE( zemp(jpi,jpj) , zhdivtr(jpi,jpj,jpk) )
+         zhdivtr(:,:,:) = sf_dyn(jf_div)%fnow(:,:,:)  * tmask(:,:,:)    ! effective u-transport
+         emp_b  (:,:)   = sf_dyn(jf_empb)%fnow(:,:,1) * tmask(:,:,1)    ! E-P
+         zemp   (:,:)   = ( 0.5_wp * ( emp(:,:) + emp_b(:,:) ) + rnf(:,:) + fwbcorr ) * tmask(:,:,1)
          CALL dta_dyn_ssh( kt, zhdivtr, sshb, zemp, ssha, e3t_a(:,:,:) )  !=  ssh, vertical scale factor & vertical transport
-         DEALLOCATE( zemp )
+         DEALLOCATE( zemp , zhdivtr )
          !                                           Write in the tracer restart file
-         !                                          *******************************
+         !                                          *********************************
          IF( lrst_trc ) THEN
             IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) 'dta_dyn_ssh : ssh field written in tracer restart file ',   &
-               &                    'at it= ', kt,' date= ', ndastp
-            IF(lwp) WRITE(numout,*) '~~~~'
+            IF(lwp) WRITE(numout,*) 'dta_dyn_ssh : ssh field written in tracer restart file at it= ', kt,' date= ', ndastp
+            IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
             CALL iom_rstput( kt, nitrst, numrtw, 'sshn', ssha )
             CALL iom_rstput( kt, nitrst, numrtw, 'sshb', sshn )
@@ -202,6 +201,4 @@
       !! ** Purpose :   Initialisation of the dynamical data     
       !! ** Method  : - read the data namdta_dyn namelist
-      !!
-      !! ** Action  : - read parameters
       !!----------------------------------------------------------------------
       INTEGER  :: ierr, ierr0, ierr1, ierr2, ierr3   ! return error code
@@ -222,13 +219,12 @@
       TYPE(FLD_N) :: sn_ubl, sn_vbl, sn_rnf    !   "              "
       TYPE(FLD_N) :: sn_div  ! informations about the fields to be read
-
-      !!----------------------------------------------------------------------
-      !
+      !!
       NAMELIST/namdta_dyn/cn_dir, ln_dynrnf, ln_dynrnf_depth,  fwbcorr, &
-         &                sn_uwd, sn_vwd, sn_wwd, sn_emp,    &
-         &                sn_avt, sn_tem, sn_sal, sn_mld , sn_qsr ,   &
-         &                sn_wnd, sn_ice, sn_fmf,                    &
-         &                sn_ubl, sn_vbl, sn_rnf,                   &
+         &                sn_uwd, sn_vwd, sn_wwd, sn_emp,               &
+         &                sn_avt, sn_tem, sn_sal, sn_mld , sn_qsr ,     &
+         &                sn_wnd, sn_ice, sn_fmf,                       &
+         &                sn_ubl, sn_vbl, sn_rnf,                       &
          &                sn_empb, sn_div 
+      !!----------------------------------------------------------------------
       !
       REWIND( numnam_ref )              ! Namelist namdta_dyn in reference namelist : Offline: init. of dynamical data
@@ -252,9 +248,7 @@
       ENDIF
       ! 
-
       jf_uwd  = 1     ;   jf_vwd  = 2    ;   jf_wwd = 3    ;   jf_emp = 4    ;   jf_avt = 5
       jf_tem  = 6     ;   jf_sal  = 7    ;   jf_mld = 8    ;   jf_qsr = 9
       jf_wnd  = 10    ;   jf_ice  = 11   ;   jf_fmf = 12   ;   jfld   = jf_fmf
-
       !
       slf_d(jf_uwd)  = sn_uwd    ;   slf_d(jf_vwd)  = sn_vwd   ;   slf_d(jf_wwd) = sn_wwd
@@ -263,24 +257,22 @@
       slf_d(jf_qsr)  = sn_qsr    ;   slf_d(jf_wnd)  = sn_wnd   ;   slf_d(jf_ice) = sn_ice
       slf_d(jf_fmf)  = sn_fmf
-
       !
       IF( .NOT.ln_linssh ) THEN
-                 jf_div  = jfld + 1    ;         jf_empb  = jfld + 2      ;      jfld = jf_empb
-           slf_d(jf_div) = sn_div      ;   slf_d(jf_empb) = sn_empb
+               jf_div  = jfld + 1   ;         jf_empb  = jfld + 2    ;   jfld = jf_empb
+         slf_d(jf_div) = sn_div     ;   slf_d(jf_empb) = sn_empb
       ENDIF
       !
       IF( ln_trabbl ) THEN
-                 jf_ubl  = jfld + 1    ;         jf_vbl  = jfld + 2     ;      jfld = jf_vbl
-           slf_d(jf_ubl) = sn_ubl      ;   slf_d(jf_vbl) = sn_vbl
+               jf_ubl  = jfld + 1   ;         jf_vbl  = jfld + 2     ;   jfld = jf_vbl
+         slf_d(jf_ubl) = sn_ubl     ;   slf_d(jf_vbl) = sn_vbl
       ENDIF
       !
       IF( ln_dynrnf ) THEN
-                jf_rnf  = jfld + 1     ;     jfld  = jf_rnf
-          slf_d(jf_rnf) = sn_rnf    
+               jf_rnf  = jfld + 1   ;     jfld  = jf_rnf
+         slf_d(jf_rnf) = sn_rnf    
       ELSE
          rnf(:,:) = 0._wp
       ENDIF
 
-  
       ALLOCATE( sf_dyn(jfld), STAT=ierr )         ! set sf structure
       IF( ierr > 0 )  THEN
@@ -426,16 +418,16 @@
    END SUBROUTINE dta_dyn_init
 
+
    SUBROUTINE dta_dyn_swp( kt )
      !!---------------------------------------------------------------------
       !!                    ***  ROUTINE dta_dyn_swp  ***
       !!
-      !! ** Purpose : Swap and the data and compute the vertical scale factor at U/V/W point
-      !!              and the depht
-      !!
+      !! ** Purpose :   Swap and the data and compute the vertical scale factor 
+      !!              at U/V/W pointand the depht
       !!---------------------------------------------------------------------
       INTEGER, INTENT(in) :: kt       ! time step
+      !
       INTEGER             :: ji, jj, jk
       REAL(wp)            :: zcoef
-      !
       !!---------------------------------------------------------------------
 
@@ -471,21 +463,21 @@
       gdept_n(:,:,1) = 0.5_wp * e3w_n(:,:,1)
       gdepw_n(:,:,1) = 0.0_wp
-
+      !
       DO jk = 2, jpk
          DO jj = 1,jpj
             DO ji = 1,jpi
-                 zcoef = (tmask(ji,jj,jk) - wmask(ji,jj,jk))
-                 gdepw_n(ji,jj,jk) = gdepw_n(ji,jj,jk-1) + e3t_n(ji,jj,jk-1)
-                 gdept_n(ji,jj,jk) =      zcoef  * ( gdepw_n(ji,jj,jk  ) + 0.5 * e3w_n(ji,jj,jk))  &
-                     &                + (1-zcoef) * ( gdept_n(ji,jj,jk-1) + e3w_n(ji,jj,jk))
-              END DO
-           END DO
-        END DO
-
+               zcoef = (tmask(ji,jj,jk) - wmask(ji,jj,jk))
+               gdepw_n(ji,jj,jk) = gdepw_n(ji,jj,jk-1) + e3t_n(ji,jj,jk-1)
+               gdept_n(ji,jj,jk) =      zcoef  * ( gdepw_n(ji,jj,jk  ) + 0.5 * e3w_n(ji,jj,jk))  &
+                  &                + (1-zcoef) * ( gdept_n(ji,jj,jk-1) + e3w_n(ji,jj,jk))
+            END DO
+         END DO
+      END DO
+      !
       gdept_b(:,:,:) = gdept_n(:,:,:)
       gdepw_b(:,:,:) = gdepw_n(:,:,:)
-
       !
    END SUBROUTINE dta_dyn_swp
+   
 
    SUBROUTINE dta_dyn_ssh( kt, phdivtr, psshb,  pemp, pssha, pe3ta )
@@ -510,5 +502,4 @@
       !! Reference  : Leclair, M., and G. Madec, 2009, Ocean Modelling.
       !!----------------------------------------------------------------------
-      !! * Arguments
       INTEGER,                                   INTENT(in )    :: kt        !  time-step
       REAL(wp), DIMENSION(jpi,jpj,jpk)          , INTENT(in )   :: phdivtr   ! horizontal divergence transport
@@ -517,10 +508,9 @@
       REAL(wp), DIMENSION(jpi,jpj)    , OPTIONAL, INTENT(inout) :: pssha     ! after ssh
       REAL(wp), DIMENSION(jpi,jpj,jpk), OPTIONAL, INTENT(out)   :: pe3ta     ! after vertical scale factor
-      !! * Local declarations
+      !
       INTEGER                       :: jk
       REAL(wp), DIMENSION(jpi,jpj)  :: zhdiv  
       REAL(wp)  :: z2dt  
       !!----------------------------------------------------------------------
-      
       !
       z2dt = 2._wp * rdt
@@ -577,6 +567,4 @@
       !!
       !!---------------------------------------------------------------------
-      USE oce, ONLY:  zts => tsa 
-      !
       INTEGER,  INTENT(in) :: kt       ! time step
       !
@@ -585,5 +573,6 @@
       REAL(wp) ::   ztintb     ! ratio applied to before records when doing time interpolation
       INTEGER  ::   iswap 
-      REAL(wp), DIMENSION(jpi,jpj,jpk) :: zuslp, zvslp, zwslpi, zwslpj
+      REAL(wp), DIMENSION(jpi,jpj,jpk)      ::   zuslp, zvslp, zwslpi, zwslpj
+      REAL(wp), DIMENSION(jpi,jpj,jpk,jpts) ::   zts
       !!---------------------------------------------------------------------
       !
@@ -658,10 +647,10 @@
    END SUBROUTINE dta_dyn_slp
 
+
    SUBROUTINE compute_slopes( kt, pts, puslp, pvslp, pwslpi, pwslpj )
       !!---------------------------------------------------------------------
       !!                    ***  ROUTINE dta_dyn_slp  ***
       !!
-      !! ** Purpose : Computation of slope
-      !!
+      !! ** Purpose :   Computation of slope
       !!---------------------------------------------------------------------
       INTEGER ,                              INTENT(in ) :: kt       ! time step
@@ -672,4 +661,5 @@
       REAL(wp), DIMENSION(jpi,jpj,jpk)     , INTENT(out) :: pwslpj   ! meridional diapycnal slopes
       !!---------------------------------------------------------------------
+      !
       IF( l_ldfslp .AND. .NOT.lk_c1d ) THEN    ! Computes slopes (here avt is used as workspace)
          CALL eos    ( pts, rhd, rhop, gdept_0(:,:,:) )
@@ -700,4 +690,5 @@
       !
    END SUBROUTINE compute_slopes
+
    !!======================================================================
 END MODULE dtadyn
