Index: branches/2017/dev_merge_2017/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf.F90
===================================================================
--- branches/2017/dev_merge_2017/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf.F90	(revision 9018)
+++ branches/2017/dev_merge_2017/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf.F90	(revision 9019)
@@ -27,5 +27,4 @@
    USE lib_mpp        ! distribued memory computing library
    USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
-   USE wrk_nemo       ! Memory Allocation
    USE timing         ! Timing
 
@@ -37,16 +36,16 @@
 
    !                      ! Parameter to control the type of lateral viscous operator
-   INTEGER, PARAMETER, PUBLIC ::   np_ERROR  =-10   ! error in setting the operator
-   INTEGER, PARAMETER, PUBLIC ::   np_no_ldf = 00   ! without operator (i.e. no lateral viscous trend)
+   INTEGER, PARAMETER, PUBLIC ::   np_ERROR  =-10   !: error in setting the operator
+   INTEGER, PARAMETER, PUBLIC ::   np_no_ldf = 00   !: without operator (i.e. no lateral viscous trend)
    !                          !!      laplacian     !    bilaplacian    !
-   INTEGER, PARAMETER, PUBLIC ::   np_lap    = 10   ,   np_blp    = 20  ! iso-level operator
-   INTEGER, PARAMETER, PUBLIC ::   np_lap_i  = 11                       ! iso-neutral or geopotential operator
+   INTEGER, PARAMETER, PUBLIC ::   np_lap    = 10   ,   np_blp    = 20  !: iso-level operator
+   INTEGER, PARAMETER, PUBLIC ::   np_lap_i  = 11                       !: iso-neutral or geopotential operator
 
-   INTEGER ::   nldf   ! type of lateral diffusion used defined from ln_dynldf_... (namlist logicals)
+   INTEGER, PUBLIC ::   nldf   !: type of lateral diffusion used defined from ln_dynldf_... (namlist logicals)
 
    !! * Substitutions
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.7 , NEMO Consortium (2015)
+   !! NEMO/OPA 4.0 , NEMO Consortium (2017)
    !! $Id$
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -62,11 +61,11 @@
       INTEGER, INTENT(in) ::   kt   ! ocean time-step index
       !
-      REAL(wp), POINTER, DIMENSION(:,:,:) ::  ztrdu, ztrdv
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   ztrdu, ztrdv
       !!----------------------------------------------------------------------
       !
-      IF( nn_timing == 1 )  CALL timing_start('dyn_ldf')
+      IF( ln_timing )   CALL timing_start('dyn_ldf')
       !
       IF( l_trddyn )   THEN                      ! temporary save of momentum trends
-         CALL wrk_alloc( jpi,jpj,jpk,   ztrdu, ztrdv )
+         ALLOCATE( ztrdu(jpi,jpj,jpk) , ztrdv(jpi,jpj,jpk) )
          ztrdu(:,:,:) = ua(:,:,:) 
          ztrdv(:,:,:) = va(:,:,:) 
@@ -85,5 +84,5 @@
          ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
          CALL trd_dyn( ztrdu, ztrdv, jpdyn_ldf, kt )
-         CALL wrk_dealloc( jpi,jpj,jpk,   ztrdu, ztrdv )
+         DEALLOCATE ( ztrdu , ztrdv )
       ENDIF
       !                                          ! print sum trends (used for debugging)
@@ -91,5 +90,5 @@
          &                       tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
       !
-      IF( nn_timing == 1 )  CALL timing_stop('dyn_ldf')
+      IF( ln_timing )   CALL timing_stop('dyn_ldf')
       !
    END SUBROUTINE dyn_ldf
@@ -102,50 +101,52 @@
       !! ** Purpose :   initializations of the horizontal ocean dynamics physics
       !!----------------------------------------------------------------------
-      INTEGER ::   ioptio, ierr         ! temporary integers 
+      INTEGER ::   ioptio, ierr   ! temporary integers 
       !!----------------------------------------------------------------------
       !
-      !                                   ! Namelist nam_dynldf: already read in ldfdyn module
+      !                                !==  Namelist nam_dynldf  ==!   already read in ldfdyn module
       !
