Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/dom_ice_2.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/dom_ice_2.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/dom_ice_2.F90	(revision 2636)
@@ -15,10 +15,9 @@
    !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-   USE par_ice_2
+   USE par_ice_2   ! LIM parameters
 
    IMPLICIT NONE
    PRIVATE
 
-   ! Routine accessibility
    PUBLIC    dom_ice_alloc_2    ! Called from nemogcm.F90
 
@@ -42,4 +41,31 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)         ::   tmi               !: ice mask: =1 if ice thick > 0
 # endif
+   !!----------------------------------------------------------------------
+   CONTAINS
+
+   INTEGER FUNCTION dom_ice_alloc_2()
+      !!----------------------------------------------------------------------
+      USE lib_mpp, ONLY:   ctl_warn   ! MPP library
+      INTEGER :: ierr(2)
+      !!----------------------------------------------------------------------
+      ierr(:) = 0
+      !
+      ALLOCATE( fs2cor(jpi,jpj),  fcor(jpi,jpj),                             &
+         &      covrai(jpi,jpj),  area(jpi,jpj), tms(jpi,jpj), tmu(jpi,jpj), &
+         &      wght(jpi,jpj,2,2),  Stat=ierr(1) )
+         !
+      ALLOCATE(                                                              &
+#if defined key_lim2_vp 
+         &        akappa(jpi,jpj,2,2), bkappa(jpi,jpj,2,2),                  &
+         &        alambd(jpi,jpj,2,2,2,2),                                   &
+#else
+         &        tmv(jpi,jpj), tmf(jpi,jpj), tmi(jpi,jpj),                  &
+#endif
+         &        Stat=ierr(2) )
+         !
+      dom_ice_alloc_2 = MAXVAL(ierr)
+      IF( dom_ice_alloc_2 /= 0 )   CALL ctl_warn('dom_ice_alloc_2: failed to allocate arrays')
+      !
+   END FUNCTION dom_ice_alloc_2
 
 #else
@@ -49,36 +75,3 @@
 #endif
    !!======================================================================
-#if defined key_lim2
-   CONTAINS
-
-     FUNCTION dom_ice_alloc_2()
-        USE in_out_manager, ONLY: ctl_warn
-        IMPLICIT none
-        INTEGER :: dom_ice_alloc_2
-        INTEGER :: ierr(2)
-
-        ierr(:) = 0
-
-        ALLOCATE(fs2cor(jpi,jpj),  fcor(jpi,jpj),                             &
-                 covrai(jpi,jpj),  area(jpi,jpj), tms(jpi,jpj), tmu(jpi,jpj), &
-                 wght(jpi,jpj,2,2),  Stat=ierr(1) )
-
-        ALLOCATE(                                                             &
-#if defined key_lim2_vp 
-                 akappa(jpi,jpj,2,2), bkappa(jpi,jpj,2,2),                    &
-                 alambd(jpi,jpj,2,2,2,2),                                     &
-#else
-                 tmv(jpi,jpj), tmf(jpi,jpj), tmi(jpi,jpj),                    &
-#endif
-                 Stat=ierr(2))
-
-        dom_ice_alloc_2 = MAXVAL(ierr)
-
-        IF(dom_ice_alloc_2 /= 0)THEN
-           CALL ctl_warn('dom_ice_alloc_2: failed to allocate arrays.')
-        END IF
-
-     END FUNCTION dom_ice_alloc_2
-#endif
-
 END MODULE dom_ice_2
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/ice_2.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/ice_2.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/ice_2.F90	(revision 2636)
@@ -12,5 +12,5 @@
    !!   'key_lim2' :                                  LIM 2.0 sea-ice model
    !!----------------------------------------------------------------------
-   USE par_ice_2          ! LIM sea-ice parameters
+   USE par_ice_2      ! LIM sea-ice parameters
 
    IMPLICIT NONE
@@ -127,18 +127,16 @@
    CONTAINS
 
-   FUNCTION ice_alloc_2()
+   INTEGER FUNCTION ice_alloc_2()
       !!-----------------------------------------------------------------
       !!               *** FUNCTION ice_alloc_2 ***
       !!-----------------------------------------------------------------
-      USE in_out_manager, ONLY: ctl_warn
-      INTEGER :: ice_alloc_2     ! return value
-      INTEGER :: ierr(9)        ! Local variables
+      USE lib_mpp, ONLY:   ctl_warn   ! MPP library
+      INTEGER :: ierr(9)              ! Local variables
       !!-----------------------------------------------------------------
-
       ierr(:) = 0
-
+      !
       ALLOCATE( ahiu(jpi,jpj) , pahu(jpi,jpj) ,                      &
          &      ahiv(jpi,jpj) , pahv(jpi,jpj) , ust2s(jpi,jpj) , STAT=ierr(1) )
-
+         !
       !* Ice Rheology
 #if defined key_lim2_vp
@@ -149,5 +147,4 @@
                 stress12_i(jpi,jpj) , shear_i(jpi,jpj) , hicm(jpi,jpj) , STAT=ierr(2) )
 #endif