-      IF(lwp) THEN                        ! Namelist print
+      IF(lwp) THEN                     !== Namelist print  ==!
          WRITE(numout,*)
          WRITE(numout,*) 'dyn_ldf_init : Choice of the lateral diffusive operator on dynamics'
          WRITE(numout,*) '~~~~~~~~~~~~'
          WRITE(numout,*) '   Namelist nam_dynldf : set lateral mixing parameters (type, direction, coefficients)'
-         WRITE(numout,*) '      laplacian operator          ln_dynldf_lap = ', ln_dynldf_lap
-         WRITE(numout,*) '      bilaplacian operator        ln_dynldf_blp = ', ln_dynldf_blp
-         WRITE(numout,*) '      iso-level                   ln_dynldf_lev = ', ln_dynldf_lev
-         WRITE(numout,*) '      horizontal (geopotential)   ln_dynldf_hor = ', ln_dynldf_hor
-         WRITE(numout,*) '      iso-neutral                 ln_dynldf_iso = ', ln_dynldf_iso
+         WRITE(numout,*) '      Type of operator'
+         WRITE(numout,*) '         no explicit diffusion       ln_dynldf_NONE = ', ln_dynldf_NONE
+         WRITE(numout,*) '         laplacian operator          ln_dynldf_lap  = ', ln_dynldf_lap
+         WRITE(numout,*) '         bilaplacian operator        ln_dynldf_blp  = ', ln_dynldf_blp
+         WRITE(numout,*) '      Direction of action'
+         WRITE(numout,*) '         iso-level                   ln_dynldf_lev  = ', ln_dynldf_lev
+         WRITE(numout,*) '         horizontal (geopotential)   ln_dynldf_hor  = ', ln_dynldf_hor
+         WRITE(numout,*) '         iso-neutral                 ln_dynldf_iso  = ', ln_dynldf_iso
       ENDIF
-      !                                   ! use of lateral operator or not
+      !                                !==  use of lateral operator or not  ==!
       nldf = np_ERROR
       ioptio = 0
-      IF( ln_dynldf_lap )   ioptio = ioptio + 1
-      IF( ln_dynldf_blp )   ioptio = ioptio + 1
-      IF( ioptio >  1   )   CALL ctl_stop( 'dyn_ldf_init: use ONE or NONE of the 2 lap/bilap operator type on momentum' )
-      IF( ioptio == 0   )   nldf = np_no_ldf     ! No lateral mixing operator
+      IF( ln_dynldf_NONE ) THEN   ;   nldf = np_no_ldf   ;   ioptio = ioptio + 1   ;   ENDIF
+      IF( ln_dynldf_lap  ) THEN   ;                          ioptio = ioptio + 1   ;   ENDIF
+      IF( ln_dynldf_blp  ) THEN   ;                          ioptio = ioptio + 1   ;   ENDIF
+      IF( ioptio /= 1    )   CALL ctl_stop( 'dyn_ldf_init: use ONE of the 3 operator options (NONE/lap/blp)' )
       !
-      IF( nldf /= np_no_ldf ) THEN        ! direction ==>> type of operator  
+      IF(.NOT.ln_dynldf_NONE ) THEN    !==  direction ==>> type of operator  ==!
          ioptio = 0
          IF( ln_dynldf_lev )   ioptio = ioptio + 1
          IF( ln_dynldf_hor )   ioptio = ioptio + 1
          IF( ln_dynldf_iso )   ioptio = ioptio + 1
-         IF( ioptio >  1   )   CALL ctl_stop( '          use only ONE direction (level/hor/iso)' )
-         IF( ioptio == 0   )   CALL ctl_stop( '          use at least ONE direction (level/hor/iso)' )
+         IF( ioptio /= 1   )   CALL ctl_stop( 'dyn_ldf_init: use ONE of the 3 direction options (level/hor/iso)' )
          !
-         !                                   ! Set nldf, the type of lateral diffusion, from ln_dynldf_... logicals
+         !                             ! Set nldf, the type of lateral diffusion, from ln_dynldf_... logicals
          ierr = 0