-
       ALLOCATE( rdvosif(jpi,jpj) , rdvobif(jpi,jpj) ,                      &
          &      fdvolif(jpi,jpj) , rdvonif(jpi,jpj) ,                      &
@@ -181,7 +178,7 @@
       ALLOCATE(sxst  (jpi,jpj) , syst  (jpi,jpj) , sxxst (jpi,jpj) ,     &
          &     syyst (jpi,jpj) , sxyst (jpi,jpj)                   , STAT=ierr(9))
-
+         !
       ice_alloc_2 = MAXVAL( ierr )
-
+      !
       IF( ice_alloc_2 /= 0 )   CALL ctl_warn('ice_alloc_2: failed to allocate arrays.')
       !
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/iceini_2.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/iceini_2.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/iceini_2.F90	(revision 2636)
@@ -30,5 +30,6 @@
    USE limsbc_2         ! LIM2 surface boundary condition
    USE in_out_manager   ! I/O manager
-      
+   USE lib_mpp          ! MPP library
+
    IMPLICIT NONE
    PRIVATE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limadv_2.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limadv_2.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limadv_2.F90	(revision 2636)
@@ -22,4 +22,5 @@
    USE lbclnk
    USE in_out_manager     ! I/O manager
+   USE lib_mpp            ! MPP library
    USE prtctl             ! Print control
 
@@ -79,5 +80,5 @@
       IF( wrk_in_use(2, 11,12,13,14,15,16,17,18,19,20,21) ) THEN
          CALL ctl_stop( 'lim_adv_x_2 : requested workspace arrays unavailable.' )   ;   RETURN
-      END IF
+      ENDIF
 
       ! Limitation of moments.                                           
@@ -224,7 +225,6 @@
       ENDIF
       !
-      IF( wrk_not_released(2, 11,12,13,14,15,16,17,18,19,20,21) ) THEN
-         CALL ctl_stop( 'lim_adv_x_2 : failed to release workspace arrays.' )
-      END IF
+      IF( wrk_not_released(2, 11,12,13,14,15,16,17,18,19,20,21) )   &
+          CALL ctl_stop( 'lim_adv_x_2 : failed to release workspace arrays.' )
       !
    END SUBROUTINE lim_adv_x_2
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limdia_2.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limdia_2.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limdia_2.F90	(revision 2636)
@@ -12,5 +12,4 @@
    !!   'key_lim2' :                                  LIM 2.0 sea-ice model
    !!----------------------------------------------------------------------
-   !!----------------------------------------------------------------------
    !!   lim_dia_2      : computation of the time evolution of keys var.
    !!   lim_dia_init_2 : initialization and namelist read
@@ -24,4 +23,5 @@
    USE limistate_2     !
    USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limdmp_2.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limdmp_2.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limdmp_2.F90	(revision 2636)
@@ -13,10 +13,11 @@
    !!   lim_dmp_2      : ice model damping
    !!----------------------------------------------------------------------
-   USE in_out_manager  ! I/O manager
    USE ice_2           ! ice variables 
    USE sbc_oce, ONLY : nn_fsbc ! for fldread
    USE dom_oce         ! for mi0; mi1 etc ...
    USE fldread         ! read input fields
-   
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! MPP library
+
    IMPLICIT NONE
    PRIVATE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limdyn_2.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limdyn_2.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limdyn_2.F90	(revision 2636)
@@ -72,6 +72,6 @@
 
       IF(  wrk_in_use(1, 1,2)  .OR.  wrk_in_use(2, 1,2)  ) THEN
-         CALL ctl_stop( 'lim_dyn_2 : requested workspace arrays unavailable.' )   ;   RETURN
-      END IF
+         CALL ctl_stop( 'lim_dyn_2 : requested workspace arrays unavailable' )   ;   RETURN
+      ENDIF
       zind => wrk_1d_1(1:jpj)      ! Set-up pointers to sub-arrays of workspaces
       zmsk => wrk_1d_2(1:jpj)
@@ -210,7 +210,6 @@
       IF(ln_ctl)   CALL prt_ctl(tab2d_1=ust2s , clinfo1=' lim_dyn  : ust2s :')
       !
-      IF( wrk_not_released(1, 1,2) .OR. wrk_not_released(2, 1,2) )THEN
-         CALL ctl_stop('lim_dyn_2 : failed to release workspace arrays.')
-      END IF
+      IF( wrk_not_released(1, 1,2)     .OR.   &
+          wrk_not_released(2, 1,2) )   CALL ctl_stop('lim_dyn_2 : failed to release workspace arrays')
       !
    END SUBROUTINE lim_dyn_2
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limhdf_2.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limhdf_2.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limhdf_2.F90	(revision 2636)
@@ -149,7 +149,5 @@
       ENDIF
       !
-      IF( wrk_not_released(2, 11,12,13,14,15,16) ) THEN
-         CALL ctl_stop( 'lim_hdf_2 : failed to release workspace arrays.' )   ;   RETURN
-      END IF
+      IF( wrk_not_released(2, 11,12,13,14,15,16) )   CALL ctl_stop('lim_hdf_2: failed to release workspace arrays')
       !
    END SUBROUTINE lim_hdf_2
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limmsh_2.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limmsh_2.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limmsh_2.F90	(revision 2636)
@@ -19,4 +19,5 @@
    USE lbclnk
    USE in_out_manager
+   USE lib_mpp          ! MPP library
 
    IMPLICIT NONE
@@ -56,8 +57,7 @@
       !!---------------------------------------------------------------------
 
-      IF(wrk_in_use(2, 1,2))THEN
-         CALL ctl_stop('lim_msh_2 : requested workspace arrays unavailable.')
-         RETURN
-      END IF
+      IF( wrk_in_use(2, 1,2) ) THEN
+         CALL ctl_stop('lim_msh_2 : requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
 
       IF(lwp) THEN
@@ -281,7 +281,5 @@
       area(:,:) = e1t(:,:) * e2t(:,:)
       !
-      IF(wrk_not_released(2, 1,2))THEN
-         CALL ctl_stop('lim_msh_2 : failed to release workspace arrays.')
-      END IF
+      IF( wrk_not_released(2, 1,2) )   CALL ctl_stop('lim_msh_2 : failed to release workspace arrays')
       !
    END SUBROUTINE lim_msh_2
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limrhg_2.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limrhg_2.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limrhg_2.F90	(revision 2636)
@@ -57,24 +57,19 @@
 CONTAINS
 
-   FUNCTION lim_rhg_alloc_2()
+   INTEGER FUNCTION lim_rhg_alloc_2()
       !!-------------------------------------------------------------------
       !!               ***  FUNCTION lim_rhg_alloc_2  ***
       !!-------------------------------------------------------------------
-      INTEGER :: lim_rhg_alloc_2
-      !!-------------------------------------------------------------------
-
-      ALLOCATE(zu0(jpi,0:jpj+1),      zv0(jpi,0:jpj+1),     &
-               zu_n(jpi,0:jpj+1),     zv_n(jpi,0:jpj+1),    &
-               zu_a(jpi,0:jpj+1),     zv_a(jpi,0:jpj+1),    &
-               zviszeta(jpi,0:jpj+1), zviseta(jpi,0:jpj+1), &
-               zzfrld(jpi,0:jpj+1),   zztms(jpi,0:jpj+1),   &
-               zi1(jpi,0:jpj+1),      zi2(jpi,0:jpj+1),     &
-               zmasst(jpi,0:jpj+1),   zpresh(jpi,0:jpj+1),  &
-               Stat=lim_rhg_alloc_2)
-
-      IF(lim_rhg_alloc_2 /= 0)THEN
-         CALL ctl_warn('lim_rhg_alloc_2 : failed to allocate arrays.')
-      END IF
-
+      ALLOCATE( zu0(jpi,0:jpj+1),      zv0(jpi,0:jpj+1),     &
+         &      zu_n(jpi,0:jpj+1),     zv_n(jpi,0:jpj+1),    &
+         &      zu_a(jpi,0:jpj+1),     zv_a(jpi,0:jpj+1),    &
+         &      zviszeta(jpi,0:jpj+1), zviseta(jpi,0:jpj+1), &
+         &      zzfrld(jpi,0:jpj+1),   zztms(jpi,0:jpj+1),   &
+         &      zi1(jpi,0:jpj+1),      zi2(jpi,0:jpj+1),     &
+         &      zmasst(jpi,0:jpj+1),   zpresh(jpi,0:jpj+1),  &
+         &      Stat=lim_rhg_alloc_2)
+         !
+      IF( lim_rhg_alloc_2 /= 0 )   CALL ctl_warn('lim_rhg_alloc_2 : failed to allocate arrays')
+      !
    END FUNCTION lim_rhg_alloc_2
 
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limsbc_2.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limsbc_2.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limsbc_2.F90	(revision 2636)
@@ -30,4 +30,5 @@
    USE albedo           ! albedo parameters
    USE lbclnk           ! ocean lateral boundary condition - MPP exchanges
+   USE lib_mpp          ! MPP library
    USE in_out_manager   ! I/O manager
    USE diaar5, ONLY :   lk_diaar5
@@ -62,11 +63,8 @@
 CONTAINS
 
-   FUNCTION lim_sbc_alloc_2()
+   INTEGER FUNCTION lim_sbc_alloc_2()
       !!-------------------------------------------------------------------
       !!             ***  ROUTINE lim_sbc_alloc_2 ***
       !!-------------------------------------------------------------------
-      INTEGER :: lim_sbc_alloc_2
-      !!-------------------------------------------------------------------
-      !
       ALLOCATE( soce_0(jpi,jpj) , utau_oce(jpi,jpj) ,                       &
          &      sice_0(jpi,jpj) , vtau_oce(jpi,jpj) , tmod_io(jpi,jpj), STAT=lim_sbc_alloc_2)
@@ -117,7 +115,6 @@
      
       IF( wrk_in_use(2, 1) .OR. wrk_in_use(3, 4,5) )THEN
-         CALL ctl_stop('lim_sbc_flx_2 : requested workspace arrays unavailable.')
-         RETURN
-      END IF
+         CALL ctl_stop('lim_sbc_flx_2 : requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
       zalb  => wrk_3d_4(:,:,1:1)      ! Set-up pointers to sub-arrays of 3d workspaces
       zalbp => wrk_3d_5(:,:,1:1)
@@ -253,7 +250,6 @@
       ENDIF 
       !
-      IF( wrk_not_released(2, 1) .OR. wrk_not_released(3, 4,5) )THEN
-         CALL ctl_stop('lim_sbc_flx_2 : failed to release workspace arrays.')
-      END IF
+      IF( wrk_not_released(2, 1)     .OR.    &
+          wrk_not_released(3, 4,5) )   CALL ctl_stop('lim_sbc_flx_2 : failed to release workspace arrays')
       !
    END SUBROUTINE lim_sbc_flx_2
@@ -297,7 +293,7 @@
       !!---------------------------------------------------------------------
       !
-      IF(wrk_in_use(2, 1,2))THEN
+      IF( wrk_in_use(2, 1,2) ) THEN
          CALL ctl_stop('lim_sbc_tau_2 : requested workspace arrays unavailable.')   ;   RETURN
-      END IF
+      ENDIF
       !
       SELECT CASE( cp_ice_msh )     
@@ -413,5 +409,5 @@
          &                       tab2d_2=vtau, clinfo2=' vtau    : '        , mask2=vmask )
       !  
-      IF(wrk_not_released(2, 1,2) )   CALL ctl_stop('lim_sbc_tau_2 : failed to release workspace arrays.')
+      IF( wrk_not_released(2, 1,2) )   CALL ctl_stop('lim_sbc_tau_2 : failed to release workspace arrays')
       !
    END SUBROUTINE lim_sbc_tau_2
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limthd_2.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limthd_2.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limthd_2.F90	(revision 2636)
@@ -116,9 +116,8 @@
       !!-------------------------------------------------------------------
 
-      IF( wrk_in_use(2, 1,2,3,4,5,6,7,8,9,10) .OR.  &
-          wrk_in_use(3, 4)   ) THEN
-         CALL ctl_stop('lim_thd_2 : requested workspace arrays unavailable')
-         RETURN
-      END IF
+      IF( wrk_in_use(2, 1,2,3,4,5,6,7,8,9,10)   .OR.  &
+          wrk_in_use(3, 4)                    ) THEN
+         CALL ctl_stop('lim_thd_2 : requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
 
       IF( kt == nit000 )   CALL lim_thd_init_2  ! Initialization (first time-step only)
@@ -521,8 +520,8 @@
       ENDIF
        !
-      IF( wrk_not_released(2, 1,2,3,4,5,6,7,8,9,10) .OR.  &
-          wrk_not_released(3, 4)   ) THEN
+      IF( wrk_not_released(2, 1,2,3,4,5,6,7,8,9,10)   .OR.  &
+          wrk_not_released(3, 4)                    ) THEN
          CALL ctl_stop('lim_thd_2 : failed to release workspace arrays')
-      END IF
+      ENDIF
       !
     END SUBROUTINE lim_thd_2
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limthd_lac_2.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limthd_lac_2.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limthd_lac_2.F90	(revision 2636)
@@ -7,6 +7,6 @@
 
    !!----------------------------------------------------------------------
-   !!   lim_lat_acr_2    : lateral accretion of ice
-   !! * Modules used
+   !!   lim_lat_acr_2   : lateral accretion of ice
+   !!----------------------------------------------------------------------
    USE par_oce          ! ocean parameters
    USE phycst
@@ -14,12 +14,11 @@
    USE ice_2
    USE limistate_2 
-     
+   USE lib_mpp          ! MPP library
+
    IMPLICIT NONE
    PRIVATE
 
-   !! * Routine accessibility
-   PUBLIC lim_thd_lac_2   ! called by lim_thd_2
-
-   !! * Module variables
+   PUBLIC   lim_thd_lac_2   ! called by lim_thd_2
+
    REAL(wp)  ::           &  ! constant values
       epsi20 = 1.e-20  ,  &
@@ -27,4 +26,5 @@
       zzero  = 0.e0    ,  &
       zone   = 1.e0
+
    !!----------------------------------------------------------------------
    !! NEMO/LIM2 3.3 , UCL - NEMO Consortium (2010)
@@ -70,12 +70,10 @@
       USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
       USE wrk_nemo, ONLY: wrk_1d_1, wrk_1d_2, wrk_1d_3, wrk_1d_4, wrk_1d_5, wrk_1d_6
-      USE in_out_manager, ONLY: ctl_stop
-      !!
-      !! * Arguments
+      !
       INTEGER , INTENT(IN)::  &
          kideb          ,   &  ! start point on which the the computation is applied
          kiut                  ! end point on which the the computation is applied
 
-      !! * Local variables
+      ! * Local variables
       INTEGER ::            &
          ji             ,   &  !  dummy loop indices
@@ -106,8 +104,7 @@
       !!---------------------------------------------------------------------      
                
-      IF(wrk_in_use(1, 1,2,3,4,5,6))THEN
-         CALL ctl_stop('lim_thd_lac_2 : requestead workspace arrays unavailable.')
-         RETURN
-      END IF
+      IF( wrk_in_use(1, 1,2,3,4,5,6) ) THEN
+         CALL ctl_stop('lim_thd_lac_2 : requestead workspace arrays unavailable')   ;   RETURN
+      ENDIF
       ! Set-up pointers to sub-arrays of workspace arrays
       zqbgow    => wrk_1d_1(1:jpij)
@@ -235,17 +232,16 @@
       END DO
       
-      IF(wrk_not_released(1, 1,2,3,4,5,6))THEN
-         CALL ctl_stop('lim_thd_lac_2 : failed to release workspace arrays.')
-      END IF
-
+      IF( wrk_not_released(1, 1,2,3,4,5,6) )   CALL ctl_stop('lim_thd_lac_2 : failed to release workspace arrays.')
+      !
    END SUBROUTINE lim_thd_lac_2
 #else
-   !!======================================================================
+   !!----------------------------------------------------------------------
    !!                       ***  MODULE limthd_lac_2   ***
    !!                           no sea ice model
-   !!======================================================================
+   !!----------------------------------------------------------------------
 CONTAINS
    SUBROUTINE lim_thd_lac_2           ! Empty routine
    END SUBROUTINE lim_thd_lac_2
 #endif
+   !!======================================================================
 END MODULE limthd_lac_2
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limthd_zdf_2.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limthd_zdf_2.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limthd_zdf_2.F90	(revision 2636)
@@ -11,8 +11,6 @@
    !!   'key_lim2'                                    LIM 2.0 sea-ice model
    !!----------------------------------------------------------------------
-   !!----------------------------------------------------------------------
    !!   lim_thd_zdf_2 : vertical accr./abl. and lateral ablation of sea ice
    !!----------------------------------------------------------------------
-   !! * Modules used
    USE par_oce          ! ocean parameters
    USE phycst           ! ???
@@ -21,4 +19,5 @@
    USE limistate_2
    USE in_out_manager
+   USE lib_mpp          ! MPP library
    USE cpl_oasis3, ONLY : lk_cpl
       
@@ -35,7 +34,6 @@
    !! NEMO/LIM2 3.3 , UCL - NEMO Consortium (2010)
    !! $Id$
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-
 CONTAINS
 
@@ -170,9 +168,8 @@
 
        IF(wrk_in_use(1, 1,  2, 3, 4, 5, 6, 7, 8, 9,10, &
-                        11,12,13,14,15,16,17,18,19,20, &
-                        21,22,23,24,25,26,27))THEN
-          CALL ctl_stop('lim_thd_zdf_2 : requested workspace arrays unavailable.')
-          RETURN
-       END IF
+          &             11,12,13,14,15,16,17,18,19,20, &
+          &             21,22,23,24,25,26,27) ) THEN
+          CALL ctl_stop('lim_thd_zdf_2 : requested workspace arrays unavailable')   ;   RETURN
+       ENDIF
 
        ztsmlt  => wrk_1d_1(1:jpij)
@@ -808,9 +805,8 @@
        END DO
        ! 
-       IF(wrk_not_released(1, 1,  2, 3, 4, 5, 6, 7, 8, 9,10, &
-                              11,12,13,14,15,16,17,18,19,20, &
-                              21,22,23,24,25,26,27))THEN
-          CALL ctl_stop('lim_thd_zdf_2 : failed to release workspace arrays.')
-       END IF
+       IF( wrk_not_released(1, 1,  2, 3, 4, 5, 6, 7, 8, 9,10,   &
+           &                   11,12,13,14,15,16,17,18,19,20,   &
+           &                   21,22,23,24,25,26,27)        )   &
+           CALL ctl_stop('lim_thd_zdf_2 : failed to release workspace arrays.')
        !
     END SUBROUTINE lim_thd_zdf_2
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limtrp_2.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limtrp_2.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limtrp_2.F90	(revision 2636)
@@ -79,8 +79,7 @@
       !---------------------------------------------------------------------
 
-      IF(wrk_in_use(2, 1,2,3,4,5,6,7,8,9,10))THEN
-         CALL ctl_stop('lim_trp_2 : requested workspace arrays unavailable.')
-         RETURN
-      END IF
+      IF( wrk_in_use(2, 1,2,3,4,5,6,7,8,9,10) ) THEN
+         CALL ctl_stop('lim_trp_2 : requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
 
       IF( kt == nit000  )   CALL lim_trp_init_2      ! Initialization (first time-step only)
@@ -274,7 +273,5 @@
       ENDIF
       !
-      IF(wrk_not_released(2, 1,2,3,4,5,6,7,8,9,10))THEN
-         CALL ctl_stop('lim_trp_2 : failed to release workspace arrays.')
-      END IF
+      IF( wrk_not_released(2, 1,2,3,4,5,6,7,8,9,10) )   CALL ctl_stop('lim_trp_2 : failed to release workspace arrays')
       !
    END SUBROUTINE lim_trp_2
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limwri_2.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limwri_2.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/limwri_2.F90	(revision 2636)
@@ -26,7 +26,8 @@
    USE ice_2
 
+   USE dianam          ! build name of file (routine)
    USE lbclnk
-   USE dianam          ! build name of file (routine)
    USE in_out_manager
+   USE lib_mpp         ! MPP library
    USE iom
    USE ioipsl
@@ -69,12 +70,8 @@
 CONTAINS
 
-   FUNCTION lim_wri_alloc_2()
+   INTEGER FUNCTION lim_wri_alloc_2()
       !!-------------------------------------------------------------------
       !!                  ***   ROUTINE lim_wri_alloc_2  ***
       !!-------------------------------------------------------------------
-      IMPLICIT none
-      INTEGER :: lim_wri_alloc_2
-      !!-------------------------------------------------------------------
-      !
       ALLOCATE( ndex51(jpij), zcmo(jpi,jpj,jpnoumax), STAT=lim_wri_alloc_2)
       !
@@ -115,8 +112,7 @@
       !!-------------------------------------------------------------------
 
-      IF(wrk_in_use(2, 1))THEN
-         CALL ctl_stop('lim_wri_2 : requested workspace array unavailable.')
-         RETURN
-      END IF
+      IF( wrk_in_use(2, 1) ) THEN
+         CALL ctl_stop('lim_wri_2 : requested workspace array unavailable')   ;   RETURN
+      ENDIF
                                                  !--------------------!
       IF( kt == nit000 ) THEN                    !   Initialisation   !
@@ -211,8 +207,6 @@
       IF( ( nn_fsbc * niter ) >= nitend )   CALL histclo( nice ) 
 
-      IF(wrk_not_released(2, 1))THEN
-         CALL ctl_stop('lim_wri_2 : failed to release workspace array.')
-      END IF
-
+      IF( wrk_not_released(2, 1) )   CALL ctl_stop('lim_wri_2 : failed to release workspace array.')
+      !
    END SUBROUTINE lim_wri_2
      
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/thd_ice_2.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/thd_ice_2.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_2/thd_ice_2.F90	(revision 2636)
@@ -12,5 +12,4 @@
    !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-   !! * Modules used
    USE par_ice_2
 
@@ -85,41 +84,42 @@
       tbif_1d              !: corresponding to the 2D var  tbif
 
-   !!======================================================================
+   !!----------------------------------------------------------------------
+   !! NEMO/LIM2 3.3 , UCL - NEMO Consortium (2010)
+   !! $Id$
+   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
  CONTAINS
 
-   FUNCTION thd_ice_alloc_2()
-      USE in_out_manager, ONLY: ctl_warn
-      IMPLICIT none
-      INTEGER :: thd_ice_alloc_2
-      ! Local vars
+   INTEGER FUNCTION thd_ice_alloc_2()
+      !!----------------------------------------------------------------------
+      USE lib_mpp        ! MPP library
       INTEGER :: ierr(4)
-
+      !!----------------------------------------------------------------------
+      !
       ierr(:) = 0
-
-      ALLOCATE(npb(jpij), npac(jpij),                             &
-               qldif_1d(jpij), qcmif_1d(jpij), thcm_1d(jpij),     &
-               fstbif_1d(jpij), fltbif_1d(jpij), fscbq_1d(jpij),  &
-               qsr_ice_1d(jpij),fr1_i0_1d(jpij), fr2_i0_1d(jpij), Stat=ierr(1))
-
-      ALLOCATE(qns_ice_1d(jpij), qfvbq_1d(jpij), sist_1d(jpij), tfu_1d(jpij), &
-               sprecip_1d(jpij), h_snow_1d(jpij),h_ice_1d(jpij),frld_1d(jpij),&
-               qstbif_1d(jpij),  fbif_1d(jpij),  Stat=ierr(2))
-
-      ALLOCATE(rdmicif_1d(jpij), rdmsnif_1d(jpij), qlbbq_1d(jpij),   &
-               dmgwi_1d(jpij)  , dvsbq_1d(jpij)  , rdvomif_1d(jpij), &
-               dvbbq_1d(jpij)  , dvlbq_1d(jpij)  , dvnbq_1d(jpij)  , &
-               Stat=ierr(3))
-
-      ALLOCATE(dqns_ice_1d(jpij) ,qla_ice_1d(jpij), dqla_ice_1d(jpij), &
-               tbif_1d(jpij, jplayersp1), Stat=ierr(4))
-
+      !
+      ALLOCATE( npb(jpij), npac(jpij),                             &
+         &      qldif_1d(jpij), qcmif_1d(jpij), thcm_1d(jpij),     &
+         &      fstbif_1d(jpij), fltbif_1d(jpij), fscbq_1d(jpij),  &
+         &      qsr_ice_1d(jpij),fr1_i0_1d(jpij), fr2_i0_1d(jpij), Stat=ierr(1))
+         !
+      ALLOCATE( qns_ice_1d(jpij), qfvbq_1d(jpij), sist_1d(jpij), tfu_1d(jpij), &
+         &      sprecip_1d(jpij), h_snow_1d(jpij),h_ice_1d(jpij),frld_1d(jpij),&
+         &      qstbif_1d(jpij),  fbif_1d(jpij),  Stat=ierr(2))
+         !
+      ALLOCATE( rdmicif_1d(jpij), rdmsnif_1d(jpij), qlbbq_1d(jpij),   &
+         &      dmgwi_1d(jpij)  , dvsbq_1d(jpij)  , rdvomif_1d(jpij), &
+         &      dvbbq_1d(jpij)  , dvlbq_1d(jpij)  , dvnbq_1d(jpij)  , &
+         &      Stat=ierr(3))
+         !
+      ALLOCATE( dqns_ice_1d(jpij) ,qla_ice_1d(jpij), dqla_ice_1d(jpij), &
+         &      tbif_1d(jpij, jplayersp1), Stat=ierr(4))
+         !
       thd_ice_alloc_2 = MAXVAL(ierr)
-
-      IF(thd_ice_alloc_2 /= 0)THEN
-         CALL ctl_warn('thd_ice_alloc_2: failed to allocate arrays.')
-      END IF
-
+      IF( thd_ice_alloc_2 /= 0 )   CALL ctl_warn('thd_ice_alloc_2: failed to allocate arrays')
+      !
    END FUNCTION thd_ice_alloc_2
 
 #endif
+   !!======================================================================
 END MODULE thd_ice_2
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/dom_ice.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/dom_ice.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/dom_ice.F90	(revision 2636)
@@ -9,4 +9,5 @@
    USE par_ice        ! LIM-3 parameter
    USE in_out_manager ! I/O manager
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/ice.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/ice.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/ice.F90	(revision 2636)
@@ -13,4 +13,5 @@
    USE par_ice          ! LIM sea-ice parameters
    USE in_out_manager   ! I/O manager
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/iceini.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/iceini.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/iceini.F90	(revision 2636)
@@ -64,5 +64,5 @@
       !
       IF( lk_mpp    )   CALL mpp_sum( ierr )
-      IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'ice_init : unable to allocate ice arrays' )
+      IF( ierr /= 0 )   CALL ctl_stop('STOP', 'ice_init : unable to allocate ice arrays')
       !
       !                                ! adequation jpk versus ice/snow layers/categories
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limadv.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limadv.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limadv.F90	(revision 2636)
@@ -21,4 +21,5 @@
    USE in_out_manager   ! I/O manager
    USE prtctl           ! Print control
+   USE lib_mpp          ! MPP library
 
    IMPLICIT NONE
@@ -75,6 +76,6 @@
 
       IF( wrk_in_use(2, 11,12,13,14,15,16,17,18,19,20,21) ) THEN
-         CALL ctl_stop( 'lim_adv_x : requested workspace arrays unavailable.' )   ;   RETURN
-      END IF
+         CALL ctl_stop('lim_adv_x: requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
 
       ! Limitation of moments.                                           
@@ -223,7 +224,6 @@
       ENDIF
       !
-      IF( wrk_not_released(2, 11,12,13,14,15,16,17,18,19,20,21) ) THEN
-         CALL ctl_stop( 'lim_adv_x : failed to release workspace arrays.' )
-      END IF
+      IF( wrk_not_released(2, 11,12,13,14,15,16,17,18,19,20,21) )    &
+          CALL ctl_stop('lim_adv_x : failed to release workspace arrays')
       !
    END SUBROUTINE lim_adv_x
@@ -263,7 +263,7 @@
       !---------------------------------------------------------------------
 
-      IF(wrk_in_use(2, 11,12,13,14,15,16,17,18,19,20,21) ) THEN
-         CALL ctl_stop( 'lim_adv_y : requested workspace arrays unavailable.' )   ;   RETURN
-      END IF
+      IF( wrk_in_use(2, 11,12,13,14,15,16,17,18,19,20,21) ) THEN
+         CALL ctl_stop('lim_adv_y : requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
 
       ! Limitation of moments.
@@ -413,7 +413,6 @@
       ENDIF
       !
-      IF( wrk_not_released(2, 11,12,13,14,15,16,17,18,19,20,21) ) THEN
-         CALL ctl_stop( 'lim_adv_y : failed to release workspace arrays.' )
-      END IF
+      IF( wrk_not_released(2, 11,12,13,14,15,16,17,18,19,20,21) )    &
+         CALL ctl_stop('lim_adv_y: failed to release workspace arrays')
       !
    END SUBROUTINE lim_adv_y
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limdyn.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limdyn.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limdyn.F90	(revision 2636)
@@ -69,6 +69,6 @@
 
       IF(  wrk_in_use(1, 1,2)  .OR.  wrk_in_use(2, 1,2)  ) THEN
-         CALL ctl_stop( 'lim_dyn : requested workspace arrays unavailable.' )   ;   RETURN
-      END IF
+         CALL ctl_stop('lim_dyn : requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
       zind => wrk_1d_1(1:jpj)      ! Set-up pointers to sub-arrays of workspaces
       zmsk => wrk_1d_2(1:jpj)
@@ -212,7 +212,6 @@
       ENDIF
       !
-      IF(  wrk_not_released(1, 1,2)  .OR.  wrk_not_released(2, 1,2)  ) THEN
-         CALL ctl_stop( 'lim_dyn : failed to release workspace arrays.' )
-      END IF
+      IF( wrk_not_released(1, 1,2) .OR.   &
+          wrk_not_released(2, 1,2)  )   CALL ctl_stop('lim_dyn : failed to release workspace arrays' )
       !
    END SUBROUTINE lim_dyn
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limhdf.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limhdf.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limhdf.F90	(revision 2636)
@@ -63,6 +63,6 @@
       
       IF( wrk_in_use(2, 11,12,13,14,15,16) ) THEN
-         CALL ctl_stop( 'lim_hdf: ERROR: requested workspace arrays unavailable' )   ;   RETURN
-      END IF
+         CALL ctl_stop( 'lim_hdf: requested workspace arrays unavailable' )   ;   RETURN
+      ENDIF
 
       !                       !==  Initialisation  ==!
@@ -146,7 +146,5 @@
       ENDIF
       !
-      IF( wrk_not_released(2, 11,12,13,14,15,16) ) THEN
-         CALL ctl_stop( 'lim_hdf : failed to release workspace arrays.' )   ;   RETURN
-      END IF
+      IF( wrk_not_released(2, 11,12,13,14,15,16) )   CALL ctl_stop('lim_hdf: failed to release workspace arrays')
       !
    END SUBROUTINE lim_hdf
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limistate.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limistate.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limistate.F90	(revision 2636)
@@ -24,4 +24,5 @@
    USE in_out_manager   ! I/O manager
    USE lbclnk           ! lateral boundary condition - MPP exchanges
+   USE lib_mpp          ! MPP library
 
    IMPLICIT NONE
@@ -73,6 +74,6 @@
 
       IF(  wrk_in_use(1, 1,2)  ) THEN
-         CALL ctl_stop( 'lim_istate : requested workspace arrays unavailable.' )   ;   RETURN
-      END IF
+         CALL ctl_stop( 'lim_istate: requested workspace arrays unavailable' )   ;   RETURN
+      ENDIF
       zgfactorn => wrk_1d_1(1:jpm)   ;   zhin => wrk_1d_3(1:jpm)   ! Set-up pointers to sub-arrays of workspaces
       zgfactors => wrk_1d_2(1:jpm)   ;   zhis => wrk_1d_4(1:jpm)
@@ -516,7 +517,5 @@
       CALL lbc_lnk( fsbbq  , 'T', 1. )
       !
-      IF(  wrk_not_released(1, 1,2)  ) THEN
-         CALL ctl_stop( 'lim_istate : failed to release workspace arrays.' )
-      END IF
+      IF( wrk_not_released(1, 1,2) )   CALL ctl_stop('lim_istate : failed to release workspace arrays')
       !
    END SUBROUTINE lim_istate
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limitd_me.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limitd_me.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limitd_me.F90	(revision 2636)
@@ -24,7 +24,7 @@
    USE limcons          ! LIM
    USE in_out_manager   ! I/O manager
-   USE prtctl           ! Print control
    USE lbclnk           ! lateral boundary condition - MPP exchanges
    USE lib_mpp          ! MPP library
+   USE prtctl           ! Print control
    USE wrk_nemo         ! workspace manager
 
@@ -78,11 +78,8 @@
 CONTAINS
 
-   FUNCTION lim_itd_me_alloc()
+   INTEGER FUNCTION lim_itd_me_alloc()
       !!---------------------------------------------------------------------!
       !!                ***  ROUTINE lim_itd_me_alloc ***
       !!---------------------------------------------------------------------!
-      INTEGER :: lim_itd_me_alloc
-      !!---------------------------------------------------------------------!
-      !
       ALLOCATE(                                                                     &
          !* Variables shared among ridging subroutines
@@ -96,8 +93,6 @@
          &      dardg1dt(jpi,jpj)  , dardg2dt(jpi,jpj)                        ,     & 
          &      dvirdgdt(jpi,jpj)  , opening(jpi,jpj)                         , STAT=lim_itd_me_alloc )
-      !
-      IF( lim_itd_me_alloc /= 0 ) THEN
-         CALL ctl_warn( 'lim_itd_me_alloc: failed to allocate arrays.' )
-      END IF
+         !
+      IF( lim_itd_me_alloc /= 0 )   CALL ctl_warn( 'lim_itd_me_alloc: failed to allocate arrays' )
       !
    END FUNCTION lim_itd_me_alloc
@@ -149,6 +144,6 @@
 
       IF( wrk_in_use(2, 1,2,3,4,5,6,7,8) ) THEN
-         CALL ctl_stop(' : requested workspace arrays unavailable.')   ;   RETURN
-      END IF
+         CALL ctl_stop('lim_itd_me: requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
 
       IF( numit == nstart  )   CALL lim_itd_me_init   ! Initialization (first time-step only)
@@ -494,5 +489,5 @@
       END DO
 
-      IF( wrk_not_released(2, 1,2,3,4,5,6,7,8) )   CALL ctl_stop( 'lim_itd_me : failed to release workspace arrays.' )
+      IF( wrk_not_released(2, 1,2,3,4,5,6,7,8) )   CALL ctl_stop('lim_itd_me: failed to release workspace arrays')
       !
    END SUBROUTINE lim_itd_me
@@ -525,6 +520,6 @@
 
       IF( wrk_in_use(2, 1) ) THEN
-         CALL ctl_stop('lim_itd_me_icestrength : requested workspace array unavailable.')   ;   RETURN
-      END IF
+         CALL ctl_stop('lim_itd_me_icestrength : requested workspace array unavailable')   ;   RETURN
+      ENDIF
 
       !------------------------------------------------------------------------------!
@@ -678,11 +673,8 @@
       ENDIF ! ksmooth
 
-      ! Boundary conditions
-      CALL lbc_lnk( strength, 'T', 1. )
-
-      IF(wrk_not_released(2, 1))THEN
-         CALL ctl_stop('lim_itd_me_icestrength : failed to release workspace array.')
-      END IF
-
+      CALL lbc_lnk( strength, 'T', 1. )      ! Boundary conditions
+
+      IF( wrk_not_released(2, 1) )   CALL ctl_stop('lim_itd_me_icestrength: failed to release workspace array')
+      !
    END SUBROUTINE lim_itd_me_icestrength
 
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limmsh.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limmsh.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limmsh.F90	(revision 2636)
@@ -17,4 +17,5 @@
    USE in_out_manager ! I/O manager
    USE lbclnk         ! lateral boundary condition - MPP exchanges
+   USE lib_mpp        ! MPP library
 
    IMPLICIT NONE
@@ -54,5 +55,5 @@
 
       IF( jphgr_msh == 2 .OR. jphgr_msh == 3 .OR. jphgr_msh == 5 )   &
-          &      CALL ctl_stop(' Coriolis parameter in LIM not set for f- or beta-plane' )
+          &      CALL ctl_stop(' Coriolis parameter in LIM not set for f- or beta-plane')
 
       !                           !==  coriolis factor & Equator position ==!
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limrst.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limrst.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limrst.F90	(revision 2636)
@@ -23,4 +23,5 @@
    USE in_out_manager   ! I/O manager
    USE iom              ! I/O library
+   USE lib_mpp          ! MPP library
 
    IMPLICIT NONE
@@ -103,5 +104,5 @@
 
       IF( wrk_in_use(2, 1) ) THEN
-         CALL ctl_stop( 'lim_rst_write : requested workspace arrays unavailable.' )   ;   RETURN
+         CALL ctl_stop( 'lim_rst_write : requested workspace arrays unavailable' )   ;   RETURN
       END IF
 
@@ -294,7 +295,5 @@
       ENDIF
       !
-      IF( wrk_not_released(2, 1) ) THEN
-         CALL ctl_stop( 'lim_rst_write : failed to release workspace arrays.' )
-      END IF
+      IF( wrk_not_released(2, 1) )   CALL ctl_stop( 'lim_rst_write : failed to release workspace arrays' )
       !
    END SUBROUTINE lim_rst_write
@@ -322,5 +321,5 @@
       IF( wrk_in_use(2, 1) ) THEN
          CALL ctl_stop( 'lim_rst_read : requested workspace arrays unavailable.' )   ;   RETURN
-      END IF
+      ENDIF
 
       IF(lwp) THEN
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limsbc.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limsbc.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limsbc.F90	(revision 2636)
@@ -30,4 +30,5 @@
    USE lbclnk           ! ocean lateral boundary condition
    USE in_out_manager   ! I/O manager
+   USE lib_mpp          ! MPP library
    USE prtctl           ! Print control
    USE cpl_oasis3, ONLY : lk_cpl
@@ -58,17 +59,13 @@
 CONTAINS
 
-   FUNCTION lim_sbc_alloc()
+   INTEGER FUNCTION lim_sbc_alloc()
       !!-------------------------------------------------------------------
       !!             ***  ROUTINE lim_sbc_alloc ***
       !!-------------------------------------------------------------------
-      INTEGER :: lim_sbc_alloc   ! return value
-      !!-------------------------------------------------------------------
-      !
       ALLOCATE( soce_0(jpi,jpj) , utau_oce(jpi,jpj) ,                       &
          &      sice_0(jpi,jpj) , vtau_oce(jpi,jpj) , tmod_io(jpi,jpj), STAT=lim_sbc_alloc)
          !
       IF( lk_mpp             )   CALL mpp_sum( lim_sbc_alloc )
-      IF( lim_sbc_alloc /= 0 )   CALL ctl_warn('lim_sbc_alloc: failed to allocate arrays.')
-      !
+      IF( lim_sbc_alloc /= 0 )   CALL ctl_warn('lim_sbc_alloc: failed to allocate arrays')
    END FUNCTION lim_sbc_alloc
 
@@ -112,5 +109,5 @@
 
       IF( wrk_in_use(2, 1,2) .OR. wrk_in_use(3, 4,5) ) THEN
-         CALL ctl_stop( 'lim_sbc_flx : requested workspace arrays unavailable.' )   ;   RETURN
+         CALL ctl_stop( 'lim_sbc_flx : requested workspace arrays unavailable' )   ;   RETURN
       ENDIF
       ! Set-up pointers to sub-arrays of 3d workspaces
@@ -300,7 +297,7 @@
       ENDIF
       !
-      IF(  wrk_not_released(2, 1,2)  .OR.  wrk_not_released(3, 4,5)  ) THEN
-         CALL ctl_stop( 'lim_sbc_flx : failed to release workspace arrays.' )
-      END IF
+      IF( wrk_not_released(2, 1,2)    .OR.   &
+          wrk_not_released(3, 4,5)  )        &
+          CALL ctl_stop( 'lim_sbc_flx: failed to release workspace arrays' )
       ! 
    END SUBROUTINE lim_sbc_flx
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limthd.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limthd.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limthd.F90	(revision 2636)
@@ -458,5 +458,5 @@
       ENDIF
       !
-      IF( wrk_not_released(2, 1) )   CALL ctl_stop( 'lim_thd : failed to release workspace arrays' )
+      IF( wrk_not_released(2, 1) )   CALL ctl_stop( 'lim_thd: failed to release workspace arrays' )
       !
    END SUBROUTINE lim_thd
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limthd_dh.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limthd_dh.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limthd_dh.F90	(revision 2636)
@@ -103,6 +103,6 @@
 
       IF( wrk_in_use(1, 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22) ) THEN
-         CALL ctl_stop('lim_thd_dh : requestead workspace arrays unavailable.')   ;   RETURN
-      END IF
+         CALL ctl_stop('lim_thd_dh: requestead workspace arrays unavailable')   ;   RETURN
+      ENDIF
       ! Set-up pointers to sub-arrays of workspace arrays
       zh_i        => wrk_1d_1 (1:jpij)   ! ice layer thickness
@@ -700,5 +700,5 @@
       !
       IF( wrk_not_released(1, 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21) )   &
-         &     CALL ctl_stop('lim_thd_dh : failed to release workspace arrays.')
+          CALL ctl_stop('lim_thd_dh : failed to release workspace arrays')
       !
    END SUBROUTINE lim_thd_dh
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limthd_ent.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limthd_ent.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limthd_ent.F90	(revision 2636)
@@ -122,5 +122,5 @@
 
       IF( wrk_in_use(1, 1,2,3,4,5,6,7,8) ) THEN
-         CALL ctl_stop('lim_thd_dh : requestead workspace arrays unavailable.')   ;   RETURN
+         CALL ctl_stop('lim_thd_dh : requestead workspace arrays unavailable')   ;   RETURN
       END IF
 
@@ -687,5 +687,5 @@
       END DO !jk
       !
-      IF( wrk_not_released(1, 1,2,3,4,5,6,7,8) )   CALL ctl_stop( 'lim_thd_ent : failed to release workspace arrays.' )
+      IF( wrk_not_released(1, 1,2,3,4,5,6,7,8) )   CALL ctl_stop( 'lim_thd_ent : failed to release workspace arrays' )
       !
    END SUBROUTINE lim_thd_ent
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limthd_lac.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limthd_lac.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limthd_lac.F90	(revision 2636)
@@ -28,4 +28,5 @@
    USE wrk_nemo         ! workspace manager
    USE in_out_manager   ! I/O manager
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
@@ -690,6 +691,6 @@
       !
       IF( wrk_not_released(1, 1,2,3,4,5,6,7,8,9,10,11,12,13,14) .OR.     &
-         &wrk_not_released(2, 1,2,3,4,5,6,7,8)                       )   &
-         &      CALL ctl_stop( 'lim_thd_lac : failed to release workspace arrays.' )
+          wrk_not_released(2, 1,2,3,4,5,6,7,8)                       )   &
+          CALL ctl_stop( 'lim_thd_lac : failed to release workspace arrays' )
       !
    END SUBROUTINE lim_thd_lac
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limthd_sal.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limthd_sal.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limthd_sal.F90	(revision 2636)
@@ -23,4 +23,5 @@
    USE wrk_nemo         ! workspace manager
    USE in_out_manager   ! I/O manager
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
@@ -237,5 +238,5 @@
       ENDIF
       !
-      IF( wrk_not_released(1, 1,2,3) )   CALL ctl_stop( 'lim_thd_lac : failed to release workspace arrays.' )
+      IF( wrk_not_released(1, 1,2,3) )   CALL ctl_stop( 'lim_thd_lac : failed to release workspace arrays' )
       !
    END SUBROUTINE lim_thd_sal
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limtrp.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limtrp.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limtrp.F90	(revision 2636)
@@ -80,6 +80,6 @@
       !!---------------------------------------------------------------------
 
-      IF( wrk_in_use( 2, 1,2,3,4,5 ) ) THEN
-         CALL ctl_stop( 'lim_trp : requested workspace arrays unavailable.' )   ;   RETURN
+      IF( wrk_in_use(2, 1,2,3,4,5) ) THEN
+         CALL ctl_stop( 'lim_trp : requested workspace arrays unavailable' )   ;   RETURN
       END IF
 
@@ -463,5 +463,5 @@
       ENDIF
       !
-      IF( wrk_not_released( 2, 1,2,3,4,5 ) )   CALL ctl_stop('lim_trp_2 : failed to release workspace arrays.')
+      IF( wrk_not_released(2, 1,2,3,4,5) )   CALL ctl_stop('lim_trp_2 : failed to release workspace arrays')
       !
    END SUBROUTINE lim_trp
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limvar.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limvar.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limvar.F90	(revision 2636)
@@ -52,4 +52,5 @@
    USE wrk_nemo         ! workspace manager
    USE in_out_manager   ! I/O manager
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
@@ -305,5 +306,5 @@
 
       IF( wrk_in_use( 2, 1,2 ) ) THEN
-         CALL ctl_stop( 'lim_var_salprof : requested workspace arrays unavailable.' )   ;   RETURN
+         CALL ctl_stop( 'lim_var_salprof: requested workspace arrays unavailable' )   ;   RETURN
       END IF
 
@@ -388,5 +389,5 @@
       ENDIF ! num_sal
       !
-      IF( wrk_not_released( 2, 1,2 ) )   CALL ctl_stop('lim_var_salprof : failed to release workspace arrays.')
+      IF( wrk_not_released(2, 1,2) )   CALL ctl_stop('lim_var_salprof: failed to release workspace arrays.')
       !
    END SUBROUTINE lim_var_salprof
@@ -510,5 +511,5 @@
       ENDIF
       !
-      IF( wrk_not_released(1, 1) )   CALL ctl_stop( 'lim_var_salprof1d : failed to release workspace arrays.' )
+      IF( wrk_not_released(1, 1) )   CALL ctl_stop( 'lim_var_salprof1d : failed to release workspace arrays' )
       !
    END SUBROUTINE lim_var_salprof1d
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limwri.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limwri.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limwri.F90	(revision 2636)
@@ -15,12 +15,13 @@
    USE phycst
    USE dom_oce
-   USE in_out_manager
    USE sbc_oce         ! Surface boundary condition: ocean fields
    USE sbc_ice         ! Surface boundary condition: ice fields
    USE dom_ice
    USE ice
+   USE limvar
+   USE in_out_manager
    USE lbclnk
+   USE lib_mpp         ! MPP library
    USE par_ice
-   USE limvar
 
    IMPLICIT NONE
@@ -70,7 +71,7 @@
       !!  modif : 03/06/98
       !!-------------------------------------------------------------------
-      USE wrk_nemo, ONLY: wrk_not_released, wrk_in_use
-      USE wrk_nemo, ONLY: zfield => wrk_2d_1             ! 2D workspace
-      USE wrk_nemo, ONLY: wrk_3d_1, wrk_3D_2, wrk_3d_3   ! 3D workspace
+      USE wrk_nemo, ONLY:   wrk_not_released, wrk_in_use
+      USE wrk_nemo, ONLY:   zfield => wrk_2d_1             ! 2D workspace
+      USE wrk_nemo, ONLY:   wrk_3d_1, wrk_3D_2, wrk_3d_3   ! 3D workspace
       !
       INTEGER, INTENT(in) ::   kindic   ! if kindic < 0 there has been an error somewhere
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/thd_ice.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/thd_ice.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/thd_ice.F90	(revision 2636)
@@ -8,4 +8,5 @@
    USE par_ice        ! LIM-3 parameters
    USE in_out_manager ! I/O manager
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
@@ -195,7 +196,5 @@
       thd_ice_alloc = MAXVAL( ierr )
 
-      IF( thd_ice_alloc /= 0 ) THEN
-         CALL ctl_warn( 'thd_ice_alloc: failed to allocate arrays.' )
-      END IF
+      IF( thd_ice_alloc /= 0 )   CALL ctl_warn( 'thd_ice_alloc: failed to allocate arrays.' )
       !
    END FUNCTION thd_ice_alloc
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/ASM/asminc.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/ASM/asminc.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/ASM/asminc.F90	(revision 2636)
@@ -21,5 +21,4 @@
    !!   ssh_asm_inc  : Apply the SSH increment
    !!----------------------------------------------------------------------
-   USE in_out_manager   ! I/O manager
    USE par_oce          ! Ocean space and time domain variables
    USE dom_oce          ! Ocean space and time domain
@@ -31,4 +30,6 @@
    USE asmpar           ! Parameters for the assmilation interface
    USE c1d              ! 1D initialization
+   USE in_out_manager   ! I/O manager
+   USE lib_mpp           ! MPP library
 
    IMPLICIT NONE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DOM/domngb.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DOM/domngb.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DOM/domngb.F90	(revision 2636)
@@ -21,7 +21,6 @@
    !! NEMO/OPA 3.3 , NEMO Consortium (2010)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-
 CONTAINS
 
@@ -36,5 +35,4 @@
       !!
       !!----------------------------------------------------------------------
-      USE in_out_manager, ONLY: ctl_stop
       USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
       USE wrk_nemo, ONLY: zglam => wrk_2d_2, &
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DOM/domstp.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DOM/domstp.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DOM/domstp.F90	(revision 2636)
@@ -8,19 +8,17 @@
    !!   dom_stp        : ocean time domain initialization
    !!----------------------------------------------------------------------
-   !! History :
-   !!        !  90-10  (O. Marti)  Original code
-   !!        !  96-01  (G. Madec)  terrain following coordinates
-   !!   8.5  !  02-08  (G. Madec)  F90: Free form and module
+   !! History :  OPA  ! 1990-10  (O. Marti)  Original code
+   !!                 ! 1996-01  (G. Madec)  terrain following coordinates
+   !!   NEMO     1.0  ! 2002-08  (G. Madec)  F90: Free form and module
    !!----------------------------------------------------------------------
-   !! * Modules used
-   USE oce             ! ocean dynamics and tracers
-   USE dom_oce         ! ocean space and time domain
-   USE in_out_manager  ! I/O manager
+   USE oce            ! ocean dynamics and tracers
+   USE dom_oce        ! ocean space and time domain
+   USE in_out_manager ! I/O manager
+   USE lib_mpp        ! MPP library
 
    IMPLICIT NONE
    PRIVATE
 
-   !! * routine accessibility
-   PUBLIC dom_stp        ! routine called by inidom.F90
+   PUBLIC   dom_stp   ! routine called by inidom.F90
 
    !! * Substitutions
@@ -29,7 +27,6 @@
    !! NEMO/OPA 3.3 , NEMO Consortium (2010)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-
 CONTAINS
 
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DOM/istate.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DOM/istate.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DOM/istate.F90	(revision 2636)
@@ -43,5 +43,6 @@
    USE dynspg_ts       ! pressure gradient schemes
    USE traswp          ! Swap arrays                      (tra_swp routine)
-   
+   USE lib_mpp         ! MPP library
+
    IMPLICIT NONE
    PRIVATE
@@ -55,7 +56,6 @@
    !! NEMO/OPA 3.3 , NEMO Consortium (2010)
    !! $Id$
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-
 CONTAINS
 
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DTA/dtasal.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DTA/dtasal.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DTA/dtasal.F90	(revision 2636)
@@ -18,7 +18,8 @@
    USE oce             ! ocean dynamics and tracers
    USE dom_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
    USE fldread         ! read input fields
    USE in_out_manager  ! I/O manager
-   USE phycst          ! physical constants
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DTA/dtatem.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DTA/dtatem.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DTA/dtatem.F90	(revision 2636)
@@ -18,7 +18,8 @@
    USE oce             ! ocean dynamics and tracers
    USE dom_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
    USE fldread         ! read input fields
    USE in_out_manager  ! I/O manager
-   USE phycst          ! physical constants
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/divcur.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/divcur.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/divcur.F90	(revision 2636)
@@ -31,4 +31,5 @@
    USE in_out_manager  ! I/O manager
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynadv.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynadv.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynadv.F90	(revision 2636)
@@ -14,4 +14,5 @@
    USE dom_oce         ! ocean space and time domain
    USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! MPP library
 
    USE dynadv_cen2     ! centred flux form advection      (dyn_adv_cen2 routine)
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynadv_cen2.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynadv_cen2.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynadv_cen2.F90	(revision 2636)
@@ -18,4 +18,5 @@
    USE trdmod         ! ocean dynamics trends
    USE in_out_manager ! I/O manager
+   USE lib_mpp         ! MPP library
    USE prtctl         ! Print control
 
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynadv_ubs.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynadv_ubs.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynadv_ubs.F90	(revision 2636)
@@ -16,9 +16,10 @@
    USE oce            ! ocean dynamics and tracers
    USE dom_oce        ! ocean space and time domain
-   USE in_out_manager ! I/O manager
-   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
    USE trdmod         ! ocean dynamics trends
    USE trdmod_oce     ! ocean variables trends
+   USE in_out_manager ! I/O manager
    USE prtctl         ! Print control
+   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp        ! MPP library
 
    IMPLICIT NONE
@@ -92,5 +93,5 @@
       IF( wrk_in_use(3, 1,2,3,4,5,6,7) .OR. wrk_in_use(4, 1,2,3,4) ) THEN
          CALL ctl_stop('dyn_adv_ubs : requested workspace array unavailable')   ;   RETURN
-      END IF
+      ENDIF
 
       zfu_t(:,:,:) = 0._wp
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynhpg.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynhpg.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynhpg.F90	(revision 2636)
@@ -36,4 +36,5 @@
    USE prtctl          ! Print control
    USE lbclnk          ! lateral boundary condition 
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
@@ -80,10 +81,9 @@
       !!
       INTEGER, INTENT(in) ::   kt   ! ocean time-step index
-      !!
-      !!----------------------------------------------------------------------
-      !
-      IF(wrk_in_use(3, 1,2) ) THEN
+      !!----------------------------------------------------------------------
+      !
+      IF( wrk_in_use(3, 1,2) ) THEN
          CALL ctl_stop('dyn_hpg: requested workspace arrays are unavailable')   ;   RETURN
-      END IF
+      ENDIF
       !
       IF( l_trddyn ) THEN                    ! Temporary saving of ua and va trends (l_trddyn)
@@ -111,5 +111,5 @@
          &                       tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
       !
-      IF(wrk_not_released(3, 1,2) )   CALL ctl_stop('dyn_hpg: failed to release workspace arrays')
+      IF( wrk_not_released(3, 1,2) )   CALL ctl_stop('dyn_hpg: failed to release workspace arrays')
       !
    END SUBROUTINE dyn_hpg
@@ -152,5 +152,5 @@
       !
       IF( lk_vvl .AND. .NOT. ln_hpg_sco )   &
-         &   CALL ctl_stop( 'dyn_hpg_init : variable volume key_vvl require the standard jacobian formulation hpg_sco')
+         &   CALL ctl_stop('dyn_hpg_init : variable volume key_vvl require the standard jacobian formulation hpg_sco')
       !
       !                               ! Set nhpg from ln_hpg_... flags
@@ -172,5 +172,5 @@
       IF( ln_hpg_djc )   ioptio = ioptio + 1
       IF( ln_hpg_rot )   ioptio = ioptio + 1
-      IF ( ioptio /= 1 )   CALL ctl_stop( ' NO or several hydrostatic pressure gradient options used' )
+      IF( ioptio /= 1 )   CALL ctl_stop( 'NO or several hydrostatic pressure gradient options used' )
       !
    END SUBROUTINE dyn_hpg_init
@@ -619,7 +619,7 @@
       !!----------------------------------------------------------------------
 
-      IF(wrk_in_use(3, 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15) ) THEN
+      IF( wrk_in_use(3, 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15) ) THEN
          CALL ctl_stop('dyn:hpg_djc : requested workspace arrays unavailable')   ;   RETURN
-      END IF
+      ENDIF
 
       IF( kt == nit000 ) THEN
@@ -819,6 +819,6 @@
       END DO
       !
-      IF(wrk_not_released(3, 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15) )   &
-         CALL ctl_stop('dyn:hpg_djc : failed to release workspace arrays.')
+      IF( wrk_not_released(3, 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15) )   &
+         CALL ctl_stop('dyn:hpg_djc : failed to release workspace arrays')
       !
    END SUBROUTINE hpg_djc
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynkeg.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynkeg.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynkeg.F90	(revision 2636)
@@ -14,7 +14,8 @@
    USE oce             ! ocean dynamics and tracers
    USE dom_oce         ! ocean space and time domain
-   USE in_out_manager  ! I/O manager
    USE trdmod          ! ocean dynamics trends 
    USE trdmod_oce      ! ocean variables trends
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! MPP library
    USE prtctl          ! Print control
 
@@ -61,6 +62,6 @@
       !!----------------------------------------------------------------------
 
-      IF(wrk_in_use(3,1) ) THEN
-         CALL ctl_stop('dyn_key: requested workspace array is unavailable.')   ;   RETURN
+      IF( wrk_in_use(3,1) ) THEN
+         CALL ctl_stop('dyn_key: requested workspace array is unavailable')   ;   RETURN
       ENDIF
 
@@ -135,5 +136,5 @@
          &                       tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
       !
-      IF(wrk_not_released(3, 1) )   CALL ctl_stop('dyn_key: failed to release workspace array')
+      IF( wrk_not_released(3, 1) )   CALL ctl_stop('dyn_key: failed to release workspace array')
       !
    END SUBROUTINE dyn_keg
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf.F90	(revision 2636)
@@ -41,7 +41,6 @@
    !! NEMO/OPA 3.3 , NEMO Consortium (2010)
    !! $Id$
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
 CONTAINS
 
@@ -58,8 +57,7 @@
       !!----------------------------------------------------------------------
 
-      IF(wrk_in_use(3, 1,2))THEN
-         CALL ctl_stop('dyn_ldf: requested workspace arrays unavailable.')
-         RETURN
-      END IF
+      IF( wrk_in_use(3, 1,2) ) THEN
+         CALL ctl_stop('dyn_ldf: requested workspace arrays unavailable.')   ;   RETURN
+      ENDIF
       !
       IF( l_trddyn )   THEN                      ! temporary save of ta and sa trends
@@ -112,7 +110,5 @@
          &                       tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
       !
-      IF(wrk_not_released(3, 1,2))THEN
-         CALL ctl_stop('dyn_ldf: failed to release workspace arrays.')
-      END IF
+      IF( wrk_not_released(3, 1,2) )   CALL ctl_stop('dyn_ldf: failed to release workspace arrays.')
       !
    END SUBROUTINE dyn_ldf
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf_bilap.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf_bilap.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf_bilap.F90	(revision 2636)
@@ -27,6 +27,5 @@
    PRIVATE
 
-   !! * Routine accessibility
-   PUBLIC dyn_ldf_bilap  ! called by step.F90
+   PUBLIC   dyn_ldf_bilap   ! called by step.F90
 
    !! * Substitutions
@@ -75,8 +74,8 @@
       !!               mixing trend.
       !!----------------------------------------------------------------------
-      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
-      USE wrk_nemo, ONLY: zcu => wrk_2d_1, zcv => wrk_2d_2   ! 3D workspace
-      USE wrk_nemo, ONLY: zuf => wrk_3d_1, zut => wrk_3d_2   ! 3D workspace
-      USE wrk_nemo, ONLY: zlu => wrk_3d_3, zlv => wrk_3d_4
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY:   zcu => wrk_2d_1, zcv => wrk_2d_2   ! 3D workspace
+      USE wrk_nemo, ONLY:   zuf => wrk_3d_1, zut => wrk_3d_2   ! 3D workspace
+      USE wrk_nemo, ONLY:   zlu => wrk_3d_3, zlv => wrk_3d_4
       !
       INTEGER, INTENT(in) ::   kt   ! ocean time-step index
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf_bilapg.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf_bilapg.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf_bilapg.F90	(revision 2636)
@@ -24,4 +24,5 @@
    USE trdmod_oce      ! ocean variables trends
    USE ldfslp          ! iso-neutral slopes available
+   USE lib_mpp         ! MPP library
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
    USE prtctl          ! Print control
@@ -41,7 +42,6 @@
    !! NEMO/OPA 3.3 , NEMO Consortium (2010)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
 CONTAINS
 
@@ -50,10 +50,8 @@
       !!               ***  ROUTINE dyn_ldf_bilapg_alloc  ***
       !!----------------------------------------------------------------------
-      !
       ALLOCATE( zfuw(jpi,jpk) , zfvw (jpi,jpk) , zdiu(jpi,jpk) , zdiv (jpi,jpk) ,     &
          &      zdju(jpi,jpk) , zdj1u(jpi,jpk) , zdjv(jpi,jpk) , zdj1v(jpi,jpk) , STAT=dyn_ldf_bilapg_alloc)
          !
       IF( dyn_ldf_bilapg_alloc /= 0 )   CALL ctl_warn('dyn_ldf_bilapg_alloc: failed to allocate arrays')
-      !
    END FUNCTION dyn_ldf_bilapg_alloc
 
@@ -96,6 +94,6 @@
 
       IF( wrk_in_use(3, 1,2) ) THEN
-         CALL ctl_stop('dyn_ldf_bilapg: requested workspace arrays unavailable.')   ;   RETURN
-      END IF
+         CALL ctl_stop('dyn_ldf_bilapg: requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
 
       IF( kt == nit000 ) THEN
@@ -454,7 +452,5 @@
       !                                                ! ===============
 
-      IF(wrk_not_released(2, 1,2,3,4,5,6,7,8))THEN
-         CALL ctl_stop('dyn:ldfguv : failed to release workspace arrays.')
-      END IF
+      IF( wrk_not_released(2, 1,2,3,4,5,6,7,8) )   CALL ctl_stop('dyn:ldfguv : failed to release workspace arrays')
       !
    END SUBROUTINE ldfguv
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf_iso.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf_iso.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf_iso.F90	(revision 2636)
@@ -27,4 +27,5 @@
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
    USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! MPP library
    USE prtctl          ! Print control
 
@@ -53,10 +54,8 @@
       !!                  ***  ROUTINE dyn_ldf_iso_alloc  ***
       !!----------------------------------------------------------------------
-      !
       ALLOCATE( zfuw(jpi,jpk) , zdiu(jpi,jpk) , zdju(jpi,jpk) , zdj1u(jpi,jpk) ,     & 
          &      zfvw(jpi,jpk) , zdiv(jpi,jpk) , zdjv(jpi,jpk) , zdj1v(jpi,jpk) , STAT=dyn_ldf_iso_alloc)
          !
       IF( dyn_ldf_iso_alloc /= 0 )   CALL ctl_warn('dyn_ldf_iso_alloc: array allocate failed.')
-      !
    END FUNCTION dyn_ldf_iso_alloc
 
@@ -121,5 +120,5 @@
 
       IF( wrk_in_use(2, 1,2,3,4,5,6,7,8) ) THEN
-         CALL ctl_stop('dyn_ldf_iso: requested workspace arrays unavailable.')   ;   RETURN
+         CALL ctl_stop('dyn_ldf_iso: requested workspace arrays unavailable')   ;   RETURN
       END IF
 
@@ -429,8 +428,6 @@
       !                                                ! ===============
 
-      IF( wrk_not_released(2, 1,2,3,4,5,6,7,8))THEN
-         CALL ctl_stop('dyn_ldf_iso: failed to release workspace arrays.')
-      END IF
-
+      IF( wrk_not_released(2, 1,2,3,4,5,6,7,8) )   CALL ctl_stop('dyn_ldf_iso: failed to release workspace arrays')
+      !
    END SUBROUTINE dyn_ldf_iso
 
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynnxt.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynnxt.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynnxt.F90	(revision 2636)
@@ -37,4 +37,5 @@
    USE in_out_manager  ! I/O manager
    USE lbclnk          ! lateral boundary condition (or mpp link)
+   USE lib_mpp         ! MPP library
    USE prtctl          ! Print control
 #if defined key_agrif
@@ -110,8 +111,7 @@
       !!----------------------------------------------------------------------
 
-      IF(wrk_in_use(2, 1,2,3))THEN
-         CALL ctl_stop('dyn_nxt: requested workspace arrays unavailable.')
-         RETURN
-      END IF
+      IF( wrk_in_use(2, 1,2,3) ) THEN
+         CALL ctl_stop('dyn_nxt: requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
 
       IF( kt == nit000 ) THEN
@@ -325,7 +325,5 @@
          &                       tab3d_2=vn, clinfo2=' Vn: '       , mask2=vmask )
       ! 
-      IF(wrk_not_released(2, 1,2,3))THEN
-         CALL ctl_stop('dyn_nxt: failed to release workspace arrays.')
-      END IF
+      IF( wrk_not_released(2, 1,2,3) )   CALL ctl_stop('dyn_nxt: failed to release workspace arrays.')
       !
    END SUBROUTINE dyn_nxt
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg.F90	(revision 2636)
@@ -14,4 +14,5 @@
    USE oce            ! ocean dynamics and tracers variables
    USE dom_oce        ! ocean space and time domain variables
+   USE phycst         ! physical constants
    USE obc_oce        ! ocean open boundary conditions
    USE sbc_oce        ! surface boundary condition: ocean
@@ -26,5 +27,5 @@
    USE prtctl         ! Print control                     (prt_ctl routine)
    USE in_out_manager ! I/O manager
-   USE phycst         ! physical constants
+   USE lib_mpp        ! MPP library
 
    IMPLICIT NONE
@@ -42,7 +43,6 @@
    !! NEMO/OPA 3.2 , LODYC-IPSL  (2009)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
 CONTAINS
 
@@ -83,8 +83,7 @@
       !!----------------------------------------------------------------------
 
-      IF(wrk_in_use(3, 4,5))THEN
-         CALL ctl_stop('dyn_spg: requested workspace arrays unavailable.')
-         RETURN
-      END IF
+      IF( wrk_in_use(3, 4,5) ) THEN
+         CALL ctl_stop('dyn_spg: requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
 
 !!gm NOTA BENE : the dynspg_exp and dynspg_ts should be modified so that 
@@ -154,7 +153,5 @@
          &                       tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
       !
-      IF(wrk_not_released(3, 4,5))THEN
-         CALL ctl_stop('dyn_spg: failed to release workspace arrays.')
-      END IF
+      IF( wrk_not_released(3, 4,5) )   CALL ctl_stop('dyn_spg: failed to release workspace arrays')
       !
    END SUBROUTINE dyn_spg
@@ -181,5 +178,5 @@
 
       !                        ! allocate dyn_spg arrays
-      IF( lk_dynspg_ts  .AND. dyn_spg_ts_alloc () /= 0 )   CALL ctl_stop('STOP', 'dyn_spg_init: failed to allocate ts  arrays')
+      IF( lk_dynspg_ts .AND.dyn_spg_ts_alloc() /= 0 )   CALL ctl_stop('STOP', 'dyn_spg_init: failed to allocate ts  arrays')
 
       !                        ! Control of surface pressure gradient scheme options
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_ts.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_ts.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_ts.F90	(revision 2636)
@@ -132,7 +132,7 @@
       !!----------------------------------------------------------------------
 
-      IF(wrk_in_use(2,  1, 2, 3, 4, 5, 6, 7, 8, 9,10,         &
-                          11,12,13,14,15,16,17,18,19,20,21 ) ) THEN
-         CALL ctl_stop( 'dyn_spg_ts: requested workspace arrays unavailable.' )   ;   RETURN
+      IF( wrk_in_use(2,  1, 2, 3, 4, 5, 6, 7, 8, 9,10,        &
+         &              11,12,13,14,15,16,17,18,19,20,21 ) ) THEN
+         CALL ctl_stop( 'dyn_spg_ts: requested workspace arrays unavailable' )   ;   RETURN
       END IF
 
@@ -569,8 +569,7 @@
       !
       !
-      IF(wrk_not_released(2,  1, 2, 3, 4, 5, 6, 7, 8, 9,10,         &
-                              11,12,13,14,15,16,17,18,19,20,21))THEN
+      IF( wrk_not_released(2,  1, 2, 3, 4, 5, 6, 7, 8, 9,10,         &
+         &                    11,12,13,14,15,16,17,18,19,20,21) )    &
          CALL ctl_stop('dyn_spg_ts: failed to release workspace arrays.')
-      END IF
       !
    END SUBROUTINE dyn_spg_ts
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynvor.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynvor.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynvor.F90	(revision 2636)
@@ -33,4 +33,5 @@
    USE prtctl         ! Print control
    USE in_out_manager ! I/O manager
+   USE lib_mpp
 
    IMPLICIT NONE
@@ -218,8 +219,7 @@
       !!----------------------------------------------------------------------
 
-      IF(wrk_in_use(2, 1,2,3))THEN
-         CALL ctl_stop('dyn:vor_ene: requested workspace arrays unavailable.')
-         RETURN
-      END IF
+      IF( wrk_in_use(2, 1,2,3) ) THEN
+         CALL ctl_stop('dyn:vor_ene: requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
 
       IF( kt == nit000 ) THEN
@@ -286,7 +286,5 @@
       END DO                                           !   End of slab
       !                                                ! ===============
-      IF(wrk_not_released(2, 1,2,3))THEN
-         CALL ctl_stop('dyn:vor_ene: failed to release workspace arrays.')
-      END IF
+      IF( wrk_not_released(2, 1,2,3) )   CALL ctl_stop('dyn:vor_ene: failed to release workspace arrays.')
       !
    END SUBROUTINE vor_ene
@@ -335,8 +333,7 @@
       !!----------------------------------------------------------------------
 
-      IF(wrk_in_use(2, 4,5,6,7))THEN
-         CALL ctl_stop('dyn:vor_mix: requested workspace arrays unavailable.')
-         RETURN
-      END IF
+      IF( wrk_in_use(2, 4,5,6,7) ) THEN
+         CALL ctl_stop('dyn:vor_mix: requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
 
       IF( kt == nit000 ) THEN
@@ -410,7 +407,5 @@
       END DO                                           !   End of slab
       !                                                ! ===============
-      IF(wrk_not_released(2, 4,5,6,7))THEN
-         CALL ctl_stop('dyn:vor_mix: failed to release workspace arrays.')
-      END IF
+      IF( wrk_not_released(2, 4,5,6,7) )   CALL ctl_stop('dyn:vor_mix: failed to release workspace arrays')
       !
    END SUBROUTINE vor_mix
@@ -456,7 +451,6 @@
       !!----------------------------------------------------------------------
       
-      IF(wrk_in_use(2, 4,5,6))THEN
-         CALL ctl_stop('dyn:vor_ens : requested workspace arrays unavailable.')
-         RETURN
+      IF( wrk_in_use(2, 4,5,6) ) THEN
+         CALL ctl_stop('dyn:vor_ens : requested workspace arrays unavailable')   ;   RETURN
       END IF
 
@@ -532,7 +526,5 @@
       END DO                                           !   End of slab
       !                                                ! ===============
-      IF(wrk_not_released(2, 4,5,6))THEN
-         CALL ctl_stop('dyn:vor_ens : failed to release workspace arrays.')
-      END IF
+      IF( wrk_not_released(2, 4,5,6) )   CALL ctl_stop('dyn:vor_ens : failed to release workspace arrays')
       !
    END SUBROUTINE vor_ens
@@ -580,7 +572,7 @@
       !!----------------------------------------------------------------------
 
-      IF(wrk_in_use(2, 1,2,3,4,5,6,7) .OR. wrk_in_use(3, 1) ) THEN
+      IF( wrk_in_use(2, 1,2,3,4,5,6,7) .OR. wrk_in_use(3, 1) ) THEN
          CALL ctl_stop('dyn:vor_een : requested workspace arrays unavailable.')   ;   RETURN
-      END IF
+      ENDIF
 
       IF( kt == nit000 ) THEN
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynzad.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynzad.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynzad.F90	(revision 2636)
@@ -20,4 +20,5 @@
    USE trdmod         ! ocean dynamics trends 
    USE in_out_manager ! I/O manager
+   USE lib_mpp         ! MPP library
    USE prtctl         ! Print control
 
@@ -66,8 +67,7 @@
       !!----------------------------------------------------------------------
       
-      IF( wrk_in_use(2, 1)  .OR.    &
-          wrk_in_use(3, 1,2) )THEN
-         CALL ctl_stop('dyn_zad: requested workspace arrays unavailable.')
-         RETURN
+      IF( wrk_in_use(2, 1)     .OR.    &
+          wrk_in_use(3, 1,2) ) THEN
+         CALL ctl_stop('dyn_zad: requested workspace arrays unavailable')   ;   RETURN
       END IF
 
@@ -126,9 +126,7 @@
          &                       tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
       !
-      IF( wrk_not_released(2, 1)  .OR.    &
-          wrk_not_released(3, 1,2) )THEN
-         CALL ctl_stop('dyn_zad: failed to release workspace arrays.')
-      END IF
-
+      IF( wrk_not_released(2, 1)       .OR.    &
+          wrk_not_released(3, 1,2) )   CALL ctl_stop('dyn_zad: failed to release workspace arrays')
+      !
    END SUBROUTINE dyn_zad
 
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynzdf.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynzdf.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynzdf.F90	(revision 2636)
@@ -23,4 +23,5 @@
    USE trdmod_oce      ! ocean variables trends
    USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! MPP library
    USE prtctl          ! Print control
 
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynzdf_exp.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynzdf_exp.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynzdf_exp.F90	(revision 2636)
@@ -19,5 +19,7 @@
    USE zdf_oce         ! ocean vertical physics
    USE sbc_oce         ! surface boundary condition: ocean
+   USE lib_mpp         ! MPP library
    USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
@@ -63,8 +65,7 @@
       !!----------------------------------------------------------------------
 
-      IF( wrk_in_use(3, 1,2) )THEN
-         CALL ctl_stop('dyn_zdf_exp : requested workspace arrays unavailable.')
-         RETURN
-      END IF
+      IF( wrk_in_use(3, 1,2) ) THEN
+         CALL ctl_stop('dyn_zdf_exp: requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
 
       IF( kt == nit000 .AND. lwp ) THEN
@@ -119,7 +120,5 @@
       END DO                           ! End of time splitting
       !
-      IF( wrk_not_released(3, 1,2) )THEN
-         CALL ctl_stop('dyn_zdf_exp : failed to release workspace arrays.')
-      END IF
+      IF( wrk_not_released(3, 1,2) )   CALL ctl_stop('dyn_zdf_exp : failed to release workspace arrays')
       !
    END SUBROUTINE dyn_zdf_exp
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynzdf_imp.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynzdf_imp.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynzdf_imp.F90	(revision 2636)
@@ -20,4 +20,5 @@
    USE phycst          ! physical constants
    USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/sshwzv.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/sshwzv.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/sshwzv.F90	(revision 2636)
@@ -25,4 +25,5 @@
    USE phycst
    USE lbclnk          ! ocean lateral boundary condition (or mpp link)
+   USE lib_mpp         ! MPP library
    USE obc_par         ! open boundary cond. parameter
    USE obc_oce
@@ -86,8 +87,7 @@
       !!----------------------------------------------------------------------
 
-      IF(wrk_in_use(2, 1,2))THEN
-         CALL ctl_stop('ssh_wzv: requested workspace arrays unavailable.')
-         RETURN
-      END IF
+      IF( wrk_in_use(2, 1,2) ) THEN
+         CALL ctl_stop('ssh_wzv: requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
 
       IF( kt == nit000 ) THEN
@@ -244,7 +244,5 @@
       IF(ln_ctl)   CALL prt_ctl( tab2d_1=ssha, clinfo1=' ssha  - : ', mask1=tmask, ovlap=1 )
       !
-      IF(wrk_not_released(2, 1,2))THEN
-         CALL ctl_stop('ssh_wzv: failed to release workspace arrays.')
-      END IF
+      IF( wrk_not_released(2, 1,2) )   CALL ctl_stop('ssh_wzv: failed to release workspace arrays')
       !
    END SUBROUTINE ssh_wzv
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/IOM/in_out_manager.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/IOM/in_out_manager.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/IOM/in_out_manager.F90	(revision 2636)
@@ -13,12 +13,7 @@
 
    !!----------------------------------------------------------------------
-   !!   ctl_stop   : update momentum and tracer Kz from a tke scheme
-   !!   ctl_warn   : initialization, namelist read, and parameters control
-   !!   getunit    : give the index of an unused logical unit
-   !!----------------------------------------------------------------------
    USE par_oce       ! ocean parameter
    USE lib_print     ! formated print library
    USE nc4interface  ! NetCDF4 interface
-   USE lib_mpp       ! MPP library
 
    IMPLICIT NONE
@@ -135,174 +130,4 @@
    !! $Id$
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   SUBROUTINE ctl_stop( cd_stop, cd1, cd2, cd3, cd4, cd5 ,   &
-      &                          cd6, cd7, cd8, cd9, cd10 )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE  stop_opa  ***
-      !!
-      !! ** Purpose :   print in ocean.outpput file a error message and 
-      !!                increment the error number (nstop) by one.
-      !!----------------------------------------------------------------------
-      CHARACTER(len=*), INTENT(in), OPTIONAL ::  cd_stop, cd1, cd2, cd3, cd4, cd5
-      CHARACTER(len=*), INTENT(in), OPTIONAL ::           cd6, cd7, cd8, cd9, cd10
-      !!----------------------------------------------------------------------
-      !
-      nstop = nstop + 1 
-      IF(lwp) THEN
-         WRITE(numout,cform_err)
-         IF( PRESENT(cd1 ) ) WRITE(numout,*) cd1
-         IF( PRESENT(cd2 ) ) WRITE(numout,*) cd2
-         IF( PRESENT(cd3 ) ) WRITE(numout,*) cd3
-         IF( PRESENT(cd4 ) ) WRITE(numout,*) cd4
-         IF( PRESENT(cd5 ) ) WRITE(numout,*) cd5
-         IF( PRESENT(cd6 ) ) WRITE(numout,*) cd6
-         IF( PRESENT(cd7 ) ) WRITE(numout,*) cd7
-         IF( PRESENT(cd8 ) ) WRITE(numout,*) cd8
-         IF( PRESENT(cd9 ) ) WRITE(numout,*) cd9
-         IF( PRESENT(cd10) ) WRITE(numout,*) cd10
-      ENDIF
-                               CALL FLUSH(numout    )
-      IF( numstp     /= -1 )   CALL FLUSH(numstp    )
-      IF( numsol     /= -1 )   CALL FLUSH(numsol    )
-      IF( numevo_ice /= -1 )   CALL FLUSH(numevo_ice)
-      !
-      IF( PRESENT(cd_stop) ) THEN
-         IF( cd_stop == 'STOP' ) THEN
-            WRITE(numout,*) 
-            WRITE(numout,*) 'huge E-R-R-O-R : immediate stop'
-            CALL mppstop()
-         ENDIF
-      ENDIF
-      !
-   END SUBROUTINE ctl_stop
-
-
-   SUBROUTINE ctl_warn( cd1, cd2, cd3, cd4, cd5,   &
-      &                 cd6, cd7, cd8, cd9, cd10 )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE  stop_warn  ***
-      !!
-      !! ** Purpose :   print in ocean.outpput file a error message and 
-      !!                increment the warning number (nwarn) by one.
-      !!----------------------------------------------------------------------
-      CHARACTER(len=*), INTENT(in), OPTIONAL ::  cd1, cd2, cd3, cd4, cd5
-      CHARACTER(len=*), INTENT(in), OPTIONAL ::  cd6, cd7, cd8, cd9, cd10
-      !!----------------------------------------------------------------------
-      ! 
-      nwarn = nwarn + 1 
-      IF(lwp) THEN
-         WRITE(numout,cform_war)
-         IF( PRESENT(cd1 ) ) WRITE(numout,*) cd1
-         IF( PRESENT(cd2 ) ) WRITE(numout,*) cd2
-         IF( PRESENT(cd3 ) ) WRITE(numout,*) cd3
-         IF( PRESENT(cd4 ) ) WRITE(numout,*) cd4
-         IF( PRESENT(cd5 ) ) WRITE(numout,*) cd5
-         IF( PRESENT(cd6 ) ) WRITE(numout,*) cd6
-         IF( PRESENT(cd7 ) ) WRITE(numout,*) cd7
-         IF( PRESENT(cd8 ) ) WRITE(numout,*) cd8
-         IF( PRESENT(cd9 ) ) WRITE(numout,*) cd9
-         IF( PRESENT(cd10) ) WRITE(numout,*) cd10
-      ENDIF
-      CALL FLUSH(numout)
-      !
-   END SUBROUTINE ctl_warn
-
-
-   SUBROUTINE ctl_opn( knum, cdfile, cdstat, cdform, cdacce, klengh, kout, ldwp, karea )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE ctl_opn  ***
-      !!
-      !! ** Purpose :   Open file and check if required file is available.
-      !!
-      !! ** Method  :   Fortan open
-      !!----------------------------------------------------------------------
-      INTEGER          , INTENT(  out) ::   knum      ! logical unit to open
-      CHARACTER(len=*) , INTENT(in   ) ::   cdfile    ! file name to open
-      CHARACTER(len=*) , INTENT(in   ) ::   cdstat    ! disposition specifier
-      CHARACTER(len=*) , INTENT(in   ) ::   cdform    ! formatting specifier
-      CHARACTER(len=*) , INTENT(in   ) ::   cdacce    ! access specifier
-      INTEGER          , INTENT(in   ) ::   klengh    ! record length
-      INTEGER          , INTENT(in   ) ::   kout      ! number of logical units for write
-      LOGICAL          , INTENT(in   ) ::   ldwp      ! boolean term for print
-      INTEGER, OPTIONAL, INTENT(in   ) ::   karea     ! proc number
-      !!
-      CHARACTER(len=80) ::   clfile
-      INTEGER           ::   iost
-      !!----------------------------------------------------------------------
-
-      ! adapt filename
-      ! ----------------
-      clfile = TRIM(cdfile)
-      IF( PRESENT( karea ) ) THEN
-         IF( karea > 1 )   WRITE(clfile, "(a,'_',i4.4)") TRIM(clfile), karea-1
-      ENDIF
-#if defined key_agrif
-      IF( .NOT. Agrif_Root() )   clfile = TRIM(Agrif_CFixed())//'_'//TRIM(clfile)
-      knum=Agrif_Get_Unit()
-#else
-      knum=getunit()
-#endif
-
-      iost=0
-      IF( cdacce(1:6) == 'DIRECT' )  THEN
-         OPEN( UNIT=knum, FILE=clfile, FORM=cdform, ACCESS=cdacce, STATUS=cdstat, RECL=klengh, ERR=100, IOSTAT=iost )
-      ELSE
-         OPEN( UNIT=knum, FILE=clfile, FORM=cdform, ACCESS=cdacce, STATUS=cdstat             , ERR=100, IOSTAT=iost )
-      ENDIF
-      IF( iost == 0 ) THEN
-         IF(ldwp) THEN
-            WRITE(kout,*) '     file   : ', clfile,' open ok'
-            WRITE(kout,*) '     unit   = ', knum
-            WRITE(kout,*) '     status = ', cdstat
-            WRITE(kout,*) '     form   = ', cdform
-            WRITE(kout,*) '     access = ', cdacce
-            WRITE(kout,*)
-         ENDIF
-      ENDIF
-100   CONTINUE
-      IF( iost /= 0 ) THEN
-         IF(ldwp) THEN
-            WRITE(kout,*)
-            WRITE(kout,*) ' ===>>>> : bad opening file: ', clfile
-            WRITE(kout,*) ' =======   ===  '
-            WRITE(kout,*) '           unit   = ', knum
-            WRITE(kout,*) '           status = ', cdstat
-            WRITE(kout,*) '           form   = ', cdform
-            WRITE(kout,*) '           access = ', cdacce
-            WRITE(kout,*) '           iostat = ', iost
-            WRITE(kout,*) '           we stop. verify the file '
-            WRITE(kout,*)
-         ENDIF
-         STOP 'ctl_opn bad opening'
-      ENDIF
-      
-   END SUBROUTINE ctl_opn
-
-
-   FUNCTION getunit()
-      !!----------------------------------------------------------------------
-      !!                  ***  FUNCTION  getunit  ***
-      !!
-      !! ** Purpose :   return the index of an unused logical unit
-      !!----------------------------------------------------------------------
-      INTEGER :: getunit
-      LOGICAL :: llopn 
-      !!----------------------------------------------------------------------
-      !
-      getunit = 15   ! choose a unit that is big enough then it is not already used in NEMO
-      llopn = .TRUE.
-      DO WHILE( (getunit < 998) .AND. llopn )
-         getunit = getunit + 1
-         INQUIRE( unit = getunit, opened = llopn )
-      END DO
-      IF( (getunit == 999) .AND. llopn ) THEN
-         CALL ctl_stop( 'getunit: All logical units until 999 are used...' )
-         getunit = -1
-      ENDIF
-      !
-   END FUNCTION getunit
-
    !!=====================================================================
 END MODULE in_out_manager
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 2636)
@@ -18,5 +18,4 @@
    !!   iom_rstput     : write a field in a restart file (interfaced to several routines)
    !!--------------------------------------------------------------------
-   USE in_out_manager  ! I/O manager
    USE dom_oce         ! ocean space and time domain
    USE lbclnk          ! lateal boundary condition / mpp exchanges
@@ -25,5 +24,6 @@
    USE iom_nf90        ! NetCDF format with native NetCDF library
    USE iom_rstdimg     ! restarts access direct format "dimg" style...
-
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp           ! MPP library
 #if defined key_iomput
    USE sbc_oce, ONLY :   nn_fsbc         ! ocean space and time domain
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/IOM/iom_ioipsl.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/IOM/iom_ioipsl.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/IOM/iom_ioipsl.F90	(revision 2636)
@@ -18,8 +18,9 @@
    !!   iom_rstput     : write a field in a restart file (interfaced to several routines)
    !!--------------------------------------------------------------------
-   USE in_out_manager  ! I/O manager
    USE dom_oce         ! ocean space and time domain
    USE iom_def         ! iom variables definitions
    USE ioipsl          ! IOIPSL library
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/IOM/iom_nf90.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/IOM/iom_nf90.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/IOM/iom_nf90.F90	(revision 2636)
@@ -18,9 +18,10 @@
    !!   iom_rstput     : write a field in a restart file (interfaced to several routines)
    !!--------------------------------------------------------------------
-   USE in_out_manager  ! I/O manager
    USE dom_oce         ! ocean space and time domain
    USE lbclnk          ! lateal boundary condition / mpp exchanges
    USE iom_def         ! iom variables definitions
    USE netcdf          ! NetCDF library
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/IOM/iom_rstdimg.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/IOM/iom_rstdimg.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/IOM/iom_rstdimg.F90	(revision 2636)
@@ -16,4 +16,5 @@
    !!--------------------------------------------------------------------
    USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! MPP library
    USE dom_oce         ! ocean space and time domain
    USE lbclnk          ! lateal boundary condition / mpp exchanges
@@ -82,5 +83,5 @@
       llclobber = ldwrt .AND. ln_clobber
       ! get a free unit
-      idrst = getunit()  ! get a free logical unit for the restart file
+      idrst = get_unit()  ! get a free logical unit for the restart file
 !!$#if defined key_agrif 
 !!$      idrst = Agrif_Get_Unit()      
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/LBC/cla.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/LBC/cla.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/LBC/cla.F90	(revision 2636)
@@ -31,4 +31,5 @@
    USE lib_mpp        ! distributed memory computing library
    USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp        ! MPP library
 
    IMPLICIT NONE
@@ -723,5 +724,5 @@
    !!   Default key                                            Dummy module
    !!----------------------------------------------------------------------
-   USE in_out_manager ! I/O manager
+   USE lib_mpp, ONLY:   ctl_stop
 CONTAINS
    SUBROUTINE cla_init
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/LBC/lbcnfd.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/LBC/lbcnfd.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/LBC/lbcnfd.F90	(revision 2636)
@@ -12,5 +12,4 @@
    !!   lbc_nfd_2d    : lateral boundary condition: North fold treatment for a 2D arrays   (lbc_nfd)
    !!----------------------------------------------------------------------
-   USE oce            ! ocean dynamics and tracers   
    USE dom_oce        ! ocean space and time domain 
    USE in_out_manager ! I/O manager
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90	(revision 2636)
@@ -18,4 +18,12 @@
    !!            3.2  !  2009  (R. Benshila) SHMEM suppression, north fold in lbc_nfd
    !!            3.2  !  2009  (O. Marti)    add mpp_ini_znl 
+   !!            4.0  !  2011  (G. Madec)  move ctl_ routines from in_out_manager
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   ctl_stop   : update momentum and tracer Kz from a tke scheme
+   !!   ctl_warn   : initialization, namelist read, and parameters control
+   !!   ctl_opn    : Open file and check if required file is available.
+   !!   get_unit    : give the index of an unused logical unit
    !!----------------------------------------------------------------------
 #if   defined key_mpp_mpi  
@@ -44,19 +52,12 @@
    !!   mpp_lbc_north_e : variant of mpp_lbc_north for extra outer halo
    !!----------------------------------------------------------------------
-   !! History :  OPA  ! 1994 (M. Guyon, J. Escobar, M. Imbard)  Original code
-   !!                 ! 1997  (A.M. Treguier)  SHMEM additions
-   !!                 ! 1998  (M. Imbard, J. Escobar, L. Colombet ) SHMEM and MPI
-   !!   NEMO     1.0  ! 2003  (J.-M. Molines, G. Madec)  F90, free form
-   !!                 ! 2004  (R. Bourdalle Badie)  isend option in mpi
-   !!                 ! 2005  (G. Madec, S. Masson)  npolj=5,6 F-point & ice cases
-   !!                 ! 2005  (R. Redler) Replacement of MPI_COMM_WORLD except for MPI_Abort
-   !!                 ! 2009  (R. Benshila) SHMEM suppression, north fold in lbc_nfd
-   !!----------------------------------------------------------------------
    USE dom_oce        ! ocean space and time domain 
    USE lbcnfd         ! north fold treatment
+   USE in_out_manager ! I/O manager
 
    IMPLICIT NONE
    PRIVATE
    
+   PUBLIC   ctl_stop, ctl_warn, get_unit, ctl_opn
    PUBLIC   mynode, mppstop, mppsync, mpp_comm_free
    PUBLIC   mpp_ini_north, mpp_lbc_north, mpp_lbc_north_e
@@ -116,7 +117,4 @@
 # endif
 
-   CHARACTER(lc) ::   cform_err = "(/,' ===>>> : E R R O R',     /,'         ===========',/)"       !:
-   CHARACTER(lc) ::   cform_war = "(/,' ===>>> : W A R N I N G', /,'         ===============',/)"   !:
-
    ! variables used in case of sea-ice
    INTEGER, PUBLIC ::   ncomm_ice       !: communicator made by the processors with sea-ice
@@ -2468,4 +2466,5 @@
    !!   Default case:            Dummy module        share memory computing
    !!----------------------------------------------------------------------
+   USE in_out_manager
 
    INTERFACE mpp_sum
@@ -2488,8 +2487,7 @@
    END INTERFACE
 
-
    LOGICAL, PUBLIC, PARAMETER ::   lk_mpp = .FALSE.      !: mpp flag
    INTEGER :: ncomm_ice
-
+   !!----------------------------------------------------------------------
 CONTAINS
 
@@ -2666,4 +2664,172 @@
    END SUBROUTINE mpp_comm_free
 #endif
+
+   !!----------------------------------------------------------------------
+   !!   All cases:         ctl_stop, ctl_warn, get_unit, ctl_opn   routines
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE ctl_stop( cd1, cd2, cd3, cd4, cd5 ,   &
+      &                 cd6, cd7, cd8, cd9, cd10 )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE  stop_opa  ***
+      !!
+      !! ** Purpose :   print in ocean.outpput file a error message and 
+      !!                increment the error number (nstop) by one.
+      !!----------------------------------------------------------------------
+      CHARACTER(len=*), INTENT(in), OPTIONAL ::  cd1, cd2, cd3, cd4, cd5
+      CHARACTER(len=*), INTENT(in), OPTIONAL ::  cd6, cd7, cd8, cd9, cd10
+      !!----------------------------------------------------------------------
+      !
+      nstop = nstop + 1 
+      IF(lwp) THEN
+         WRITE(numout,cform_err)
+         IF( PRESENT(cd1 ) )   WRITE(numout,*) cd1
+         IF( PRESENT(cd2 ) )   WRITE(numout,*) cd2
+         IF( PRESENT(cd3 ) )   WRITE(numout,*) cd3
+         IF( PRESENT(cd4 ) )   WRITE(numout,*) cd4
+         IF( PRESENT(cd5 ) )   WRITE(numout,*) cd5
+         IF( PRESENT(cd6 ) )   WRITE(numout,*) cd6
+         IF( PRESENT(cd7 ) )   WRITE(numout,*) cd7
+         IF( PRESENT(cd8 ) )   WRITE(numout,*) cd8
+         IF( PRESENT(cd9 ) )   WRITE(numout,*) cd9
+         IF( PRESENT(cd10) )   WRITE(numout,*) cd10
+      ENDIF
+                               CALL FLUSH(numout    )
+      IF( numstp     /= -1 )   CALL FLUSH(numstp    )
+      IF( numsol     /= -1 )   CALL FLUSH(numsol    )
+      IF( numevo_ice /= -1 )   CALL FLUSH(numevo_ice)
+      !
+      IF( cd1 == 'STOP' ) THEN
+         IF(lwp) WRITE(numout,*)  'huge E-R-R-O-R : immediate stop'
+         CALL mppstop()
+      ENDIF
+      !
+   END SUBROUTINE ctl_stop
+
+
+   SUBROUTINE ctl_warn( cd1, cd2, cd3, cd4, cd5,   &
+      &                 cd6, cd7, cd8, cd9, cd10 )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE  stop_warn  ***
+      !!
+      !! ** Purpose :   print in ocean.outpput file a error message and 
+      !!                increment the warning number (nwarn) by one.
+      !!----------------------------------------------------------------------
+      CHARACTER(len=*), INTENT(in), OPTIONAL ::  cd1, cd2, cd3, cd4, cd5
+      CHARACTER(len=*), INTENT(in), OPTIONAL ::  cd6, cd7, cd8, cd9, cd10
+      !!----------------------------------------------------------------------
+      ! 
+      nwarn = nwarn + 1 
+      IF(lwp) THEN
+         WRITE(numout,cform_war)
+         IF( PRESENT(cd1 ) ) WRITE(numout,*) cd1
+         IF( PRESENT(cd2 ) ) WRITE(numout,*) cd2
+         IF( PRESENT(cd3 ) ) WRITE(numout,*) cd3
+         IF( PRESENT(cd4 ) ) WRITE(numout,*) cd4
+         IF( PRESENT(cd5 ) ) WRITE(numout,*) cd5
+         IF( PRESENT(cd6 ) ) WRITE(numout,*) cd6
+         IF( PRESENT(cd7 ) ) WRITE(numout,*) cd7
+         IF( PRESENT(cd8 ) ) WRITE(numout,*) cd8
+         IF( PRESENT(cd9 ) ) WRITE(numout,*) cd9
+         IF( PRESENT(cd10) ) WRITE(numout,*) cd10
+      ENDIF
+      CALL FLUSH(numout)
+      !
+   END SUBROUTINE ctl_warn
+
+
+   SUBROUTINE ctl_opn( knum, cdfile, cdstat, cdform, cdacce, klengh, kout, ldwp, karea )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ctl_opn  ***
+      !!
+      !! ** Purpose :   Open file and check if required file is available.
+      !!
+      !! ** Method  :   Fortan open
+      !!----------------------------------------------------------------------
+      INTEGER          , INTENT(  out) ::   knum      ! logical unit to open
+      CHARACTER(len=*) , INTENT(in   ) ::   cdfile    ! file name to open
+      CHARACTER(len=*) , INTENT(in   ) ::   cdstat    ! disposition specifier
+      CHARACTER(len=*) , INTENT(in   ) ::   cdform    ! formatting specifier
+      CHARACTER(len=*) , INTENT(in   ) ::   cdacce    ! access specifier
+      INTEGER          , INTENT(in   ) ::   klengh    ! record length
+      INTEGER          , INTENT(in   ) ::   kout      ! number of logical units for write
+      LOGICAL          , INTENT(in   ) ::   ldwp      ! boolean term for print
+      INTEGER, OPTIONAL, INTENT(in   ) ::   karea     ! proc number
+      !!
+      CHARACTER(len=80) ::   clfile
+      INTEGER           ::   iost
+      !!----------------------------------------------------------------------
+
+      ! adapt filename
+      ! ----------------
+      clfile = TRIM(cdfile)
+      IF( PRESENT( karea ) ) THEN
+         IF( karea > 1 )   WRITE(clfile, "(a,'_',i4.4)") TRIM(clfile), karea-1
+      ENDIF
+#if defined key_agrif
+      IF( .NOT. Agrif_Root() )   clfile = TRIM(Agrif_CFixed())//'_'//TRIM(clfile)
+      knum=Agrif_Get_Unit()
+#else
+      knum=get_unit()
+#endif
+
+      iost=0
+      IF( cdacce(1:6) == 'DIRECT' )  THEN
+         OPEN( UNIT=knum, FILE=clfile, FORM=cdform, ACCESS=cdacce, STATUS=cdstat, RECL=klengh, ERR=100, IOSTAT=iost )
+      ELSE
+         OPEN( UNIT=knum, FILE=clfile, FORM=cdform, ACCESS=cdacce, STATUS=cdstat             , ERR=100, IOSTAT=iost )
+      ENDIF
+      IF( iost == 0 ) THEN
+         IF(ldwp) THEN
+            WRITE(kout,*) '     file   : ', clfile,' open ok'
+            WRITE(kout,*) '     unit   = ', knum
+            WRITE(kout,*) '     status = ', cdstat
+            WRITE(kout,*) '     form   = ', cdform
+            WRITE(kout,*) '     access = ', cdacce
+            WRITE(kout,*)
+         ENDIF
+      ENDIF
+100   CONTINUE
+      IF( iost /= 0 ) THEN
+         IF(ldwp) THEN
+            WRITE(kout,*)
+            WRITE(kout,*) ' ===>>>> : bad opening file: ', clfile
+            WRITE(kout,*) ' =======   ===  '
+            WRITE(kout,*) '           unit   = ', knum
+            WRITE(kout,*) '           status = ', cdstat
+            WRITE(kout,*) '           form   = ', cdform
+            WRITE(kout,*) '           access = ', cdacce
+            WRITE(kout,*) '           iostat = ', iost
+            WRITE(kout,*) '           we stop. verify the file '
+            WRITE(kout,*)
+         ENDIF
+         STOP 'ctl_opn bad opening'
+      ENDIF
+      
+   END SUBROUTINE ctl_opn
+
+
+   INTEGER FUNCTION get_unit()
+      !!----------------------------------------------------------------------
+      !!                  ***  FUNCTION  get_unit  ***
+      !!
+      !! ** Purpose :   return the index of an unused logical unit
+      !!----------------------------------------------------------------------
+      LOGICAL :: llopn 
+      !!----------------------------------------------------------------------
+      !
+      get_unit = 15   ! choose a unit that is big enough then it is not already used in NEMO
+      llopn = .TRUE.
+      DO WHILE( (get_unit < 998) .AND. llopn )
+         get_unit = get_unit + 1
+         INQUIRE( unit = get_unit, opened = llopn )
+      END DO
+      IF( (get_unit == 999) .AND. llopn ) THEN
+         CALL ctl_stop( 'get_unit: All logical units until 999 are used...' )
+         get_unit = -1
+      ENDIF
+      !
+   END FUNCTION get_unit
+
    !!----------------------------------------------------------------------
 END MODULE lib_mpp
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/LDF/ldfdyn_oce.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/LDF/ldfdyn_oce.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/LDF/ldfdyn_oce.F90	(revision 2636)
@@ -8,4 +8,5 @@
    USE par_oce        ! ocean parameters
    USE in_out_manager ! I/O manager
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
@@ -45,4 +46,5 @@
       !!                 ***  FUNCTION ldfdyn_oce_alloc  ***
       !!----------------------------------------------------------------------
+      ldfdyn_oce_alloc = 0
 #if defined key_dynldf_c3d
       ALLOCATE( ahm1(jpi,jpj,jpk) , ahm2(jpi,jpj,jpk) , ahm3(jpi,jpj,jpk) , ahm4(jpi,jpj,jpk) , STAT=ldfdyn_oce_alloc )
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/LDF/ldftra_oce.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/LDF/ldftra_oce.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/LDF/ldftra_oce.F90	(revision 2636)
@@ -8,4 +8,5 @@
    USE par_oce        ! ocean parameters
    USE in_out_manager ! I/O manager
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/albedo.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/albedo.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/albedo.F90	(revision 2636)
@@ -18,4 +18,5 @@
    USE phycst          ! physical constants
    USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
@@ -64,6 +65,6 @@
       !! References :   Shine and Hendersson-Sellers 1985, JGR, 90(D1), 2243-2250.
       !!----------------------------------------------------------------------
-      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released, llwrk_in_use, llwrk_not_released
-      USE wrk_nemo, ONLY: wrk_3d_6, wrk_3d_7    ! 3D workspace
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released, llwrk_in_use, llwrk_not_released
+      USE wrk_nemo, ONLY:   wrk_3d_6, wrk_3d_7    ! 3D workspace
       !!
       REAL(wp), INTENT(in   ), DIMENSION(:,:,:) ::   pt_ice      !  ice surface temperature (Kelvin)
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/cpl_oasis4.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/cpl_oasis4.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/cpl_oasis4.F90	(revision 2636)
@@ -20,15 +20,16 @@
    !!   cpl_prism_init     : initialization of coupled mode communication
    !!   cpl_prism_define   : definition of grid and fields
-   !!   cpl_prism_snd     : snd out fields in coupled mode
-   !!   cpl_prism_rcv     : receive fields in coupled mode
-   !!   cpl_prism_update_time   : update date sent to Oasis
+   !!   cpl_prism_snd      : snd out fields in coupled mode
+   !!   cpl_prism_rcv      : receive fields in coupled mode
+   !!   cpl_prism_update_time : update date sent to Oasis
    !!   cpl_prism_finalize : finalize the coupled mode communication
    !!----------------------------------------------------------------------
-   USE prism              ! OASIS4 prism module
-   USE par_oce                      ! ocean parameters
-   USE dom_oce                      ! ocean space and time domain
-   USE domwri                       ! ocean space and time domain
-   USE in_out_manager               ! I/O manager
-   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE prism            ! OASIS4 prism module
+   USE par_oce          ! ocean parameters
+   USE dom_oce          ! ocean space and time domain
+   USE domwri           ! ocean space and time domain
+   USE in_out_manager   ! I/O manager
+   USE lbclnk           ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp          ! MPP library
 
    IMPLICIT NONE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/fldread.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/fldread.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/fldread.F90	(revision 2636)
@@ -15,9 +15,10 @@
    USE oce             ! ocean dynamics and tracers
    USE dom_oce         ! ocean space and time domain
-   USE ioipsl, ONLY :   ymds2ju, ju2ymds   ! for calendar
    USE phycst          ! ???
    USE in_out_manager  ! I/O manager
    USE iom             ! I/O manager library
    USE geo2ocean       ! for vector rotation on to model grid
+   USE lib_mpp         ! MPP library
+   USE ioipsl, ONLY :   ymds2ju, ju2ymds   ! for calendar
 
    IMPLICIT NONE
@@ -391,5 +392,5 @@
          CALL fld_clopn( sdjf, iyear, imonth, iday )
       ENDIF 
-
+      !
    END SUBROUTINE fld_init
 
@@ -804,7 +805,7 @@
       !!                file, restructuring as required
       !!----------------------------------------------------------------------
-      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released, iwrk_in_use, iwrk_not_released
-      USE wrk_nemo, ONLY: data_tmp => wrk_2d_1
-      USE wrk_nemo, ONLY: data_src => iwrk_2d_1
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released, iwrk_in_use, iwrk_not_released
+      USE wrk_nemo, ONLY:   data_tmp =>  wrk_2d_1     ! 2D real    workspace
+      USE wrk_nemo, ONLY:   data_src => iwrk_2d_1     ! 2D integer workspace
       !!
       TYPE( FLD ), INTENT(in) ::   sd   ! field with name of weights file
@@ -822,5 +823,5 @@
       IF(  wrk_in_use(2, 1)  .OR.  iwrk_in_use(2,1) ) THEN
          CALL ctl_stop('fld_weights: requested workspace arrays are unavailable.')   ;   RETURN
-      END IF
+      ENDIF
       !
       IF( nxt_wgt > tot_wgts ) THEN
@@ -934,5 +935,5 @@
       ENDIF
 
-      IF( wrk_not_released(2, 1) .OR.    &
+      IF(  wrk_not_released(2, 1) .OR.    &
           iwrk_not_released(2, 1)   )   CALL ctl_stop('fld_weights: failed to release workspace arrays')
       !
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/geo2ocean.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/geo2ocean.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/geo2ocean.F90	(revision 2636)
@@ -46,7 +46,6 @@
    !! NEMO/OPA 3.3 , NEMO Consortium (2010)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-
 CONTAINS
 
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/sbcapr.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/sbcapr.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/sbcapr.F90	(revision 2636)
@@ -20,4 +20,5 @@
    USE lib_fortran     ! distribued memory computing library
    USE iom             ! IOM library
+   USE lib_mpp         ! MPP library
    USE restart         ! ocean restart
 
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_clio.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_clio.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_clio.F90	(revision 2636)
@@ -232,8 +232,7 @@
       !!---------------------------------------------------------------------
 
-      IF(wrk_in_use(3, 1,2,3))THEN
-         CALL ctl_stop('blk_oce_clio: requested workspace arrays are unavailable.')
-         RETURN
-      END IF
+      IF( wrk_in_use(3, 1,2,3) ) THEN
+         CALL ctl_stop('blk_oce_clio: requested workspace arrays are unavailable')   ;   RETURN
+      ENDIF
 
       zpatm = 101000.      ! atmospheric pressure  (assumed constant here)
@@ -386,8 +385,6 @@
       ENDIF
 
-      IF(wrk_not_released(3, 1,2,3))THEN
-         CALL ctl_stop('blk_oce_clio: failed to release workspace arrays.')
-      END IF
-
+      IF( wrk_not_released(3, 1,2,3) )   CALL ctl_stop('blk_oce_clio: failed to release workspace arrays')
+      !
    END SUBROUTINE blk_oce_clio
 
@@ -420,10 +417,10 @@
       !!
       !!----------------------------------------------------------------------
-      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
-      USE wrk_nemo, ONLY:  ztatm => wrk_2d_1   ! Tair in Kelvin
-      USE wrk_nemo, ONLY:  zqatm => wrk_2d_2   ! specific humidity
-      USE wrk_nemo, ONLY: zevsqr => wrk_2d_3   ! vapour pressure square-root
-      USE wrk_nemo, ONLY:  zrhoa => wrk_2d_4   ! air density
-      USE wrk_nemo, ONLY: wrk_3d_1, wrk_3d_2
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY:   ztatm  => wrk_2d_1   ! Tair in Kelvin
+      USE wrk_nemo, ONLY:   zqatm  => wrk_2d_2   ! specific humidity
+      USE wrk_nemo, ONLY:   zevsqr => wrk_2d_3   ! vapour pressure square-root
+      USE wrk_nemo, ONLY:   zrhoa  => wrk_2d_4   ! air density
+      USE wrk_nemo, ONLY:   wrk_3d_1 , wrk_3d_2
       !!
       REAL(wp), INTENT(in   ), DIMENSION(:,:,:)   ::   pst      ! ice surface temperature                   [Kelvin]
@@ -457,7 +454,6 @@
       !!---------------------------------------------------------------------
 
-      IF( (wrk_in_use(2, 1,2,3,4)) .OR. (wrk_in_use(3, 1,2)) )THEN
-         CALL ctl_stop('blk_ice_clio: requested workspace arrays are unavailable.')
-         RETURN
+      IF(  wrk_in_use(2, 1,2,3,4)  .OR.  wrk_in_use(3, 1,2)  ) THEN
+         CALL ctl_stop('blk_ice_clio: requested workspace arrays are unavailable')   ;   RETURN
       ELSE IF(pdim > jpk)THEN
          CALL ctl_stop('blk_ice_clio: too many ice levels to use wrk_nemo 3D workspaces.')
@@ -637,8 +633,8 @@
       ENDIF
 
-      IF( (wrk_not_released(2, 1,2,3,4)) .OR. (wrk_not_released(3, 1,2)) )THEN
+      IF( wrk_not_released(2, 1,2,3,4)  .OR.   &
+          wrk_not_released(3, 1,2)        )    &
          CALL ctl_stop('blk_ice_clio: failed to release workspace arrays.')
-      END IF
-
+      !
    END SUBROUTINE blk_ice_clio
 
@@ -654,8 +650,8 @@
       !!               - also initialise sbudyko and stauc once for all 
       !!----------------------------------------------------------------------
-      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
-      USE wrk_nemo, ONLY:   zev => wrk_2d_1                  ! vapour pressure
-      USE wrk_nemo, ONLY: zdlha => wrk_2d_2, zlsrise => wrk_2d_3, zlsset => wrk_2d_4 
-      USE wrk_nemo, ONLY:   zps => wrk_2d_5, zpc => wrk_2d_6 ! sine (cosine) of latitude per sine (cosine) of solar declination 
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY:   zev   => wrk_2d_1                  ! vapour pressure
+      USE wrk_nemo, ONLY:   zdlha => wrk_2d_2 , zlsrise => wrk_2d_3 , zlsset => wrk_2d_4 
+      USE wrk_nemo, ONLY:   zps   => wrk_2d_5 , zpc     => wrk_2d_6 ! sin/cos of latitude per sin/cos of solar declination 
       !!
       REAL(wp), INTENT(  out), DIMENSION(jpi,jpj)     ::   pqsr_oce    ! shortwave radiation  over the ocean
@@ -679,7 +675,6 @@
       !!---------------------------------------------------------------------
 
-      IF(wrk_in_use(2, 1,2,3,4,5,6))THEN
-         CALL ctl_stop('blk_clio_qsr_oce: requested workspace arrays unavailable.')
-         RETURN
+      IF( wrk_in_use(2, 1,2,3,4,5,6) ) THEN
+         CALL ctl_stop('blk_clio_qsr_oce: requested workspace arrays unavailable')   ;   RETURN
       END IF
 
@@ -796,8 +791,6 @@
       END DO
 
-      IF(wrk_not_released(2, 1,2,3,4,5,6))THEN
-         CALL ctl_stop('blk_clio_qsr_oce: failed to release workspace arrays.')
-      END IF
-
+      IF( wrk_not_released(2, 1,2,3,4,5,6) )   CALL ctl_stop('blk_clio_qsr_oce: failed to release workspace arrays')
+      !
    END SUBROUTINE blk_clio_qsr_oce
 
@@ -813,10 +806,10 @@
       !!               - also initialise sbudyko and stauc once for all 
       !!----------------------------------------------------------------------
-      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
-      USE wrk_nemo, ONLY: zev => wrk_2d_1         ! vapour pressure
-      USE wrk_nemo, ONLY: zdlha => wrk_2d_2       ! 2D workspace
-      USE wrk_nemo, ONLY: zlsrise => wrk_2d_3     ! 2D workspace
-      USE wrk_nemo, ONLY: zlsset => wrk_2d_4      ! 2D workspace
-      USE wrk_nemo, ONLY: zps => wrk_2d_5, zpc => wrk_2d_6   ! sine (cosine) of latitude per sine (cosine) of solar declination 
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY:   zev     => wrk_2d_1     ! vapour pressure
+      USE wrk_nemo, ONLY:   zdlha   => wrk_2d_2     ! 2D workspace
+      USE wrk_nemo, ONLY:   zlsrise => wrk_2d_3     ! 2D workspace
+      USE wrk_nemo, ONLY:   zlsset  => wrk_2d_4     ! 2D workspace
+      USE wrk_nemo, ONLY:   zps     => wrk_2d_5, zpc => wrk_2d_6   ! sin/cos of latitude per sin/cos of solar declination 
       !!
       REAL(wp), INTENT(in   ), DIMENSION(:,:,:) ::   pa_ice_cs   ! albedo of ice under clear sky
@@ -839,8 +832,7 @@
       !!---------------------------------------------------------------------
 
-      IF(wrk_in_use(2, 1,2,3,4,5,6))THEN
-         CALL ctl_stop('blk_clio_qsr_ice: requested workspace arrays unavailable.')
-         RETURN
-      END IF
+      IF( wrk_in_use(2, 1,2,3,4,5,6) ) THEN
+         CALL ctl_stop('blk_clio_qsr_ice: requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
 
       ijpl = SIZE(pqsr_ice, 3 )      ! number of ice categories
@@ -945,7 +937,5 @@
       END DO
       !
-      IF(wrk_not_released(2, 1,2,3,4,5,6))THEN
-         CALL ctl_stop('blk_clio_qsr_ice: failed to release workspace arrays.')
-      END IF
+      IF( wrk_not_released(2, 1,2,3,4,5,6) )   CALL ctl_stop('blk_clio_qsr_ice: failed to release workspace arrays')
       !
    END SUBROUTINE blk_clio_qsr_ice
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_core.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_core.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_core.F90	(revision 2636)
@@ -11,4 +11,5 @@
    !!                           -  Implement reading of 6-hourly fields   
    !!            3.0  !  2006-06  (G. Madec) sbc rewritting   
+   !!             -   !  2006-12  (L. Brodeau) Original code for TURB_CORE_2Z
    !!            3.2  !  2009-04  (B. Lemaire)  Introduce iom_put
    !!            3.3  !  2010-10  (S. Masson)  add diurnal cycle
@@ -208,30 +209,28 @@
       !!  ** Nota  :   sf has to be a dummy argument for AGRIF on NEC
       !!---------------------------------------------------------------------
-      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
-      USE wrk_nemo, ONLY: zwnd_i => wrk_2d_1, zwnd_j  => wrk_2d_2   ! wind speed components at T-point
-      USE wrk_nemo, ONLY: zqsatw => wrk_2d_3           ! specific humidity at pst
-      USE wrk_nemo, ONLY: zqlw => wrk_2d_4, zqsb => wrk_2d_5       ! long wave and sensible heat fluxes
-      USE wrk_nemo, ONLY: zqla => wrk_2d_6, zevap => wrk_2d_7      ! latent heat fluxes and evaporation
-      USE wrk_nemo, ONLY:    Cd => wrk_2d_8           ! transfer coefficient for momentum      (tau)
-      USE wrk_nemo, ONLY:    Ch => wrk_2d_9           ! transfer coefficient for sensible heat (Q_sens)
-      USE wrk_nemo, ONLY:    Ce => wrk_2d_10          ! transfer coefficient for evaporation   (Q_lat)
-      USE wrk_nemo, ONLY:   zst => wrk_2d_11          ! surface temperature in Kelvin
-      USE wrk_nemo, ONLY: zt_zu => wrk_2d_12          ! air temperature at wind speed height
-      USE wrk_nemo, ONLY: zq_zu => wrk_2d_13          ! air spec. hum.  at wind speed height
-      !!
-      TYPE(fld), INTENT(in), DIMENSION(:)       ::   sf    ! input data
-      REAL(wp),  INTENT(in), DIMENSION(:,:) ::   pst   ! surface temperature                      [Celcius]
-      REAL(wp),  INTENT(in), DIMENSION(:,:) ::   pu    ! surface current at U-point (i-component) [m/s]
-      REAL(wp),  INTENT(in), DIMENSION(:,:) ::   pv    ! surface current at V-point (j-component) [m/s]
-
-      INTEGER  ::   ji, jj     ! dummy loop indices
-      REAL(wp) ::   zcoef_qsatw
-      REAL(wp) ::   zztmp                                 ! temporary variable
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY:   zwnd_i => wrk_2d_1  , zwnd_j => wrk_2d_2      ! wind speed components at T-point
+      USE wrk_nemo, ONLY:   zqsatw => wrk_2d_3           ! specific humidity at pst
+      USE wrk_nemo, ONLY:   zqlw   => wrk_2d_4  , zqsb   => wrk_2d_5      ! long wave and sensible heat fluxes
+      USE wrk_nemo, ONLY:   zqla   => wrk_2d_6  , zevap  => wrk_2d_7      ! latent heat fluxes and evaporation
+      USE wrk_nemo, ONLY:   Cd     => wrk_2d_8           ! transfer coefficient for momentum      (tau)
+      USE wrk_nemo, ONLY:   Ch     => wrk_2d_9           ! transfer coefficient for sensible heat (Q_sens)
+      USE wrk_nemo, ONLY:   Ce     => wrk_2d_10          ! transfer coefficient for evaporation   (Q_lat)
+      USE wrk_nemo, ONLY:   zst    => wrk_2d_11          ! surface temperature in Kelvin
+      USE wrk_nemo, ONLY:   zt_zu  => wrk_2d_12          ! air temperature at wind speed height
+      USE wrk_nemo, ONLY:   zq_zu  => wrk_2d_13          ! air spec. hum.  at wind speed height
+      !
+      TYPE(fld), INTENT(in), DIMENSION(:)   ::   sf    ! input data
+      REAL(wp) , INTENT(in), DIMENSION(:,:) ::   pst   ! surface temperature                      [Celcius]
+      REAL(wp) , INTENT(in), DIMENSION(:,:) ::   pu    ! surface current at U-point (i-component) [m/s]
+      REAL(wp) , INTENT(in), DIMENSION(:,:) ::   pv    ! surface current at V-point (j-component) [m/s]
+      !
+      INTEGER  ::   ji, jj               ! dummy loop indices
+      REAL(wp) ::   zcoef_qsatw, zztmp   ! local variable
       !!---------------------------------------------------------------------
 
-      IF(wrk_in_use(2, 1,2,3,4,5,6,7,8,9,10,11,12,13))THEN
-         CALL ctl_stop('blk_oce_core: requested workspace arrays unavailable.')
-         RETURN
-      END IF
+      IF( wrk_in_use(2, 1,2,3,4,5,6,7,8,9,10,11,12,13) ) THEN
+         CALL ctl_stop('blk_oce_core: requested workspace arrays unavailable.')   ;   RETURN
+      ENDIF
       !
       ! local scalars ( place there for vector optimisation purposes)
@@ -383,7 +382,6 @@
       ENDIF
       !
-      IF(wrk_not_released(2, 1,2,3,4,5,6,7,8,9,10,11,12,13))THEN
-         CALL ctl_stop('blk_oce_core: failed to release workspace arrays.')
-      END IF
+      IF( wrk_not_released(2, 1,2,3,4,5,6,7,8,9,10,11,12,13) )   &
+          CALL ctl_stop('blk_oce_core: failed to release workspace arrays')
       !
    END SUBROUTINE blk_oce_core
@@ -407,25 +405,25 @@
       !! caution : the net upward water flux has with mm/day unit
       !!---------------------------------------------------------------------
-      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
-      USE wrk_nemo, ONLY: z_wnds_t => wrk_2d_1                ! wind speed ( = | U10m - U_ice | ) at T-point
-      USE wrk_nemo, ONLY: wrk_3d_4, wrk_3d_5, wrk_3d_6, wrk_3d_7
-      !!
-      REAL(wp), DIMENSION(:,:,:)  , INTENT(in   ) ::   pst      ! ice surface temperature (>0, =rt0 over land) [Kelvin]
-      REAL(wp), DIMENSION(:,:)    , INTENT(in   ) ::   pui      ! ice surface velocity (i- and i- components      [m/s]
-      REAL(wp), DIMENSION(:,:)    , INTENT(in   ) ::   pvi      !    at I-point (B-grid) or U & V-point (C-grid)
-      REAL(wp), DIMENSION(:,:,:)  , INTENT(in   ) ::   palb     ! ice albedo (clear sky) (alb_ice_cs)               [%]
-      REAL(wp), DIMENSION(:,:)    , INTENT(  out) ::   p_taui   ! i- & j-components of surface ice stress        [N/m2]
-      REAL(wp), DIMENSION(:,:)    , INTENT(  out) ::   p_tauj   !   at I-point (B-grid) or U & V-point (C-grid)
-      REAL(wp), DIMENSION(:,:,:)  , INTENT(  out) ::   p_qns    ! non solar heat flux over ice (T-point)         [W/m2]
-      REAL(wp), DIMENSION(:,:,:)  , INTENT(  out) ::   p_qsr    !     solar heat flux over ice (T-point)         [W/m2]
-      REAL(wp), DIMENSION(:,:,:)  , INTENT(  out) ::   p_qla    ! latent    heat flux over ice (T-point)         [W/m2]
-      REAL(wp), DIMENSION(:,:,:)  , INTENT(  out) ::   p_dqns   ! non solar heat sensistivity  (T-point)         [W/m2]
-      REAL(wp), DIMENSION(:,:,:)  , INTENT(  out) ::   p_dqla   ! latent    heat sensistivity  (T-point)         [W/m2]
-      REAL(wp), DIMENSION(:,:)    , INTENT(  out) ::   p_tpr    ! total precipitation          (T-point)      [Kg/m2/s]
-      REAL(wp), DIMENSION(:,:),     INTENT(  out) ::   p_spr    ! solid precipitation          (T-point)      [Kg/m2/s]
-      REAL(wp), DIMENSION(:,:),     INTENT(  out) ::   p_fr1    ! 1sr fraction of qsr penetration in ice (T-point)  [%]
-      REAL(wp), DIMENSION(:,:),     INTENT(  out) ::   p_fr2    ! 2nd fraction of qsr penetration in ice (T-point)  [%]
-      CHARACTER(len=1)            , INTENT(in   ) ::   cd_grid  ! ice grid ( C or B-grid)
-      INTEGER                     , INTENT(in   ) ::   pdim     ! number of ice categories
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY:   z_wnds_t => wrk_2d_1                ! wind speed ( = | U10m - U_ice | ) at T-point
+      USE wrk_nemo, ONLY:   wrk_3d_4 , wrk_3d_5 , wrk_3d_6 , wrk_3d_7
+      !!
+      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   pst      ! ice surface temperature (>0, =rt0 over land) [Kelvin]
+      REAL(wp), DIMENSION(:,:)  , INTENT(in   ) ::   pui      ! ice surface velocity (i- and i- components      [m/s]
+      REAL(wp), DIMENSION(:,:)  , INTENT(in   ) ::   pvi      !    at I-point (B-grid) or U & V-point (C-grid)
+      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   palb     ! ice albedo (clear sky) (alb_ice_cs)               [%]
+      REAL(wp), DIMENSION(:,:)  , INTENT(  out) ::   p_taui   ! i- & j-components of surface ice stress        [N/m2]
+      REAL(wp), DIMENSION(:,:)  , INTENT(  out) ::   p_tauj   !   at I-point (B-grid) or U & V-point (C-grid)
+      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   p_qns    ! non solar heat flux over ice (T-point)         [W/m2]
+      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   p_qsr    !     solar heat flux over ice (T-point)         [W/m2]
+      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   p_qla    ! latent    heat flux over ice (T-point)         [W/m2]
+      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   p_dqns   ! non solar heat sensistivity  (T-point)         [W/m2]
+      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   p_dqla   ! latent    heat sensistivity  (T-point)         [W/m2]
+      REAL(wp), DIMENSION(:,:)  , INTENT(  out) ::   p_tpr    ! total precipitation          (T-point)      [Kg/m2/s]
+      REAL(wp), DIMENSION(:,:)  , INTENT(  out) ::   p_spr    ! solid precipitation          (T-point)      [Kg/m2/s]
+      REAL(wp), DIMENSION(:,:)  , INTENT(  out) ::   p_fr1    ! 1sr fraction of qsr penetration in ice (T-point)  [%]
+      REAL(wp), DIMENSION(:,:)  , INTENT(  out) ::   p_fr2    ! 2nd fraction of qsr penetration in ice (T-point)  [%]
+      CHARACTER(len=1)          , INTENT(in   ) ::   cd_grid  ! ice grid ( C or B-grid)
+      INTEGER                   , INTENT(in   ) ::   pdim     ! number of ice categories
       !!
       INTEGER  ::   ji, jj, jl    ! dummy loop indices
@@ -447,8 +445,7 @@
 
       ! Set-up access to workspace arrays
-      IF( wrk_in_use(2, 1) .OR. wrk_in_use(3, 4,5,6,7) )THEN
-         CALL ctl_stop('blk_ice_core: requested workspace arrays unavailable.')
-         RETURN
-      ELSE IF(ijpl > jpk)THEN
+      IF( wrk_in_use(2, 1) .OR. wrk_in_use(3, 4,5,6,7) ) THEN
+         CALL ctl_stop('blk_ice_core: requested workspace arrays unavailable')   ;   RETURN
+      ELSE IF(ijpl > jpk) THEN
          CALL ctl_stop('blk_ice_core: no. of ice categories > jpk so wrk_nemo 3D workspaces cannot be used.')
          RETURN
@@ -608,13 +605,12 @@
       ENDIF
 
-      IF( wrk_not_released(2, 1) .OR. wrk_not_released(3, 4,5,6,7) )THEN
-         CALL ctl_stop('blk_ice_core: failed to release workspace arrays.')
-      END IF
-
+      IF( wrk_not_released(2, 1) .OR.   &
+          wrk_not_released(3, 4,5,6,7) )   CALL ctl_stop('blk_ice_core: failed to release workspace arrays')
+      !
    END SUBROUTINE blk_ice_core
   
 
    SUBROUTINE TURB_CORE_1Z(zu, sst, T_a, q_sat, q_a,   &
-      &                        dU, Cd, Ch, Ce   )
+      &                        dU , Cd , Ch   , Ce   )
       !!----------------------------------------------------------------------
       !!                      ***  ROUTINE  turb_core  ***
@@ -629,9 +625,5 @@
       !!      are provided at the same height 'zzu'!
       !!
-      !! References :
-      !!      Large & Yeager, 2004 : ???
-      !! History :
-      !!        !  XX-XX  (???     )  Original code
-      !!   9.0  !  05-08  (L. Brodeau) Rewriting and optimization
+      !! References :   Large & Yeager, 2004 : ???
       !!----------------------------------------------------------------------
       USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released, iwrk_in_use, iwrk_not_released
@@ -651,36 +643,30 @@
       USE wrk_nemo, ONLY: zeta => wrk_2d_27        ! stability parameter at height zu
       USE wrk_nemo, ONLY: U_n10 => wrk_2d_28       ! neutral wind velocity at 10m     [m]
-      USE wrk_nemo, ONLY: xlogt => wrk_2d_29,    xct => wrk_2d_30,   &
-                         zpsi_h => wrk_2d_31, zpsi_m => wrk_2d_32
+      USE wrk_nemo, ONLY: xlogt  => wrk_2d_29,    xct => wrk_2d_30,   &
+                          zpsi_h => wrk_2d_31, zpsi_m => wrk_2d_32
       USE wrk_nemo, ONLY: stab => iwrk_2d_1      ! 1st guess stability test integer
-      !!
-      REAL(wp), INTENT(in) :: zu                 ! altitude of wind measurement       [m]
-      REAL(wp), INTENT(in),  DIMENSION(:,:) ::  &
-         sst,       &       ! sea surface temperature         [Kelvin]
-         T_a,       &       ! potential air temperature       [Kelvin]
-         q_sat,     &       ! sea surface specific humidity   [kg/kg]
-         q_a,       &       ! specific air humidity           [kg/kg]
-         dU                 ! wind module |U(zu)-U(0)|        [m/s]
-      REAL(wp), intent(out), DIMENSION(:,:) :: &
-         Cd,    &                ! transfert coefficient for momentum       (tau)
-         Ch,    &                ! transfert coefficient for temperature (Q_sens)
-         Ce                      ! transfert coefficient for evaporation  (Q_lat)
+      !
+      REAL(wp)                , INTENT(in   ) ::   zu      ! altitude of wind measurement       [m]
+      REAL(wp), DIMENSION(:,:), INTENT(in   ) ::   sst     ! sea surface temperature         [Kelvin]
+      REAL(wp), DIMENSION(:,:), INTENT(in   ) ::   T_a     ! potential air temperature       [Kelvin]
+      REAL(wp), DIMENSION(:,:), INTENT(in   ) ::   q_sat   ! sea surface specific humidity   [kg/kg]
+      REAL(wp), DIMENSION(:,:), INTENT(in   ) ::   q_a     ! specific air humidity           [kg/kg]
+      REAL(wp), DIMENSION(:,:), INTENT(in   ) ::   dU      ! wind module |U(zu)-U(0)|        [m/s]
+      REAL(wp), DIMENSION(:,:), INTENT(  out) ::   Cd      ! transfert coefficient for momentum       (tau)
+      REAL(wp), DIMENSION(:,:), INTENT(  out) ::   Ch      ! transfert coefficient for temperature (Q_sens)
+      REAL(wp), DIMENSION(:,:), INTENT(  out) ::   Ce      ! transfert coefficient for evaporation  (Q_lat)
       !!
       INTEGER :: j_itt
-      INTEGER, PARAMETER :: nb_itt = 3
-
-      REAL(wp), PARAMETER ::                        &
-         grav   = 9.8,          &  ! gravity                       
-         kappa  = 0.4              ! von Karman s constant
+      INTEGER , PARAMETER ::   nb_itt = 3
+      REAL(wp), PARAMETER ::   grav   = 9.8   ! gravity                       
+      REAL(wp), PARAMETER ::   kappa  = 0.4   ! von Karman s constant
       !!----------------------------------------------------------------------
 
-      IF( wrk_in_use(2, 14,15,16,17,18,         &
-                        19,20,21,22,23,24,      &
-                        25,26,27,28,29,30,      &
-                        31,32)             .OR. &
-          iwrk_in_use(2, 1) )THEN
-         CALL ctl_stop('TURB_CORE_1Z: requested workspace arrays unavailable.')
-         RETURN
-      END IF
+      IF( wrk_in_use(2,             14,15,16,17,18,19,      &
+                        20,21,22,23,24,25,26,27,28,29,      &
+                        30,31,32)                      .OR. &
+          iwrk_in_use(2, 1)                              ) THEN
+         CALL ctl_stop('TURB_CORE_1Z: requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
 
       !! * Start
@@ -743,12 +729,10 @@
       END DO
       !!
-      IF( wrk_not_released(2, 14,15,16,17,18,          &
-                              19,20,21,22,23,24,       &
-                              25,26,27,28,29,30,       &
-                              31,32)              .OR. &
-          iwrk_not_released(2, 1) )THEN
-         CALL ctl_stop('TURB_CORE_1Z: failed to release workspace arrays.')
-      END IF
-      !!
+      IF( wrk_not_released(2,             14,15,16,17,18,19,          &
+         &                    20,21,22,23,24,25,26,27,28,29,          &
+         &                    30,31,32                      )   .OR.  &      
+         iwrk_not_released(2, 1)                                  )   &
+         CALL ctl_stop('TURB_CORE_1Z: failed to release workspace arrays')
+      !
     END SUBROUTINE TURB_CORE_1Z
 
@@ -767,8 +751,5 @@
       !!      whereas wind (dU) is at 10m.
       !!
-      !! References :
-      !!      Large & Yeager, 2004 : ???
-      !! History :
-      !!   9.0  !  06-12  (L. Brodeau) Original code for 2Z
+      !! References :   Large & Yeager, 2004 : ???
       !!----------------------------------------------------------------------
       USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released, iwrk_in_use, iwrk_not_released
@@ -899,5 +880,5 @@
          CALL ctl_stop('TURB_CORE_2Z: requested workspace arrays unavailable.')
       END IF
-
+      !
     END SUBROUTINE TURB_CORE_2Z
 
@@ -926,5 +907,5 @@
            & + (1. - stabit)*(2*log((1. + X)/2) + log((1. + X2)/2) - 2*atan(X) + pi/2)  ! Unstable 
 
-      IF(wrk_not_released(2, 33,34,35))THEN
+      IF( wrk_not_released(2, 33,34,35) ) THEN
          CALL ctl_stop('psi_m: failed to release workspace arrays.')
          RETURN
@@ -946,8 +927,7 @@
       !-------------------------------------------------------------------------------
 
-      IF(wrk_in_use(2, 33,34,35))THEN
-         CALL ctl_stop('psi_h: requested workspace arrays unavailable.')
-         RETURN
-      END IF
+      IF( wrk_in_use(2, 33,34,35) ) THEN
+         CALL ctl_stop('psi_h: requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
 
       X2 = sqrt(abs(1. - 16.*zta))  ;  X2 = max(X2 , 1.) ;  X  = sqrt(X2)
@@ -956,9 +936,6 @@
            & + (1. - stabit)*(2.*log( (1. + X2)/2. ))                 ! Unstable
 
-      IF(wrk_not_released(2, 33,34,35))THEN
-         CALL ctl_stop('psi_h: failed to release workspace arrays.')
-         RETURN
-      END IF
-
+      IF( wrk_not_released(2, 33,34,35) )   CALL ctl_stop('psi_h: failed to release workspace arrays.')
+      !
     END FUNCTION psi_h
   
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 2636)
@@ -223,7 +223,7 @@
       !!---------------------------------------------------------------------
 
-      IF(wrk_in_use(2,1,2) ) THEN
-         CALL ctl_stop('sbc_cpl_init: requested workspace arrays unavailable.')   ;   RETURN
-      END IF
+      IF(wrk_in_use(2, 1,2) ) THEN
+         CALL ctl_stop('sbc_cpl_init: requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
 
       ! ================================ !
@@ -563,8 +563,6 @@
          &   CALL ctl_stop( 'sbc_cpl_init: diurnal cycle reconstruction (ln_dm2dc) needs daily couping for solar radiation' )
 
-      IF(wrk_not_released(2,1,2))THEN
-         CALL ctl_stop('sbc_cpl_init: failed to release workspace arrays.')
-      END IF
-
+      IF( wrk_not_released(2, 1,2) )   CALL ctl_stop('sbc_cpl_init: failed to release workspace arrays.')
+      !
    END SUBROUTINE sbc_cpl_init
 
@@ -629,8 +627,7 @@
       !!----------------------------------------------------------------------
 
-      IF(wrk_in_use(2, 1,2))THEN
-         CALL ctl_stop('sbc_cpl_rcv: requested workspace arrays unavailable.')
-         RETURN
-      END IF
+      IF( wrk_in_use(2, 1,2) ) THEN
+         CALL ctl_stop('sbc_cpl_rcv: requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
 
       IF( kt == nit000 )   CALL sbc_cpl_init( k_ice )          ! initialisation
@@ -820,7 +817,5 @@
       ENDIF
       !
-      IF(wrk_not_released(2, 1,2))THEN
-         CALL ctl_stop('sbc_cpl_rcv: failed to release workspace arrays.')
-      END IF
+      IF( wrk_not_released(2, 1,2) )   CALL ctl_stop('sbc_cpl_rcv: failed to release workspace arrays')
       !
    END SUBROUTINE sbc_cpl_rcv
@@ -870,8 +865,7 @@
       !!----------------------------------------------------------------------
 
-      IF(wrk_in_use(2,1,2))THEN
-         CALL ctl_stop('sbc_cpl_ice_tau: requested workspace arrays unavailable.')
-         RETURN
-      END IF
+      IF( wrk_in_use(2, 1,2) ) THEN
+         CALL ctl_stop('sbc_cpl_ice_tau: requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
 
       IF( srcv(jpr_itx1)%laction ) THEN   ;   itx =  jpr_itx1   
@@ -1041,7 +1035,5 @@
       ENDIF
       !   
-      IF(wrk_not_released(2,1,2))THEN
-         CALL ctl_stop('sbc_cpl_ice_tau: failed to release workspace arrays.')
-      END IF
+      IF( wrk_not_released(2, 1,2) )   CALL ctl_stop('sbc_cpl_ice_tau: failed to release workspace arrays')
       !
    END SUBROUTINE sbc_cpl_ice_tau
@@ -1118,8 +1110,7 @@
       !!----------------------------------------------------------------------
 
-      IF( wrk_in_use(2,1,2,3) .OR. wrk_in_use(3,1) )THEN
-         CALL ctl_stop('sbc_cpl_ice_flx: requested workspace arrays unavailable.')
-         RETURN
-      END IF
+      IF( wrk_in_use(2, 1,2,3) .OR. wrk_in_use(3, 1) ) THEN
+         CALL ctl_stop('sbc_cpl_ice_flx: requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
 
       zicefr(:,:,1) = 1.- p_frld(:,:,1)
@@ -1240,8 +1231,7 @@
       END SELECT
 
-      IF( wrk_not_released(2,1,2,3) .OR. wrk_not_released(3,1) )THEN
-         CALL ctl_stop('sbc_cpl_ice_flx: failed to release workspace arrays.')
-      END IF
-
+      IF( wrk_not_released(2, 1,2,3) .OR.   &
+          wrk_not_released(3, 1)      )   CALL ctl_stop('sbc_cpl_ice_flx: failed to release workspace arrays')
+      !
    END SUBROUTINE sbc_cpl_ice_flx
    
@@ -1268,8 +1258,7 @@
       !!----------------------------------------------------------------------
 
-      IF(wrk_in_use(2, 1,2,3,4,5,6,7,8,9))THEN
-         CALL ctl_stop('sbc_cpl_snd: requested workspace arrays are unavailable.');
-         RETURN
-      END IF
+      IF( wrk_in_use(2, 1,2,3,4,5,6,7,8,9) ) THEN
+         CALL ctl_stop('sbc_cpl_snd: requested workspace arrays are unavailable')   ;   RETURN
+      ENDIF
 
       isec = ( kt - nit000 ) * NINT(rdttra(1))        ! date of exchanges
@@ -1444,10 +1433,7 @@
          ! 
       ENDIF
-   !
-      IF(wrk_not_released(2, 1,2,3,4,5,6,7,8,9))THEN
-         CALL ctl_stop('sbc_cpl_snd: failed to release workspace arrays.');
-         RETURN
-      END IF
-   !
+      !
+      IF( wrk_not_released(2, 1,2,3,4,5,6,7,8,9) )   CALL ctl_stop('sbc_cpl_snd: failed to release workspace arrays')
+      !
    END SUBROUTINE sbc_cpl_snd
    
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/sbcdcy.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/sbcdcy.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/sbcdcy.F90	(revision 2636)
@@ -10,6 +10,5 @@
 
    !!----------------------------------------------------------------------
-   !!  sbc_dcy : compute solar flux at kt from daily mean, taking 
-   !!            diurnal cycle into account
+   !!  sbc_dcy : solar flux at kt from daily mean, taking diurnal cycle into account
    !!----------------------------------------------------------------------
    USE oce              ! ocean dynamics and tracers
@@ -33,5 +32,5 @@
    !! NEMO/OPA 3.3 , NEMO-consortium (2010) 
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -41,5 +40,4 @@
          !!                ***  FUNCTION sbc_dcy_alloc  ***
          !!----------------------------------------------------------------------
-         !
          ALLOCATE( raa (jpi,jpj) , rbb  (jpi,jpj) , rcc  (jpi,jpj) , rab  (jpi,jpj) ,     &
             &      rtmd(jpi,jpj) , rdawn(jpi,jpj) , rdusk(jpi,jpj) , rscal(jpi,jpj) , STAT=sbc_dcy_alloc )
@@ -47,5 +45,4 @@
          IF( lk_mpp             )   CALL mpp_sum ( sbc_dcy_alloc )
          IF( sbc_dcy_alloc /= 0 )   CALL ctl_warn('sbc_dcy_alloc: failed to allocate arrays')
-         !
       END FUNCTION sbc_dcy_alloc
 
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_if.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_if.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_if.F90	(revision 2636)
@@ -19,4 +19,5 @@
    USE iom             ! I/O manager library
    USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_lim.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_lim.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_lim.F90	(revision 2636)
@@ -22,5 +22,4 @@
    USE oce             ! ocean dynamics and tracers
    USE dom_oce         ! ocean space and time domain
-   USE lib_mpp         ! MPP library
    USE par_ice         ! sea-ice parameters
    USE ice             ! LIM-3: ice variables
@@ -50,4 +49,5 @@
    USE c1d             ! 1D vertical configuration
    USE lbclnk          ! lateral boundary condition - MPP link
+   USE lib_mpp         ! MPP library
    USE iom             ! I/O manager library
    USE in_out_manager  ! I/O manager
@@ -101,5 +101,5 @@
 
       IF( wrk_in_use(3, 1,2) ) THEN
-         CALL ctl_stop( 'sbc_ice_lim: requested workspace arrays are unavailable.' )   ;   RETURN
+         CALL ctl_stop( 'sbc_ice_lim: requested workspace arrays are unavailable' )   ;   RETURN
       ENDIF
 
@@ -252,5 +252,5 @@
 !!gm   remark, the ocean-ice stress is not saved in ice diag call above .....  find a solution!!!
       !
-      IF( wrk_not_released(3, 1,2) )   CALL ctl_stop( 'sbc_ice_lim: failed to release workspace arrays.' )
+      IF( wrk_not_released(3, 1,2) )   CALL ctl_stop( 'sbc_ice_lim: failed to release workspace arrays' )
       !
    END SUBROUTINE sbc_ice_lim
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_lim_2.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_lim_2.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_lim_2.F90	(revision 2636)
@@ -96,7 +96,7 @@
       !!----------------------------------------------------------------------
 
-      IF(wrk_in_use(3, 1,2,3) ) THEN
+      IF( wrk_in_use(3, 1,2,3) ) THEN
          CALL ctl_stop('sbc_ice_lim_2: requested workspace arrays are unavailable.')   ;   RETURN
-      END IF
+      ENDIF
       ! Use pointers to access only sub-arrays of workspaces
       zalb_ice_os => wrk_3d_1(:,:,1:1)
@@ -228,5 +228,5 @@
       IF( ln_limdyn    )   CALL lim_sbc_tau_2( kt, ub(:,:,1), vb(:,:,1) )  ! using before instantaneous surf. currents
       !
-      IF(wrk_not_released(3, 1,2,3) )   CALL ctl_stop('sbc_ice_lim_2: failed to release workspace arrays')
+      IF( wrk_not_released(3, 1,2,3) )   CALL ctl_stop('sbc_ice_lim_2: failed to release workspace arrays')
       !
    END SUBROUTINE sbc_ice_lim_2
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 2636)
@@ -38,6 +38,6 @@
    USE sbcfwb           ! surface boundary condition: freshwater budget
    USE closea           ! closed sea
-   USE bdy_par         ! unstructured open boundary data variables
-   USE bdyice          ! unstructured open boundary data  (bdy_ice_frs routine)
+   USE bdy_par          ! unstructured open boundary data variables
+   USE bdyice           ! unstructured open boundary data  (bdy_ice_frs routine)
 
    USE prtctl           ! Print control                    (prt_ctl routine)
@@ -45,4 +45,5 @@
    USE iom              ! IOM library
    USE in_out_manager   ! I/O manager
+   USE lib_mpp          ! MPP library
 
    IMPLICIT NONE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/sbcrnf.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/sbcrnf.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SBC/sbcrnf.F90	(revision 2636)
@@ -19,9 +19,10 @@
    USE phycst          ! physical constants
    USE sbc_oce         ! surface boundary condition variables
+   USE closea          ! closed seas
    USE fldread         ! read input field at current time step
+   USE restart         ! restart
    USE in_out_manager  ! I/O manager
    USE iom             ! I/O module
-   USE restart         ! restart
-   USE closea          ! closed seas
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SOL/solpcg.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SOL/solpcg.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SOL/solpcg.F90	(revision 2636)
@@ -26,5 +26,5 @@
    !! NEMO/OPA 3.3 , NEMO Consortium (2010)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
 CONTAINS
@@ -83,26 +83,24 @@
       !!        !  08-01  (R. Benshila) mpp optimization
       !!----------------------------------------------------------------------
-      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
-      USE wrk_nemo, ONLY: zgcr => wrk_2d_1
-      !!
-      INTEGER, INTENT( inout ) ::   kindic   ! solver indicator, < 0 if the conver-
-      !                                      ! gence is not reached: the model is
-      !                                      ! stopped in step
-      !                                      ! set to zero before the call of solpcg
-      !!
-      INTEGER ::   ji, jj, jn                ! dummy loop indices
-      REAL(wp) ::  zgcad                     ! temporary scalars
-      REAL(wp), DIMENSION(2) :: zsum
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY:   zgcr => wrk_2d_1
+      !!
+      INTEGER, INTENT(inout) ::   kindic   ! solver indicator, < 0 if the conver-
+      !                                    ! gence is not reached: the model is stopped in step
+      !                                    ! set to zero before the call of solpcg
+      !!
+      INTEGER  ::   ji, jj, jn   ! dummy loop indices
+      REAL(wp) ::   zgcad        ! temporary scalars
+      REAL(wp), DIMENSION(2) ::   zsum
       !!----------------------------------------------------------------------
       
       IF( wrk_in_use(2, 1) )THEN
-         CALL ctl_stop('sol_pcg: requested workspace array is unavailable')
-         RETURN
-      END IF
+         CALL ctl_stop('sol_pcg: requested workspace array is unavailable')   ;   RETURN
+      ENDIF
 
       ! Initialization of the algorithm with standard PCG
       ! -------------------------------------------------
-      zgcr = 0.e0 
-      gcr  = 0.e0 
+      zgcr = 0._wp
+      gcr  = 0._wp
 
       CALL lbc_lnk( gcx, c_solver_pt, 1. )   ! lateral boundary condition
@@ -207,17 +205,9 @@
       END DO                                           !    End Loop
       !                                                !================
-     
 999   CONTINUE
-     
-     
-      ! Output in gcx with lateral b.c. applied
-      ! ---------------------------------------
-     
-      CALL lbc_lnk( gcx, c_solver_pt, 1. )
-     
+          
+      CALL lbc_lnk( gcx, c_solver_pt, 1. )      ! Output in gcx with lateral b.c. applied
       ! 
-      IF( wrk_not_released(2, 1) )THEN
-         CALL ctl_stop('sol_pcg: failed to release workspace array')
-      END IF
+      IF( wrk_not_released(2, 1) )   CALL ctl_stop('sol_pcg: failed to release workspace array')
       !
    END SUBROUTINE sol_pcg
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SOL/solsor.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SOL/solsor.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SOL/solsor.F90	(revision 2636)
@@ -32,7 +32,6 @@
    !! NEMO/OPA 3.3 , NEMO Consortium (2010)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-
 CONTAINS
       
@@ -58,20 +57,18 @@
       !!                Beare and Stevens 1997 Ann. Geophysicae 15, 1369-1377
       !!----------------------------------------------------------------------
-      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
-      USE wrk_nemo, ONLY: ztab => wrk_2d_1
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY:   ztab => wrk_2d_1    ! 2D workspace
       !!
       INTEGER, INTENT(inout) ::   kindic   ! solver indicator, < 0 if the convergence is not reached:
       !                                    ! the model is stopped in step (set to zero before the call of solsor)
       !!
-      INTEGER  ::   ji, jj, jn               ! dummy loop indices
-      INTEGER  ::   ishift, icount
-      INTEGER  ::   ijmppodd, ijmppeven, ijpr2d
-      REAL(wp) ::   ztmp, zres, zres2
+      INTEGER  ::   ji, jj, jn       ! dummy loop indices
+      INTEGER  ::   ishift, icount, ijmppodd, ijmppeven, ijpr2d   ! local integers
+      REAL(wp) ::   ztmp, zres, zres2                             ! local scalars
       !!----------------------------------------------------------------------
       
       IF( wrk_in_use(2, 1) )THEN
-         CALL ctl_stop('sol_sor: requested workspace array is unavailable')
-         RETURN
-      END IF
+         CALL ctl_stop('sol_sor: requested workspace array is unavailable')   ;   RETURN
+      ENDIF
 
       ijmppeven = MOD( nimpp+njmpp+jpr2di+jpr2dj   , 2 )
@@ -171,7 +168,5 @@
       CALL lbc_lnk_e( gcx, c_solver_pt, 1. )    ! boundary conditions
       ! 
-      IF( wrk_not_released(2, 1) )THEN
-         CALL ctl_stop('sol_sor: failed to release workspace array')
-      END IF
+      IF( wrk_not_released(2, 1) )   CALL ctl_stop('sol_sor: failed to release workspace array')
       !
    END SUBROUTINE sol_sor
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SOL/solver.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SOL/solver.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/SOL/solver.F90	(revision 2636)
@@ -26,5 +26,5 @@
    USE in_out_manager  ! I/O manager
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
-   USE lib_mpp
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
@@ -35,5 +35,4 @@
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-
 CONTAINS
 
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/eosbn2.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/eosbn2.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/eosbn2.F90	(revision 2636)
@@ -33,6 +33,7 @@
    USE dom_oce         ! ocean space and time domain
    USE phycst          ! physical constants
+   USE zdfddm          ! vertical physics: double diffusion
    USE in_out_manager  ! I/O manager
-   USE zdfddm          ! vertical physics: double diffusion
+   USE lib_mpp         ! MPP library
    USE prtctl          ! Print control
 
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/traadv.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/traadv.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/traadv.F90	(revision 2636)
@@ -24,6 +24,7 @@
    USE ldftra_oce      ! lateral diffusion coefficient on tracers
    USE in_out_manager  ! I/O manager
+   USE iom             ! I/O module
    USE prtctl          ! Print control
-   USE iom
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_cen2.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_cen2.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_cen2.F90	(revision 2636)
@@ -31,4 +31,5 @@
    USE restart         ! ocean restart
    USE trc_oce         ! share passive tracers/Ocean variables
+   USE lib_mpp           ! MPP library
 
    IMPLICIT NONE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_bilap.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_bilap.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_bilap.F90	(revision 2636)
@@ -28,4 +28,5 @@
    USE diaptr          ! poleward transport diagnostics
    USE trc_oce         ! share passive tracers/Ocean variables
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
@@ -166,7 +167,5 @@
       END DO                                              ! tracer loop
       !                                                   ! ===========
-      IF(wrk_not_released(2, 1,2,3))THEN
-         CALL ctl_stop('tra_ldf_bilap: failed to release workspace arrays.')
-      END IF
+      IF( wrk_not_released(2, 1,2,3) )   CALL ctl_stop('tra_ldf_bilap: failed to release workspace arrays')
       !
    END SUBROUTINE tra_ldf_bilap
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_bilapg.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_bilapg.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_bilapg.F90	(revision 2636)
@@ -24,4 +24,5 @@
    USE diaptr          ! poleward transport diagnostics 
    USE trc_oce         ! share passive tracers/Ocean variables
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_iso_grif.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_iso_grif.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_iso_grif.F90	(revision 2636)
@@ -25,4 +25,5 @@
    USE iom             ! I/O library
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/tranpc.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/tranpc.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/tranpc.F90	(revision 2636)
@@ -18,8 +18,9 @@
    USE zdf_oce         ! ocean vertical physics
    USE trdmod_oce      ! ocean active tracer trends
-   USE trdtra      ! ocean active tracer trends
+   USE trdtra          ! ocean active tracer trends
    USE eosbn2          ! equation of state (eos routine) 
    USE lbclnk          ! lateral boundary conditions (or mpp link)
    USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/traqsr.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/traqsr.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/traqsr.F90	(revision 2636)
@@ -28,4 +28,5 @@
    USE fldread         ! read input fields
    USE restart         ! ocean restart
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/trazdf.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/trazdf.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/trazdf.F90	(revision 2636)
@@ -14,4 +14,6 @@
    USE oce             ! ocean dynamics and tracers variables
    USE dom_oce         ! ocean space and time domain variables 
+   USE domvvl          ! variable volume
+   USE phycst          ! physical constant
    USE zdf_oce         ! ocean vertical physics variables
    USE sbc_oce         ! surface boundary condition: ocean
@@ -26,8 +28,7 @@
    USE in_out_manager  ! I/O manager
    USE prtctl          ! Print control
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp         ! MPP library
 
-   USE phycst
-   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
-   USE domvvl          ! variable volume
 
    IMPLICIT NONE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/trazdf_exp.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/trazdf_exp.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/trazdf_exp.F90	(revision 2636)
@@ -28,6 +28,7 @@
    USE zdf_oce         ! ocean vertical physics
    USE zdfddm          ! ocean vertical physics: double diffusion
+   USE trc_oce         ! share passive tracers/Ocean variables
    USE in_out_manager  ! I/O manager
-   USE trc_oce         ! share passive tracers/Ocean variables
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
@@ -43,7 +44,6 @@
    !! NEMO/OPA 3.3 , NEMO Consortium (2010)
    !! $Id$
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-
 CONTAINS
 
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/trazdf_imp.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/trazdf_imp.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/trazdf_imp.F90	(revision 2636)
@@ -33,4 +33,5 @@
    USE in_out_manager  ! I/O manager
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/zpshde.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/zpshde.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/zpshde.F90	(revision 2636)
@@ -20,4 +20,5 @@
    USE in_out_manager  ! I/O manager
    USE lbclnk          ! lateral boundary conditions (or mpp link)
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRD/trdmld_oce.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRD/trdmld_oce.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRD/trdmld_oce.F90	(revision 2636)
@@ -91,5 +91,4 @@
      !!                 ***  FUNCTION trdmld_oce_alloc   ***
      !!----------------------------------------------------------------------
-     USE in_out_manager, ONLY: ctl_warn
      USE lib_mpp
      INTEGER :: ierr(5)
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRD/trdmod.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRD/trdmod.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRD/trdmod.F90	(revision 2636)
@@ -24,4 +24,5 @@
    USE trdmld                  ! ocean active mixed layer tracers trends 
    USE in_out_manager          ! I/O manager
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRD/trdmod_trc.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRD/trdmod_trc.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRD/trdmod_trc.F90	(revision 2636)
@@ -4,9 +4,4 @@
    !!  Dummy module
    !!======================================================================
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
    !!----------------------------------------------------------------------
    !!   Dummy module                                             NO TOP use
@@ -21,4 +16,8 @@
    END SUBROUTINE trd_mod_trc
 
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
+   !! $Id$
+   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
    !!======================================================================
 END MODULE trdmod_trc
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRD/trdtra.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRD/trdtra.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRD/trdtra.F90	(revision 2636)
@@ -17,4 +17,5 @@
    USE trdmod_trc       ! ocean passive mixed layer tracers trends 
    USE in_out_manager   ! I/O manager
+   USE lib_mpp          ! MPP library
 
    IMPLICIT NONE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/ZDF/zdf_oce.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/ZDF/zdf_oce.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/ZDF/zdf_oce.F90	(revision 2636)
@@ -9,4 +9,5 @@
    USE par_oce        ! ocean parameters
    USE in_out_manager ! I/O manager
+   USE lib_mpp        ! MPP library
 
    IMPLICIT NONE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfddm.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfddm.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfddm.F90	(revision 2636)
@@ -21,4 +21,5 @@
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
    USE prtctl          ! Print control
+   USE lib_mpp            ! MPP library
 
    IMPLICIT NONE
@@ -56,4 +57,5 @@
       IF( zdf_ddm_alloc /= 0 )   CALL ctl_warn('zdf_ddm_alloc: failed to allocate arrays')
    END FUNCTION zdf_ddm_alloc
+
 
    SUBROUTINE zdf_ddm( kt )
@@ -89,13 +91,10 @@
       !! References :   Merryfield et al., JPO, 29, 1124-1142, 1999.
       !!----------------------------------------------------------------------
-      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
-      USE wrk_nemo, ONLY: zmsks  => wrk_2d_1,  &
-                          zmskf  => wrk_2d_2,  &
-                          zmskd1 => wrk_2d_3,  &
-                          zmskd2 => wrk_2d_4,  &
-                          zmskd3 => wrk_2d_5
-      IMPLICIT none
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY:   zmsks  => wrk_2d_1 , zmskf  => wrk_2d_2 , zmskd1 => wrk_2d_3   ! 2D workspace
+      USE wrk_nemo, ONLY:   zmskd2 => wrk_2d_4 , zmskd3 => wrk_2d_5                        !  -      -
+      !
       INTEGER, INTENT(in) ::   kt   ! ocean time-step indexocean time step
-      !!
+      !
       INTEGER  ::   ji, jj , jk     ! dummy loop indices
       REAL(wp) ::   zinr, zrr       ! temporary scalars
@@ -105,5 +104,5 @@
 
       IF( wrk_in_use(2, 1,2,3,4,5) ) THEN
-         CALL ctl_stop('zdf_ddm: Requested workspace arrays already in use.')   ;   RETURN
+         CALL ctl_stop('zdf_ddm: Requested workspace arrays already in use')   ;   RETURN
       END IF
 
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfgls.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfgls.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfgls.F90	(revision 2636)
@@ -25,4 +25,5 @@
    USE restart        ! only for lrst_oce
    USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp        ! MPP manager
    USE prtctl         ! Print control
    USE in_out_manager ! I/O manager
@@ -106,5 +107,5 @@
    !!----------------------------------------------------------------------
    !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id $
+   !! $Id$
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfkpp.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfkpp.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfkpp.F90	(revision 2636)
@@ -28,4 +28,5 @@
    USE zdfddm          ! double diffusion mixing
    USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! MPP library
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
    USE prtctl          ! Print control
@@ -167,5 +168,5 @@
          !
       IF( lk_mpp             )   CALL mpp_sum ( zdf_kpp_alloc )
-      IF( zdf_kpp_alloc /= 0 )   CALL ctl_warn('zdf_kpp_alloc: failed to allocate arrays.')
+      IF( zdf_kpp_alloc /= 0 )   CALL ctl_warn('zdf_kpp_alloc: failed to allocate arrays')
    END FUNCTION zdf_kpp_alloc
 
@@ -1236,5 +1237,5 @@
       IF( wrk_not_released(1, 1,2,3,4,5,6,7,8,9,10,11,12,13,14) .OR. &
           wrk_not_released(2, 1,2,3,4,5,6,7,8,9,10,11)          .OR. &
-          wrk_not_released_xz(1,2,3)  )   CALL ctl_stop('zdf_kpp : failed to release workspace arrays.')
+          wrk_not_released_xz(1,2,3)  )   CALL ctl_stop('zdf_kpp : failed to release workspace arrays')
       !
    END SUBROUTINE zdf_kpp
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfmxl.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfmxl.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfmxl.F90	(revision 2636)
@@ -14,5 +14,6 @@
    USE in_out_manager  ! I/O manager
    USE prtctl          ! Print control
-   USE iom
+   USE iom             ! I/O library
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
@@ -64,5 +65,5 @@
       !!----------------------------------------------------------------------
       USE wrk_nemo, ONLY: iwrk_in_use, iwrk_not_released
-      USE wrk_nemo, ONLY: imld => iwrk_2d_1    ! 2D workspace
+      USE wrk_nemo, ONLY: imld => iwrk_2d_1    ! 2D integer workspace
       !!
       INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
@@ -74,6 +75,6 @@
       !!----------------------------------------------------------------------
 
-      IF( iwrk_in_use(2,1) )THEN
-         CALL ctl_stop('zdf_mxl : requested workspace array unavailable.')   ;   RETURN
+      IF( iwrk_in_use(2, 1) )THEN
+         CALL ctl_stop('zdf_mxl : requested workspace array unavailable')   ;   RETURN
       END IF
 
@@ -112,5 +113,5 @@
       IF(ln_ctl)   CALL prt_ctl( tab2d_1=REAL(nmln,wp), clinfo1=' nmln : ', tab2d_2=hmlp, clinfo2=' hmlp : ', ovlap=1 )
       !
-      IF( iwrk_not_released(2,1) )   CALL ctl_stop('zdf_mxl : failed to release workspace array')
+      IF( iwrk_not_released(2, 1) )   CALL ctl_stop('zdf_mxl : failed to release workspace array')
       !
    END SUBROUTINE zdf_mxl
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfric.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfric.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfric.F90	(revision 2636)
@@ -25,4 +25,5 @@
    USE in_out_manager  ! I/O manager
    USE lbclnk          ! ocean lateral boundary condition (or mpp link)
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
@@ -57,5 +58,5 @@
       !
       IF( lk_mpp             )   CALL mpp_sum ( zdf_ric_alloc )
-      IF( zdf_ric_alloc /= 0 )   CALL ctl_warn('zdf_ric_alloc: failed to allocate arrays.')
+      IF( zdf_ric_alloc /= 0 )   CALL ctl_warn('zdf_ric_alloc: failed to allocate arrays')
    END FUNCTION zdf_ric_alloc
 
@@ -97,5 +98,5 @@
       !!----------------------------------------------------------------------
 
-      IF(wrk_in_use(2, 1) ) THEN
+      IF( wrk_in_use(2, 1) ) THEN
          CALL ctl_stop('zdf_ric : requested workspace array unavailable')   ;   RETURN
       END IF
@@ -150,5 +151,5 @@
       CALL lbc_lnk( avmu, 'U', 1. )   ;   CALL lbc_lnk( avmv, 'V', 1. )
       !
-      IF(wrk_not_released(2, 1) )   CALL ctl_stop('zdf_ric : failed to release workspace array')
+      IF( wrk_not_released(2, 1) )   CALL ctl_stop('zdf_ric : failed to release workspace array')
       !
    END SUBROUTINE zdf_ric
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/ZDF/zdftke.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/ZDF/zdftke.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/ZDF/zdftke.F90	(revision 2636)
@@ -49,4 +49,5 @@
    USE in_out_manager ! I/O manager
    USE iom            ! I/O manager library
+   USE lib_mpp        ! MPP library
 
    IMPLICIT NONE
@@ -189,11 +190,9 @@
       !!                (= Kz dz[Ub] * dz[Un] )
       !! ---------------------------------------------------------------------
-      USE oce,   zdiag  =>   ua   ! use ua as workspace
-      USE oce,   zd_up  =>   va   ! use va as workspace
-      USE oce,   zd_lw  =>   ta   ! use ta as workspace
-      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released, iwrk_in_use, iwrk_not_released
-      USE wrk_nemo, ONLY: imlc => iwrk_2d_1 ! 2D INTEGER workspace
-      USE wrk_nemo, ONLY: zhlc => wrk_2d_1  ! 2D REAL workspace
-      USE wrk_nemo, ONLY: zpelc => wrk_3d_1 ! 3D REAL workspace
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released, iwrk_in_use, iwrk_not_released
+      USE oce     , ONLY:   zdiag => ua , zd_up => va , zd_lw => ta   ! (ua,va,ta) used  as workspace
+      USE wrk_nemo, ONLY:   imlc  => iwrk_2d_1   ! 2D INTEGER workspace
+      USE wrk_nemo, ONLY:   zhlc  =>  wrk_2d_1   ! 2D REAL workspace
+      USE wrk_nemo, ONLY:   zpelc =>  wrk_3d_1   ! 3D REAL workspace
       !!
       INTEGER  ::   ji, jj, jk                      ! dummy loop arguments
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/ZDF/zdftmx.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/ZDF/zdftmx.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/ZDF/zdftmx.F90	(revision 2636)
@@ -24,4 +24,5 @@
    USE in_out_manager  ! I/O manager
    USE iom             ! I/O Manager
+   USE lib_mpp         ! MPP library
    USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
 
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/lib_print.f90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/lib_print.f90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/lib_print.f90	(revision 2636)
@@ -10,5 +10,4 @@
    !!   prizre       : print an real 2D vertical field
    !!----------------------------------------------------------------------
-   !! * Mules used
    USE par_kind      ! kind parameters
 
@@ -16,7 +15,6 @@
    PRIVATE
 
-   !! * Routine accessibility
-   PUBLIC prihin, prihre, prizre
-   !!----------------------------------------------------------------------
+   PUBLIC   prihin, prihre, prizre
+
    !!----------------------------------------------------------------------
    !! NEMO/OPA 3.3 , NEMO Consortium (2010)
@@ -40,5 +38,4 @@
       !!        !  03-07 (G. Madec)  F90, free form
       !!----------------------------------------------------------------------
-      !! * Arguments
       INTEGER, INTENT( in ) ::   &
          ki, kj,                 &  ! array dimensions
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/oce.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/oce.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/oce.F90	(revision 2636)
@@ -9,5 +9,5 @@
    !!----------------------------------------------------------------------
    USE par_oce        ! ocean parameters
-   USE in_out_manager ! I/O manager
+   USE lib_mpp        ! MPP library
 
    IMPLICIT NONE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/trc_oce.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/trc_oce.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/trc_oce.F90	(revision 2636)
@@ -13,4 +13,5 @@
    USE in_out_manager  ! I/O manager
    USE dom_oce         ! ocean space and time domain
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/LOBSTER/sms_lobster.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/LOBSTER/sms_lobster.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/LOBSTER/sms_lobster.F90	(revision 2636)
@@ -11,5 +11,4 @@
    !!             2.0  !  2007-04  (C. Deltel, G. Madec) Free form and modules
    !!----------------------------------------------------------------------
-
 #if defined key_lobster
    !!----------------------------------------------------------------------
@@ -21,10 +20,4 @@
    IMPLICIT NONE
    PUBLIC
-
-   !!----------------------------------------------------------------------
-   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
-   !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
 
    !!  biological parameters
@@ -108,27 +101,26 @@
    REAL(wp), ALLOCATABLE, SAVE,  DIMENSION(:,:) ::   cmask       !: ???
 
-   !!======================================================================
-
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
+   !! $Id$ 
+   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
 CONTAINS
 
-   FUNCTION sms_lobster_alloc()
+   INTEGER FUNCTION sms_lobster_alloc()
       !!----------------------------------------------------------------------
       !!        *** ROUTINE sms_lobster_alloc ***
       !!----------------------------------------------------------------------
-      USE in_out_manager, ONLY: ctl_warn
-      INTEGER :: sms_lobster_alloc
+      USE lib_mpp, ONLY: ctl_warn
       !!----------------------------------------------------------------------
-
-      ALLOCATE(remdmp(jpk,jp_lobster),                                &
-               neln(jpi,jpj),    xze(jpi,jpj),     xpar(jpi,jpj,jpk), &
-               dminl(jpi,jpj),   dmin3(jpi,jpj,jpk),                  &
-               sedpocb(jpi,jpj), sedpocn(jpi,jpj), sedpoca(jpi,jpj),  &
-               fbod(jpi,jpj),    cmask(jpi,jpj)  ,                    &
-               Stat=sms_lobster_alloc)
-
-      IF(sms_lobster_alloc /= 0)THEN
-         CALL ctl_warn('sms_lobster_alloc : failed to allocate arrays.')
-      END IF
-
+      !
+      ALLOCATE( remdmp(jpk,jp_lobster),                                   &
+         &      neln(jpi,jpj),    xze(jpi,jpj),     xpar(jpi,jpj,jpk),    &
+         &      dminl(jpi,jpj),   dmin3(jpi,jpj,jpk),                     &
+         &      sedpocb(jpi,jpj), sedpocn(jpi,jpj), sedpoca(jpi,jpj),     &
+         &      fbod(jpi,jpj),    cmask(jpi,jpj)                    , STAT=sms_lobster_alloc )
+         !
+      IF( sms_lobster_alloc /= 0 )   CALL ctl_warn('sms_lobster_alloc : failed to allocate arrays')
+      !
    END FUNCTION sms_lobster_alloc
 
@@ -140,4 +132,3 @@
 
    !!======================================================================
-
 END MODULE sms_lobster
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcnam_lobster.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcnam_lobster.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcnam_lobster.F90	(revision 2636)
@@ -10,11 +10,12 @@
    !!   'key_lobster'   :                                 LOBSTER bio-model
    !!----------------------------------------------------------------------
-   !! trc_nam_lobster      : LOBSTER model namelist read
-   !!----------------------------------------------------------------------
-   USE oce_trc         ! Ocean variables
-   USE par_trc         ! TOP parameters
-   USE trc             ! TOP variables
-   USE sms_lobster     ! sms trends
-   USE in_out_manager  ! I/O manager
+   !! trc_nam_lobster   : LOBSTER model namelist read
+   !!----------------------------------------------------------------------
+   USE oce_trc          ! Ocean variables
+   USE par_trc          ! TOP parameters
+   USE trc              ! TOP variables
+   USE sms_lobster      ! sms trends
+   USE in_out_manager   ! I/O manager
+   USE lib_mpp          ! MPP library
 
    IMPLICIT NONE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcopt.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcopt.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcopt.F90	(revision 2636)
@@ -21,4 +21,5 @@
    USE sms_lobster
    USE prtctl_trc      ! Print control for debbuging
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
@@ -69,6 +70,5 @@
 
       IF( (wrk_in_use(2, 1,2)) .OR. (wrk_in_use(3, 2,3)) )THEN
-         CALL ctl_stop('trc_opt : requested workspace arrays unavailable.')
-         RETURN
+         CALL ctl_stop('trc_opt : requested workspace arrays unavailable')   ;   RETURN
       END IF
 
@@ -138,7 +138,6 @@
       ENDIF
       !
-      IF( (wrk_not_released(2, 1,2)) .OR. (wrk_not_released(3, 2,3)) )THEN
-         CALL ctl_stop('trc_opt : failed to release workspace arrays.')
-      END IF
+      IF( wrk_not_released(2, 1,2)  .OR.  wrk_not_released(3, 2,3)  )   &
+          CALL ctl_stop('trc_opt : failed to release workspace arrays')
       !
    END SUBROUTINE trc_opt
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcsms_lobster.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcsms_lobster.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/LOBSTER/trcsms_lobster.F90	(revision 2636)
@@ -13,5 +13,5 @@
    !!   trcsms_lobster        :  Time loop of passive tracers sms
    !!----------------------------------------------------------------------
-   USE oce_trc         !
+   USE oce_trc          !
    USE trc
    USE trcbio
@@ -23,4 +23,5 @@
    USE trdmod_trc
    USE trdmld_trc
+   USE lib_mpp          ! MPP library
 
    IMPLICIT NONE
@@ -32,7 +33,6 @@
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-
 CONTAINS
 
@@ -53,8 +53,7 @@
       !! --------------------------------------------------------------------
 
-      IF(wrk_in_use(3,1))THEN
-         CALL ctl_stop('trc_sms_lobster : requested workspace array unavailable.')
-         RETURN
-      END IF
+      IF( wrk_in_use(3,1) ) THEN
+         CALL ctl_stop('trc_sms_lobster : requested workspace array unavailable')   ;   RETURN
+      ENDIF
 
       CALL trc_opt( kt )      ! optical model
@@ -72,8 +71,6 @@
       IF( lk_trdmld_trc )  CALL trd_mld_bio( kt )   ! trends: Mixed-layer
 
-      IF(wrk_not_released(3,1))THEN
-         CALL ctl_stop('trc_sms_lobster : failed to release workspace array.')
-      END IF
-
+      IF( wrk_not_released(3,1) )   CALL ctl_stop('trc_sms_lobster : failed to release workspace array.')
+      !
    END SUBROUTINE trc_sms_lobster
 
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trcadv.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trcadv.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trcadv.F90	(revision 2636)
@@ -10,5 +10,4 @@
    !!----------------------------------------------------------------------
    !!   'key_top'                                                TOP models
-   !!----------------------------------------------------------------------
    !!----------------------------------------------------------------------
    !!   trc_adv      : compute ocean tracer advection trend
@@ -27,5 +26,6 @@
    USE ldftra_oce      ! lateral diffusion coefficient on tracers
    USE in_out_manager  ! I/O manager
-   USE prtctl_trc          ! Print control
+   USE lib_mpp         ! MPP library
+   USE prtctl_trc      ! Print control
 
    IMPLICIT NONE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trcnxt.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trcnxt.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trcnxt.F90	(revision 2636)
@@ -3,5 +3,4 @@
    !!                       ***  MODULE  trcnxt  ***
    !! Ocean passive tracers:  time stepping on passives tracers
-   !!======================================================================
    !!======================================================================
    !! History :  7.0  !  1991-11  (G. Madec)  Original code
@@ -27,5 +26,4 @@
    !!   trc_nxt     : time stepping on passive tracers
    !!----------------------------------------------------------------------
-   !! * Modules used
    USE oce_trc         ! ocean dynamics and tracers variables
    USE trc             ! ocean passive tracers variables
@@ -43,30 +41,27 @@
    PRIVATE
 
-   !! * Routine accessibility
-   PUBLIC trc_nxt          ! routine called by step.F90
-   PUBLIC trc_nxt_alloc    ! routine called by nemogcm.F90
+   PUBLIC   trc_nxt          ! routine called by step.F90
+   PUBLIC   trc_nxt_alloc    ! routine called by nemogcm.F90
 
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:) ::   r2dt
+
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-
 CONTAINS
 
-   FUNCTION trc_nxt_alloc()
+   INTEGER FUNCTION trc_nxt_alloc()
       !!----------------------------------------------------------------------
       !!                   ***  ROUTINE trc_nxt_alloc  ***
       !!----------------------------------------------------------------------
-      INTEGER :: trc_nxt_alloc
+      USE lib_mpp, ONLY: ctl_warn
       !!----------------------------------------------------------------------
-
+      !
       ALLOCATE( r2dt(jpk), Stat=trc_nxt_alloc)
-
-      IF(trc_nxt_alloc /= 0)THEN
-         CALL ctl_warn('trc_nxt_alloc : failed to allocate array.')
-      ENDIF
-
+      !
+      IF( trc_nxt_alloc /= 0 )   CALL ctl_warn('trc_nxt_alloc : failed to allocate array')
+      !
    END FUNCTION trc_nxt_alloc
 
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trcsbc.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trcsbc.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trcsbc.F90	(revision 2636)
@@ -16,16 +16,15 @@
    !!   trc_sbc      : update the tracer trend at ocean surface
    !!----------------------------------------------------------------------
-   !! * Modules used
-   USE oce_trc             ! ocean dynamics and active tracers variables
-   USE trc                 ! ocean  passive tracers variables
-   USE prtctl_trc          ! Print control for debbuging
+   USE oce_trc         ! ocean dynamics and active tracers variables
+   USE trc             ! ocean  passive tracers variables
+   USE prtctl_trc      ! Print control for debbuging
    USE trdmod_oce
    USE trdtra
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
    PRIVATE
 
-   !! * Routine accessibility
-   PUBLIC trc_sbc              ! routine called by step.F90
+   PUBLIC   trc_sbc   ! routine called by step.F90
 
    !! * Substitutions
@@ -34,7 +33,6 @@
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-
 CONTAINS
 
@@ -62,8 +60,7 @@
       USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
       USE wrk_nemo, zemps => wrk_2d_1
-      !! * Arguments
+      !
       INTEGER, INTENT( in ) ::   kt          ! ocean time-step index
-
-      !! * Local declarations
+      !
       INTEGER  ::   ji, jj, jn           ! dummy loop indices
       REAL(wp) ::   zsrau, zse3t   ! temporary scalars
@@ -73,6 +70,5 @@
 
       IF(wrk_in_use(2, 1))THEN
-         CALL ctl_stop('trc_sbc: requested workspace array unavailable.')
-         RETURN
+         CALL ctl_stop('trc_sbc: requested workspace array unavailable.')   ;   RETURN
       END IF
 
@@ -126,8 +122,6 @@
       ENDIF
 
-      IF(wrk_not_released(2, 1))THEN
-         CALL ctl_stop('trc_sbc: failed to release workspace array.')
-      END IF
-
+      IF( wrk_not_released(2, 1) )   CALL ctl_stop('trc_sbc: failed to release workspace array')
+      !
    END SUBROUTINE trc_sbc
 
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trczdf.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trczdf.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trczdf.F90	(revision 2636)
@@ -20,9 +20,10 @@
    USE trazdf_exp      ! vertical diffusion: explicit (tra_zdf_exp     routine)
    USE trazdf_imp      ! vertical diffusion: implicit (tra_zdf_imp     routine)
+   USE trdmod_oce
+   USE trdtra
    USE prtctl_trc      ! Print control
    USE in_out_manager  ! I/O manager
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
-   USE trdmod_oce
-   USE trdtra
+   USE lib_mpp         ! MPP library
 
    IMPLICIT NONE
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trdmld_trc.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trdmld_trc.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trdmld_trc.F90	(revision 2636)
@@ -23,5 +23,5 @@
    USE zdfddm  , ONLY : avs  !: salinity vertical diffusivity coeff. at w-point
 # endif
-   USE trcnam_trp      ! passive tracers transport namelist variables
+   USE trcnam_trp        ! passive tracers transport namelist variables
    USE trdmod_trc_oce    ! definition of main arrays used for trends computations
    USE in_out_manager    ! I/O manager
@@ -30,4 +30,5 @@
    USE ioipsl            ! NetCDF library
    USE lbclnk            ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp           ! MPP library
    USE trdmld_trc_rst    ! restart for diagnosing the ML trends
    USE prtctl            ! print control
@@ -47,5 +48,5 @@
    CHARACTER (LEN=40) ::  clhstnam                                ! name of the trends NetCDF file
    INTEGER ::   nmoymltrd
-   INTEGER ::   ndextrd1(jpi*jpj)
+   INTEGER, ALLOCATABLE, SAVE, DIMENSION(:) ::   ndextrd1
    INTEGER, DIMENSION(jptra) ::   nidtrd, nh_t
    INTEGER ::   ndimtrd1                        
@@ -87,10 +88,8 @@
                ztmltrdbio2(jpi,jpj,jpdiabio)     , &
 #endif
-               Stat=trd_mld_trc_alloc)
-
-      IF(trd_mld_trc_alloc/=0)THEN
-         CALL ctl_warn('trd_mld_trc_alloc : failed to allocate arrays.')
-      END IF
-
+         &     ndextrd1(jpi*jpj)                 ,  STAT=trd_mld_trc_alloc)
+         !
+      IF( lk_mpp                )   CALL mpp_sum ( trd_mld_trc_alloc )
+      IF( trd_mld_trc_alloc /=0 )   CALL ctl_warn('trd_mld_trc_alloc : failed to allocate arrays.')
    END FUNCTION trd_mld_trc_alloc
 
@@ -125,7 +124,6 @@
       !!----------------------------------------------------------------------
 
-      IF(wrk_in_use(2, 1))THEN
-         CALL ctl_stop('trd_mld_trc_zint : requested workspace array unavailable.')
-         RETURN
+      IF( wrk_in_use(2, 1) ) THEN
+         CALL ctl_stop('trd_mld_trc_zint : requested workspace array unavailable')   ;   RETURN
       END IF
 
@@ -213,10 +211,9 @@
       END SELECT
 
-      IF(wrk_not_released(2, 1))THEN
-         CALL ctl_stop('trd_mld_trc_zint : failed to release workspace array.')
-      END IF
-
+      IF( wrk_not_released(2, 1) )   CALL ctl_stop('trd_mld_trc_zint : failed to release workspace array.')
+      !
     END SUBROUTINE trd_mld_trc_zint
-    
+
+
     SUBROUTINE trd_mld_bio_zint( ptrc_trdmld, ktrd )
       !!----------------------------------------------------------------------
@@ -387,8 +384,8 @@
       !!       - See NEMO documentation (in preparation)
       !!----------------------------------------------------------------------
-      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
-      USE wrk_nemo, wrk_3d_1, wrk_3d_2, wrk_3d_3, wrk_3d_4, &
-                    wrk_3d_5, wrk_3d_6, wrk_3d_7, wrk_3d_8, &
-                    wrk_3d_9
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY:   wrk_3d_1, wrk_3d_2, wrk_3d_3, wrk_3d_4
+      USE wrk_nemo, ONLY:   wrk_3d_5, wrk_3d_6, wrk_3d_7, wrk_3d_8, wrk_3d_9
+      !
       INTEGER, INTENT( in ) ::   kt                               ! ocean time-step index
       INTEGER ::   ji, jj, jk, jl, ik, it, itmod, jn
@@ -414,8 +411,7 @@
       !!----------------------------------------------------------------------
 
-      IF(wrk_in_use(3, 1,2,3,4,5,6,7,8,9))THEN
-         CALL ctl_stop('trd_mld_trc : requested workspace arrays unavailable.')
-         RETURN
-      END IF
+      IF( wrk_in_use(3, 1,2,3,4,5,6,7,8,9) ) THEN
+         CALL ctl_stop('trd_mld_trc : requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
       ! Set-up pointers into sub-arrays of workspaces
       ztmltot   => wrk_3d_1(:,:,1:jptra)
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trdmod_trc_oce.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trdmod_trc_oce.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trdmod_trc_oce.F90	(revision 2636)
@@ -4,37 +4,32 @@
    !! Ocean trends :   set tracer and momentum trend variables
    !!======================================================================
-   !!----------------------------------------------------------------------
-   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
-   !! $Header: /home/opalod/NEMOCVSROOT/NEMO/OPA_SRC/TRD/trdmld_oce.F90,v 1.2 2005/03/27 18:35:23 opalod Exp $ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-#if defined key_top
+#if defined key_top   ||   defined key_esopa
    !!----------------------------------------------------------------------
    !!   'key_top'                                                TOP models
    !!----------------------------------------------------------------------
 
-   USE par_oce                        ! ocean parameters
-   USE par_trc                        ! passive tracers parameters
+   USE par_oce       ! ocean parameters
+   USE par_trc       ! passive tracers parameters
 
    IMPLICIT NONE
    PUBLIC
 
-   !!* Namelist namtoptrd:  diagnostics on passive tracers trends
-   INTEGER  ::    nn_trd_trc                 !: time step frequency dynamics and tracers trends
-   INTEGER  ::    nn_ctls_trc                !: control surface type for trends vertical integration
+   !                                         !!* Namelist namtoptrd:  diagnostics on passive tracers trends
+   INTEGER  ::    nn_trd_trc                  !: time step frequency dynamics and tracers trends
+   INTEGER  ::    nn_ctls_trc                 !: control surface type for trends vertical integration
    REAL(wp) ::    rn_ucf_trc                  !: unit conversion factor (for netCDF trends outputs)
-   LOGICAL  ::    ln_trdmld_trc_instant    !: flag to diagnose inst./mean ML trc trends
-   LOGICAL  ::    ln_trdmld_trc_restart    !: flag to restart mixed-layer trc diagnostics
-   CHARACTER(len=50) ::  cn_trdrst_trc_in  !: suffix of pass. tracer restart name (input)
-   CHARACTER(len=50) ::  cn_trdrst_trc_out !: suffix of pass. tracer restart name (output)
+   LOGICAL  ::    ln_trdmld_trc_instant       !: flag to diagnose inst./mean ML trc trends
+   LOGICAL  ::    ln_trdmld_trc_restart       !: flag to restart mixed-layer trc diagnostics
+   CHARACTER(len=50) ::  cn_trdrst_trc_in     !: suffix of pass. tracer restart name (input)
+   CHARACTER(len=50) ::  cn_trdrst_trc_out    !: suffix of pass. tracer restart name (output)
    LOGICAL, DIMENSION (jptra) ::   ln_trdtrc  !: large trends diagnostic to write or not (namelist)
 
 # if defined key_trdtrc && defined key_iomput
    LOGICAL, PARAMETER ::   lk_trdtrc = .TRUE. 
-#else
+# else
    LOGICAL, PARAMETER ::   lk_trdtrc = .FALSE.   !: ML trend flag
-#endif
+# endif
 
-#if defined key_trdmld_trc
+# if defined key_trdmld_trc   ||   defined key_esopa
    !!----------------------------------------------------------------------
    !!   'key_trdmld_trc'                     mixed layer trends diagnostics
@@ -108,9 +103,9 @@
       tmltrdm_trc                                !: total cumulative trends over the analysis window
 
-#else
+# else
    LOGICAL, PARAMETER ::   lk_trdmld_trc = .FALSE.   !: ML trend flag
-#endif
+# endif
 
-#if defined key_lobster
+# if defined key_lobster
    CHARACTER(LEN=80) :: clname_bio, ctrd_bio(jpdiabio,2)
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::  &
@@ -121,23 +116,17 @@
       tmltrd_csum_ub_bio                         !: before (prev. analysis period) cumulated sum over the
                                                  !: upper triangle
-#endif
-
-#else
+# endif
    !!----------------------------------------------------------------------
-   !!  Empty module :                                     No passive tracer
+   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
+   !! $Header: /home/opalod/NEMOCVSROOT/NEMO/OPA_SRC/TRD/trdmld_oce.F90,v 1.2 2005/03/27 18:35:23 opalod Exp $ 
+   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-#endif
-
-#if defined key_top
 CONTAINS
 
-   FUNCTION trd_mod_trc_oce_alloc()
+   INTEGER FUNCTION trd_mod_trc_oce_alloc()
       !!----------------------------------------------------------------------
       !!         *** ROUTINE trd_mod_trc_oce_alloc ***
       !!----------------------------------------------------------------------
-      USE in_out_manager, ONLY: ctl_warn
-      !
-      INTEGER :: trd_mod_trc_oce_alloc
-      ! Locals
+      USE lib_mpp, ONLY: ctl_warn
       INTEGER :: ierr(2)
       !!----------------------------------------------------------------------
@@ -145,5 +134,5 @@
       ierr(:) = 0
 
-#if defined key_trdmld_trc
+# if defined key_trdmld_trc
       ALLOCATE(nmld_trc(jpi,jpj),          nbol_trc(jpi,jpj),           &
                wkx_trc(jpi,jpj,jpk),       rmld_trc(jpi,jpj),           &
@@ -166,6 +155,6 @@
                tmltrdm_trc(jpi,jpj,jptra),                   &
                Stat=ierr(1))
-#endif
-#if defined key_lobster
+# endif
+# if defined key_lobster
       ALLOCATE(tmltrd_bio(jpi,jpj,jpdiabio),         &
                tmltrd_sum_bio(jpi,jpj,jpdiabio),     &
@@ -173,20 +162,22 @@
                tmltrd_csum_ub_bio(jpi,jpj,jpdiabio), &
                Stat=ierr(2))
-#endif
+# endif
 
       trd_mod_trc_oce_alloc = MAXVAL(ierr)
 
-      IF(trd_mod_trc_oce_alloc /= 0)THEN
-         CALL ctl_warn('trd_mod_trc_oce_alloc : failed to allocate arrays.')
-      END IF
+      IF( trd_mod_trc_oce_alloc /= 0 )   CALL ctl_warn('trd_mod_trc_oce_alloc : failed to allocate arrays')
 
-#if defined key_trdmld_trc
-      ! Initialise what used to be a parameter - max level for mixed-layer 
-      ! trends diag.
-      jpktrd_trc = jpk
+# if defined key_trdmld_trc
+      jpktrd_trc = jpk      ! Initialise what used to be a parameter - max level for mixed-layer trends diag.
+# endif
+      !
+   END FUNCTION trd_mod_trc_oce_alloc
+
+#else
+   !!----------------------------------------------------------------------
+   !!  Empty module :                                     No passive tracer
+   !!----------------------------------------------------------------------
 #endif
 
-   END FUNCTION trd_mod_trc_oce_alloc
-#endif
-
+   !!======================================================================
 END MODULE trdmod_trc_oce
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/trc.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/trc.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/trc.F90	(revision 2636)
@@ -78,8 +78,7 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION (:,:,  :) ::   trc2d    !:  additional 2d outputs  
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION (:,:,:,:) ::   trc3d    !:  additional 3d outputs  
-   
 # endif
 
-#if defined key_diabio || defined key_trdmld_trc
+# if defined key_diabio || defined key_trdmld_trc
    !                                                              !!*  namtop_XXX namelist *
    INTEGER , PUBLIC                               ::   nn_writebio   !: time step frequency for biological outputs 
@@ -87,5 +86,5 @@
    CHARACTER(len=20), PUBLIC, DIMENSION(jpdiabio) ::   ctrbiu      !: biological trends unit   
    CHARACTER(len=80), PUBLIC, DIMENSION(jpdiabio) ::   ctrbil      !: biological trends long name
-#endif
+# endif
 # if defined key_diabio
    !! Biological trends
@@ -101,27 +100,18 @@
 # endif
 
-#else
-   !!----------------------------------------------------------------------
-   !!  Empty module :                                     No passive tracer
-   !!----------------------------------------------------------------------
-#endif
-
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
    !! $Id$ 
    !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!======================================================================
-#if defined key_top
+   !!----------------------------------------------------------------------
 CONTAINS
 
-   FUNCTION trc_alloc()
+   INTEGER FUNCTION trc_alloc()
       !!-------------------------------------------------------------------
       !!                    *** ROUTINE trc_alloc ***
       !!-------------------------------------------------------------------
-      USE in_out_manager, ONLY: ctl_warn
+      USE lib_mpp, ONLY: ctl_warn
+      !!-------------------------------------------------------------------
       !
-      INTEGER :: trc_alloc
-      !!-------------------------------------------------------------------
-
       ALLOCATE(cvol(jpi,jpj,jpk),                                  &
                trn(jpi,jpj,jpk,jptra),                             &
@@ -132,16 +122,20 @@
 # if defined key_diatrc && ! defined key_iomput
                trc2d(jpi,jpj,jpdia2d), trc3d(jpi,jpj,jpk,jpdia3d), &
-#endif
+# endif
 # if defined key_diabio
                trbio(jpi,jpj,jpk,jpdiabio),                        &
-#endif
-               Stat=trc_alloc)
+# endif
+               STAT=trc_alloc)
 
-      IF(trc_alloc /= 0)THEN
-         CALL ctl_warn('trc_alloc: failed to allocate arrays.')
-      END IF
-
+      IF( trc_alloc /= 0 )   CALL ctl_warn('trc_alloc: failed to allocate arrays')
+      !
    END FUNCTION trc_alloc
+   
+#else
+   !!----------------------------------------------------------------------
+   !!  Empty module :                                     No passive tracer
+   !!----------------------------------------------------------------------
 #endif
 
+   !!======================================================================
 END MODULE trc
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/trcnam.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/trcnam.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/trcnam.F90	(revision 2636)
@@ -27,4 +27,5 @@
    USE trcnam_my_trc     ! MY_TRC SMS namelist
    USE in_out_manager    ! I/O manager
+   USE lib_mpp           ! MPP library
    USE trdmod_trc_oce
 
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/trcsms.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/trcsms.F90	(revision 2635)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/trcsms.F90	(revision 2636)
@@ -30,7 +30,6 @@
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
    !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-
 CONTAINS
 