-         IF ( ln_dynldf_lap ) THEN      ! laplacian operator
-            IF ( ln_zco ) THEN                ! z-coordinate
+         IF( ln_dynldf_lap ) THEN         ! laplacian operator
+            IF( ln_zco ) THEN                ! z-coordinate
                IF ( ln_dynldf_lev )   nldf = np_lap     ! iso-level = horizontal (no rotation)
                IF ( ln_dynldf_hor )   nldf = np_lap     ! iso-level = horizontal (no rotation)
                IF ( ln_dynldf_iso )   nldf = np_lap_i   ! iso-neutral            (   rotation)
             ENDIF
-            IF ( ln_zps ) THEN             ! z-coordinate with partial step
+            IF( ln_zps ) THEN                ! z-coordinate with partial step
                IF ( ln_dynldf_lev )   nldf = np_lap     ! iso-level              (no rotation)
                IF ( ln_dynldf_hor )   nldf = np_lap     ! iso-level              (no rotation)
                IF ( ln_dynldf_iso )   nldf = np_lap_i   ! iso-neutral            (   rotation)
             ENDIF
-            IF ( ln_sco ) THEN             ! s-coordinate
+            IF( ln_sco ) THEN                ! s-coordinate
                IF ( ln_dynldf_lev )   nldf = np_lap     ! iso-level = horizontal (no rotation)
                IF ( ln_dynldf_hor )   nldf = np_lap_i   ! horizontal             (   rotation)
@@ -154,19 +155,19 @@
          ENDIF
          !
-         IF( ln_dynldf_blp ) THEN          ! bilaplacian operator
-            IF ( ln_zco ) THEN                ! z-coordinate
-               IF ( ln_dynldf_lev )   nldf = np_blp     ! iso-level = horizontal (no rotation)
-               IF ( ln_dynldf_hor )   nldf = np_blp     ! iso-level = horizontal (no rotation)
-               IF ( ln_dynldf_iso )   ierr = 2          ! iso-neutral            (   rotation)
+         IF( ln_dynldf_blp ) THEN         ! bilaplacian operator
+            IF( ln_zco ) THEN                ! z-coordinate
+               IF( ln_dynldf_lev )   nldf = np_blp     ! iso-level = horizontal (no rotation)
+               IF( ln_dynldf_hor )   nldf = np_blp     ! iso-level = horizontal (no rotation)
+               IF( ln_dynldf_iso )   ierr = 2          ! iso-neutral            (   rotation)
             ENDIF
-            IF ( ln_zps ) THEN             ! z-coordinate with partial step
-               IF ( ln_dynldf_lev )   nldf = np_blp     ! iso-level              (no rotation)
-               IF ( ln_dynldf_hor )   nldf = np_blp     ! iso-level              (no rotation)
-               IF ( ln_dynldf_iso )   ierr = 2          ! iso-neutral            (   rotation)
+            IF( ln_zps ) THEN                ! z-coordinate with partial step
+               IF( ln_dynldf_lev )   nldf = np_blp     ! iso-level              (no rotation)
+               IF( ln_dynldf_hor )   nldf = np_blp     ! iso-level              (no rotation)
+               IF( ln_dynldf_iso )   ierr = 2          ! iso-neutral            (   rotation)
             ENDIF
-            IF ( ln_sco ) THEN             ! s-coordinate
-               IF ( ln_dynldf_lev )   nldf = np_blp     ! iso-level              (no rotation)
-               IF ( ln_dynldf_hor )   ierr = 2          ! horizontal             (   rotation)
-               IF ( ln_dynldf_iso )   ierr = 2          ! iso-neutral            (   rotation)
+            IF( ln_sco ) THEN                ! s-coordinate
+               IF( ln_dynldf_lev )   nldf = np_blp     ! iso-level              (no rotation)
+               IF( ln_dynldf_hor )   ierr = 2          ! horizontal             (   rotation)
+               IF( ln_dynldf_iso )   ierr = 2          ! iso-neutral            (   rotation)
             ENDIF
          ENDIF
