Index: branches/2014/dev_r4650_UKMO12_CFL_diags_take2/NEMOGCM/TOOLS/SIREN/src/mpp.f90
===================================================================
--- branches/2014/dev_r4650_UKMO12_CFL_diags_take2/NEMOGCM/TOOLS/SIREN/src/mpp.f90	(revision 4712)
+++ branches/2014/dev_r4650_UKMO12_CFL_diags_take2/NEMOGCM/TOOLS/SIREN/src/mpp.f90	(revision 5832)
@@ -5,32 +5,47 @@
 ! MODULE: mpp
 !
-!
 ! DESCRIPTION:
-!> This module manage massively parallel processing
+!> @brief
+!> This module manage massively parallel processing.
 !
 !> @details
 !> define type TMPP:<br/>
-!> TYPE(TMPP) :: tl_mpp<br/>
+!> @code
+!> TYPE(TMPP) :: tl_mpp
+!> @endcode
 !>
 !>    to initialise a mpp structure:<br/>
-!>    - tl_mpp=mpp_init( cd_file, id_mask, [id_niproc,] [id_njproc,] 
-!>         [id_nproc] [id_preci,] [id_precj,] [cd_type])
-!>    - tl_mpp=mpp_init( cd_file, td_var, [id_niproc,] [id_njproc,] 
-!>         [id_nproc] [id_preci,] [id_precj,] [cd_type])
-!>    - tl_mpp=mpp_init( td_file )
+!> @code
+!>    tl_mpp=mpp_init( cd_file, id_mask, 
+!>                       [id_niproc,] [id_njproc,] [id_nproc,]
+!>                       [id_preci,] [id_precj,] 
+!>                       [cd_type,] [id_ew])
+!> @endcode
+!> or
+!> @code
+!>    tl_mpp=mpp_init( cd_file, td_var, 
+!>                      [id_niproc,] [id_njproc,] [id_nproc,]
+!>                      [id_preci,] [id_precj,]
+!>                      [cd_type] )
+!> @endcode
+!> or
+!> @code
+!>    tl_mpp=mpp_init( td_file [,id_ew] )
+!> @endcode
 !>       - cd_file is the filename of the global domain file, in which 
 !>         MPP will be done (example: Bathymetry) 
 !>       - td_file is the file structure of one processor file composing an MPP
-!>       - id_mask is the 2D mask of global domain 
+!>       - id_mask is the 2D mask of global domain [optional]
 !>       - td_var is a variable structure (on T-point) from global domain file.
-!>         mask of the domain will be computed using FillValue
+!>         mask of the domain will be computed using FillValue [optional]
 !>       - id_niproc is the number of processor following I-direction to be used
-!>         (optional)
+!>         [optional]
 !>       - id_njproc is the number of processor following J-direction to be used 
-!>         (optional)
-!>       - id_nproc is the total number of processor to be used (optional)
-!>       - id_preci is the size of the overlap region following I-direction
-!>       - id_precj is the size of the overlap region following J-direction
-!>       - cd_type is the type of files composing MPP<br/>
+!>         [optional]
+!>       - id_nproc is the total number of processor to be used [optional]
+!>       - id_preci is the size of the overlap region following I-direction [optional]
+!>       - id_precj is the size of the overlap region following J-direction [optional]
+!>       - cd_type is the type of files composing MPP [optional]
+!>       - id_ew is east-west overlap [optional]<br/> 
 !>  
 !>    to get mpp name:<br/>
@@ -62,5 +77,5 @@
 !>    - tl_mpp\%i_ndim
 !>
-!>    to get the table of dimension structure (4 elts) associated to the
+!>    to get the array of dimension structure (4 elts) associated to the
 !>    mpp structure:<br/>
 !>    - tl_mpp\%t_dim(:)
@@ -70,50 +85,110 @@
 !>
 !>    to clean a mpp structure:<br/>
-!>    - CALL mpp_clean(tl_mpp)
+!> @code
+!>    CALL mpp_clean(tl_mpp)
+!> @endcode
 !>
 !>    to print information about mpp:<br/>
+!> @code
 !>    CALL mpp_print(tl_mpp)
+!> @endcode
 !>
 !>    to add variable to mpp:<br/>
+!> @code
 !>    CALL mpp_add_var(td_mpp, td_var)
+!> @endcode
 !>       - td_var is a variable structure
 !>
 !>    to add dimension to mpp:<br/>
+!> @code
 !>    CALL mpp_add_dim(td_mpp, td_dim)
+!> @endcode
 !>       - td_dim is a dimension structure
 !>
-!>    to delete variable to mpp:<br/>
+!>    to add attribute to mpp:<br/>
+!> @code
+!>    CALL mpp_add_att(td_mpp, td_att)
+!> @endcode
+!>       - td_att is a attribute structure
+!>
+!>    to delete variable from mpp:<br/>
+!> @code
 !>    CALL mpp_del_var(td_mpp, td_var)
+!> @endcode
+!>    or
+!> @code
+!>    CALL mpp_del_var(td_mpp, cd_name)
+!> @endcode
 !>       - td_var is a variable structure
+!>       - cd_name is variable name or standard name
 !>
-!>    to delete dimension to mpp:<br/>
+!>    to delete dimension from mpp:<br/>
+!> @code
 !>    CALL mpp_del_dim(td_mpp, td_dim)
+!> @endcode
 !>       - td_dim is a dimension structure
 !>
+!>    to delete attribute from mpp:<br/>
+!> @code
+!>    CALL mpp_del_att(td_mpp, td_att)
+!> @endcode
+!>    or
+!> @code
+!>    CALL mpp_del_att(td_mpp, cd_name)
+!> @endcode
+!>       - td_att is a attribute structure
+!>       - cd_name is attribute name
+!>
 !>    to overwrite variable to mpp:<br/>
+!> @code
 !>    CALL mpp_move_var(td_mpp, td_var)
+!> @endcode
 !>       - td_var is a variable structure
 !>
 !>    to overwrite dimension to mpp:<br/>
+!> @code
 !>    CALL mpp_move_dim(td_mpp, td_dim)
+!> @endcode
 !>       - td_dim is a dimension structure
 !>
+!>    to overwrite attribute to mpp:<br/>
+!> @code
+!>    CALL mpp_move_att(td_mpp, td_att)
+!> @endcode
+!>       - td_att is a attribute structure
+!>
 !>    to determine domain decomposition type:<br/>
+!> @code
 !>    CALL mpp_get_dom(td_mpp)
+!> @endcode
 !>
 !>    to get processors to be used:<br/>
-!>    CALL mpp_get_use( td_mpp, td_dom )
-!>       - td_dom is a domain structure
+!> @code
+!>    CALL mpp_get_use( td_mpp, id_imin, id_imax, id_idim, & 
+!>    &                         id_jmin, id_jmax, id_jdim )
+!> @endcode
+!>       - id_imin 
+!>       - id_imax 
+!>       - id_idim 
+!>       - id_jmin 
+!>       - id_jmax 
+!>       - id_jdim 
 !>
 !>    to get sub domains which form global domain contour:<br/>
+!> @code
 !>    CALL mpp_get_contour( td_mpp ) 
+!> @endcode
 !>
 !>    to get global domain indices of one processor:<br/>
+!> @code
 !>    il_ind(1:4)=mpp_get_proc_index( td_mpp, id_procid )
+!> @endcode
 !>       - il_ind(1:4) are global domain indices (i1,i2,j1,j2)
 !>       - id_procid is the processor id
 !>
 !>    to get the processor domain size:<br/>
+!> @code
 !>    il_size(1:2)=mpp_get_proc_size( td_mpp, id_procid )
+!> @endcode
 !>       - il_size(1:2) are the size of domain following I and J
 !>       - id_procid is the processor id
@@ -122,16 +197,13 @@
 !>  J.Paul
 ! REVISION HISTORY:
-!> @date Nov, 2013 - Initial Version
-!> @todo
-!>  - add description generique de l'objet mpp
-!>  - mpp_print
-!>  - voir pour mettre cd_file systematiquement pour mpp_init
-!>  + modifier utilisation la haut
+!> @date November, 2013 - Initial Version
+!> @date November, 2014 - Fix memory leaks bug
 !
 !> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
 !----------------------------------------------------------------------
 MODULE mpp
+   USE global                          ! global parameter
    USE kind                            ! F90 kind parameter
-   USE logger                             ! log file manager
+   USE logger                          ! log file manager
    USE fct                             ! basic useful function
    USE dim                             ! dimension manager
@@ -140,15 +212,12 @@
    USE file                            ! file manager
    USE iom                             ! I/O manager
-!   USE proc                            ! proc manager
-   USE dom                             ! domain manager
    IMPLICIT NONE
-   PRIVATE
    ! NOTE_avoid_public_variables_if_possible
 
    ! type and variable
-   PUBLIC :: TMPP       ! mpp structure
+   PUBLIC :: TMPP       !< mpp structure
 
    ! function and subroutine
-   PUBLIC :: ASSIGNMENT(=)      !< copy mpp structure
+   PUBLIC :: mpp_copy           !< copy mpp structure
    PUBLIC :: mpp_init           !< initialise mpp structure
    PUBLIC :: mpp_clean          !< clean mpp strcuture
@@ -163,4 +232,6 @@
    PUBLIC :: mpp_move_dim       !< overwrite one dimension strucutre in mpp structure
    PUBLIC :: mpp_move_att       !< overwrite one attribute strucutre in mpp structure
+   PUBLIC :: mpp_recombine_var  !< recombine variable from mpp structure
+   PUBLIC :: mpp_get_index      !< return index of mpp 
 
    PUBLIC :: mpp_get_dom        !< determine domain decomposition type (full, overlap, noverlap)
@@ -170,40 +241,66 @@
    PUBLIC :: mpp_get_proc_size  !< get processor domain size
 
-   PRIVATE :: mpp__add_proc     !< add one proc strucutre in mpp structure
-   PRIVATE :: mpp__del_proc     !< delete one proc strucutre in mpp structure
-   PRIVATE :: mpp__move_proc    !< overwrite proc strucutre in mpp structure
-   PRIVATE :: mpp__compute      !< compute domain decomposition
-   PRIVATE :: mpp__del_land     !< remove land sub domain from domain decomposition
-   PRIVATE :: mpp__optimiz      !< compute optimum domain decomposition
-   PRIVATE :: mpp__land_proc    !< check if processor is a land processor
-   PRIVATE :: mpp__check_dim    !< check mpp structure dimension with proc or variable dimension
-   PRIVATE :: mpp__del_var_name !< delete variable in mpp structure, given variable name
-   PRIVATE :: mpp__del_var_str  !< delete variable in mpp structure, given variable structure
-   PRIVATE :: mpp__del_att_name !< delete variable in mpp structure, given variable name
-   PRIVATE :: mpp__del_att_str  !< delete variable in mpp structure, given variable structure
-   PRIVATE :: mpp__split_var    !< extract variable part that will be written in processor 
-   PRIVATE :: mpp__copy         !< copy mpp structure
-
-   !> @struct TMPP
-   TYPE TMPP
+   PRIVATE :: mpp__add_proc            ! add one proc strucutre in mpp structure
+   PRIVATE :: mpp__del_proc            ! delete one proc strucutre in mpp structure
+   PRIVATE :: mpp__del_proc_id         ! delete one proc strucutre in mpp structure, given procesor id
+   PRIVATE :: mpp__del_proc_str        ! delete one proc strucutre in mpp structure, given procesor file structure 
+   PRIVATE :: mpp__move_proc           ! overwrite proc strucutre in mpp structure
+   PRIVATE :: mpp__compute             ! compute domain decomposition
+   PRIVATE :: mpp__del_land            ! remove land sub domain from domain decomposition
+   PRIVATE :: mpp__optimiz             ! compute optimum domain decomposition
+   PRIVATE :: mpp__land_proc           ! check if processor is a land processor
+   PRIVATE :: mpp__check_dim           ! check mpp structure dimension with proc or variable dimension
+   PRIVATE :: mpp__check_proc_dim      ! check if processor and mpp structure use same dimension
+   PRIVATE :: mpp__check_var_dim       ! check if variable  and mpp structure use same dimension
+   PRIVATE :: mpp__del_var_name        ! delete variable in mpp structure, given variable name
+   PRIVATE :: mpp__del_var_mpp         ! delete all variable in mpp structure
+   PRIVATE :: mpp__del_var_str         ! delete variable in mpp structure, given variable structure
+   PRIVATE :: mpp__del_att_name        ! delete variable in mpp structure, given variable name
+   PRIVATE :: mpp__del_att_str         ! delete variable in mpp structure, given variable structure
+   PRIVATE :: mpp__split_var           ! extract variable part that will be written in processor 
+   PRIVATE :: mpp__copy_unit           ! copy mpp structure
+   PRIVATE :: mpp__copy_arr            ! copy array of mpp structure
+   PRIVATE :: mpp__get_use_unit        ! get sub domains to be used (which cover "zoom domain")
+   PRIVATE :: mpp__init_mask           ! initialise mpp structure, given file name
+   PRIVATE :: mpp__init_var            ! initialise mpp structure, given variable strcuture
+   PRIVATE :: mpp__init_file           ! initialise a mpp structure, given file structure 
+   PRIVATE :: mpp__init_file_cdf       ! initialise a mpp structure with cdf file
+   PRIVATE :: mpp__init_file_rstdimg   ! initialise a mpp structure with rstdimg file
+   PRIVATE :: mpp__clean_unit          ! clean mpp strcuture
+   PRIVATE :: mpp__clean_arr           ! clean array of mpp strcuture
+
+   TYPE TMPP !< mpp structure
 
       ! general 
-      CHARACTER(LEN=lc)                   :: c_name = ''   !< base name ???
-
-      INTEGER(i4)                         :: i_niproc = 0         !< number of processors following i
-      INTEGER(i4)                         :: i_njproc = 0         !< number of processors following j
-      INTEGER(i4)                         :: i_nproc  = 0         !< total number of proccessors used
-      INTEGER(i4)                         :: i_preci = 1          !< i-direction overlap region length
-      INTEGER(i4)                         :: i_precj = 1          !< j-direction overlap region length
-
-      CHARACTER(LEN=lc)                   :: c_type = ''   !< type of the files (cdf, cdf4, dimg)
-      CHARACTER(LEN=lc)                   :: c_dom  = ''   !< type of domain (full, overlap, nooverlap)
-
-      INTEGER(i4)                         :: i_ndim = 0           !< number of dimensions used in mpp
-      TYPE(TDIM),  DIMENSION(ip_maxdim)   :: t_dim                !< global domain dimension
-
-      TYPE(TFILE), DIMENSION(:), POINTER  :: t_proc => NULL()     !< files/processors composing mpp
+      CHARACTER(LEN=lc)                  :: c_name = ''   !< base name 
+      INTEGER(i4)                        :: i_id   = 0    !< mpp id
+
+      INTEGER(i4)                        :: i_niproc = 0  !< number of processors following i
+      INTEGER(i4)                        :: i_njproc = 0  !< number of processors following j
+      INTEGER(i4)                        :: i_nproc  = 0  !< total number of proccessors used
+      INTEGER(i4)                        :: i_preci = 1   !< i-direction overlap region length
+      INTEGER(i4)                        :: i_precj = 1   !< j-direction overlap region length
+      INTEGER(i4)                        :: i_ew    = -1  !< east-west overlap
+      INTEGER(i4)                        :: i_perio = -1  !< NEMO periodicity index
+      INTEGER(i4)                        :: i_pivot = -1  !< NEMO pivot point index F(0),T(1)
+
+      CHARACTER(LEN=lc)                  :: c_type = ''   !< type of the files (cdf, cdf4, dimg)
+      CHARACTER(LEN=lc)                  :: c_dom  = ''   !< type of domain (full, overlap, nooverlap)
+
+      INTEGER(i4)                        :: i_ndim = 0    !< number of dimensions used in mpp
+      TYPE(TDIM),  DIMENSION(ip_maxdim)  :: t_dim         !< global domain dimension
+
+      TYPE(TFILE), DIMENSION(:), POINTER :: t_proc => NULL()     !< files/processors composing mpp
 
    END TYPE
+
+   INTERFACE mpp_get_use
+      MODULE PROCEDURE mpp__get_use_unit 
+   END INTERFACE mpp_get_use
+
+   INTERFACE mpp_clean
+      MODULE PROCEDURE mpp__clean_unit 
+      MODULE PROCEDURE mpp__clean_arr   
+   END INTERFACE mpp_clean
 
    INTERFACE mpp__check_dim
@@ -220,4 +317,5 @@
       MODULE PROCEDURE mpp__del_var_name
       MODULE PROCEDURE mpp__del_var_str
+      MODULE PROCEDURE mpp__del_var_mpp
    END INTERFACE mpp_del_var
 
@@ -230,9 +328,10 @@
       MODULE PROCEDURE mpp__init_mask
       MODULE PROCEDURE mpp__init_var
-      MODULE PROCEDURE mpp__init_read
+      MODULE PROCEDURE mpp__init_file
    END INTERFACE mpp_init
 
-   INTERFACE ASSIGNMENT(=)
-      MODULE PROCEDURE mpp__copy   ! copy mpp structure
+   INTERFACE mpp_copy
+      MODULE PROCEDURE mpp__copy_unit  ! copy mpp structure
+      MODULE PROCEDURE mpp__copy_arr   ! copy array of mpp structure
    END INTERFACE
 
@@ -240,23 +339,34 @@
    !-------------------------------------------------------------------
    !> @brief
-   !> This subroutine copy mpp structure in another mpp
-   !> structure
+   !> This subroutine copy mpp structure in another one
    !> @details 
-   !> mpp file are copied in a temporary table, 
+   !> mpp file are copied in a temporary array, 
    !> so input and output mpp structure do not point on the same 
    !> "memory cell", and so on are independant. 
    !>
-   !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[out] td_mpp1  : mpp structure
-   !> @param[in] td_mpp2  : mpp structure
-   !-------------------------------------------------------------------
-   ! @code
-   SUBROUTINE mpp__copy( td_mpp1, td_mpp2 )
+   !> @warning do not use on the output of a function who create or read an
+   !> structure (ex: tl_file=file_copy(file_init()) is forbidden).
+   !> This will create memory leaks.
+   !> @warning to avoid infinite loop, do not use any function inside 
+   !> this subroutine
+   !>
+   !> @author J.Paul
+   !> - November, 2013- Initial Version
+   !> @date November, 2014
+   !>    - use function instead of overload assignment operator 
+   !> (to avoid memory leak)
+   !
+   !> @param[in] td_mpp   mpp structure
+   !> @return copy of input mpp structure
+   !-------------------------------------------------------------------
+   FUNCTION mpp__copy_unit( td_mpp )
       IMPLICIT NONE
       ! Argument
-      TYPE(TMPP), INTENT(OUT) :: td_mpp1
-      TYPE(TMPP), INTENT(IN)  :: td_mpp2
+      TYPE(TMPP), INTENT(IN)  :: td_mpp
+      ! function
+      TYPE(TMPP) :: mpp__copy_unit
+
+      ! local variable
+      TYPE(TFILE) :: tl_file
 
       ! loop indices
@@ -264,31 +374,80 @@
       !----------------------------------------------------------------
 
-      CALL logger_trace("COPY: mpp "//TRIM(td_mpp2%c_name)//" in "//&
-      &  TRIM(td_mpp1%c_name))
+      CALL logger_trace("MPP COPY: "//TRIM(td_mpp%c_name)//" in "//&
+      &  TRIM(mpp__copy_unit%c_name))
+
       ! copy mpp variable
-      td_mpp1%c_name     = TRIM(td_mpp2%c_name)
-      td_mpp1%i_niproc   = td_mpp2%i_niproc
-      td_mpp1%i_njproc   = td_mpp2%i_njproc
-      td_mpp1%i_nproc    = td_mpp2%i_nproc
-      td_mpp1%i_preci    = td_mpp2%i_preci
-      td_mpp1%i_precj    = td_mpp2%i_precj
-      td_mpp1%c_type     = TRIM(td_mpp2%c_type)
-      td_mpp1%c_dom      = TRIM(td_mpp2%c_dom)
-      td_mpp1%i_ndim     = td_mpp2%i_ndim
+      mpp__copy_unit%c_name     = TRIM(td_mpp%c_name)
+      mpp__copy_unit%i_niproc   = td_mpp%i_niproc
+      mpp__copy_unit%i_njproc   = td_mpp%i_njproc
+      mpp__copy_unit%i_nproc    = td_mpp%i_nproc
+      mpp__copy_unit%i_preci    = td_mpp%i_preci
+      mpp__copy_unit%i_precj    = td_mpp%i_precj
+      mpp__copy_unit%c_type     = TRIM(td_mpp%c_type)
+      mpp__copy_unit%c_dom      = TRIM(td_mpp%c_dom)
+      mpp__copy_unit%i_ndim     = td_mpp%i_ndim
+      mpp__copy_unit%i_ew       = td_mpp%i_ew
+      mpp__copy_unit%i_perio    = td_mpp%i_perio
+      mpp__copy_unit%i_pivot    = td_mpp%i_pivot
 
       ! copy dimension
-      td_mpp1%t_dim(:) = td_mpp2%t_dim(:)
+      mpp__copy_unit%t_dim(:) = dim_copy(td_mpp%t_dim(:))
       
       ! copy file structure
-      IF( ASSOCIATED(td_mpp1%t_proc) ) DEALLOCATE(td_mpp1%t_proc)
-      IF( ASSOCIATED(td_mpp2%t_proc) )THEN
-         ALLOCATE( td_mpp1%t_proc(td_mpp1%i_nproc) )
-         DO ji=1,td_mpp1%i_nproc
-            td_mpp1%t_proc(ji) = td_mpp2%t_proc(ji)
+      IF( ASSOCIATED(mpp__copy_unit%t_proc) )THEN
+         CALL file_clean(mpp__copy_unit%t_proc(:))
+         DEALLOCATE(mpp__copy_unit%t_proc)
+      ENDIF
+      IF( ASSOCIATED(td_mpp%t_proc) .AND. mpp__copy_unit%i_nproc > 0 )THEN
+         ALLOCATE( mpp__copy_unit%t_proc(mpp__copy_unit%i_nproc) )
+         DO ji=1,mpp__copy_unit%i_nproc
+            tl_file = file_copy(td_mpp%t_proc(ji))
+            mpp__copy_unit%t_proc(ji) = file_copy(tl_file)
          ENDDO
-      ENDIF
-
-   END SUBROUTINE mpp__copy
-   ! @endcode
+         ! clean
+         CALL file_clean(tl_file)
+      ENDIF
+
+   END FUNCTION mpp__copy_unit
+   !-------------------------------------------------------------------
+   !> @brief
+   !> This subroutine copy an array of mpp structure in another one
+   !> @details 
+   !> mpp file are copied in a temporary array, 
+   !> so input and output mpp structure do not point on the same 
+   !> "memory cell", and so on are independant. 
+   !>
+   !> @warning do not use on the output of a function who create or read an
+   !> structure (ex: tl_file=file_copy(file_init()) is forbidden).
+   !> This will create memory leaks.
+   !> @warning to avoid infinite loop, do not use any function inside 
+   !> this subroutine
+   !>
+   !> @author J.Paul
+   !> - November, 2013- Initial Version
+   !> @date November, 2014
+   !>    - use function instead of overload assignment operator 
+   !> (to avoid memory leak)
+   !>
+   !> @param[in] td_mpp   mpp structure
+   !> @return copy of input array of mpp structure
+   !-------------------------------------------------------------------
+   FUNCTION mpp__copy_arr( td_mpp )
+      IMPLICIT NONE
+      ! Argument
+      TYPE(TMPP), DIMENSION(:), INTENT(IN)  :: td_mpp
+      ! function
+      TYPE(TMPP), DIMENSION(SIZE(td_mpp(:))) :: mpp__copy_arr
+
+      ! local variable
+      ! loop indices
+      INTEGER(i4) :: ji
+      !----------------------------------------------------------------
+
+      DO ji=1,SIZE(td_mpp(:))
+         mpp__copy_arr(ji)=mpp_copy(td_mpp(ji))
+      ENDDO
+
+   END FUNCTION mpp__copy_arr
    !-------------------------------------------------------------------
    !> @brief This subroutine print some information about mpp strucutre.
@@ -297,7 +456,6 @@
    !> - Nov, 2013- Initial Version
    !
-   !> @param[in] td_mpp : mpp structure
-   !-------------------------------------------------------------------
-   ! @code
+   !> @param[in] td_mpp mpp structure
+   !-------------------------------------------------------------------
    SUBROUTINE mpp_print(td_mpp)
       IMPLICIT NONE
@@ -307,5 +465,5 @@
 
       ! local variable
-      INTEGER(i4), PARAMETER :: ip_freq = 4
+      INTEGER(i4), PARAMETER :: il_freq = 4
 
       INTEGER(i4), DIMENSION(:,:), ALLOCATABLE :: il_proc
@@ -321,5 +479,5 @@
       !----------------------------------------------------------------
 
-      WRITE(*,'((a,a),2(/3x,a,a),6(/3x,a,i0))')&
+      WRITE(*,'((a,a),2(/3x,a,a),9(/3x,a,i0))')&
       &  "MPP : ",TRIM(td_mpp%c_name), &
       &  " type   : ",TRIM(td_mpp%c_type), &
@@ -330,5 +488,8 @@
       &  " preci  : ",td_mpp%i_preci, &
       &  " precj  : ",td_mpp%i_precj, &
-      &  " ndim   : ",td_mpp%i_ndim
+      &  " ndim   : ",td_mpp%i_ndim,  &
+      &  " overlap: ",td_mpp%i_ew, &
+      &  " perio  : ",td_mpp%i_perio, &
+      &  " pivot  : ",td_mpp%i_pivot
 
       ! print dimension
@@ -363,11 +524,12 @@
                &  td_mpp%t_proc(ji)%i_lej
 
-               !! attribute
-               !DO jj=1, td_mpp%t_proc(ji)%i_natt
-               !   CALL att_print(td_mpp%t_proc(ji)%t_att(jj))
-               !ENDDO
-
-
             ENDDO
+
+            IF( td_mpp%t_proc(1)%i_nvar > 0 )THEN
+               WRITE(*,'(/a)') " Variable(s) used : "
+               DO ji=1,td_mpp%t_proc(1)%i_nvar
+                  WRITE(*,'(3x,a)') TRIM(td_mpp%t_proc(1)%t_var(ji)%c_name) 
+               ENDDO
+            ENDIF
 
          ELSE
@@ -387,11 +549,13 @@
                &  td_mpp%t_proc(ji)%i_lej
 
-               !! attribute
-               !DO jj=1, td_mpp%t_proc(ji)%i_natt
-               !   CALL att_print(td_mpp%t_proc(ji)%t_att(jj))
-               !ENDDO
-
             ENDDO
             
+            IF( td_mpp%t_proc(1)%i_nvar > 0 )THEN
+               WRITE(*,'(/a)') " Variable(s) used : "
+               DO ji=1,td_mpp%t_proc(1)%i_nvar
+                  WRITE(*,'(3x,a)') TRIM(td_mpp%t_proc(1)%t_var(ji)%c_name) 
+               ENDDO
+            ENDIF
+
             ALLOCATE( il_proc(td_mpp%i_niproc,td_mpp%i_njproc) )
             ALLOCATE( il_lci(td_mpp%i_niproc,td_mpp%i_njproc) )
@@ -407,6 +571,6 @@
 
             jl = 1
-            DO jk = 1,(td_mpp%i_niproc-1)/ip_freq+1
-               jm = MIN(td_mpp%i_niproc, jl+ip_freq-1)
+            DO jk = 1,(td_mpp%i_niproc-1)/il_freq+1
+               jm = MIN(td_mpp%i_niproc, jl+il_freq-1)
                WRITE(*,*)
                WRITE(*,9401) (ji, ji = jl,jm)
@@ -419,5 +583,5 @@
                   WRITE(*,9400) ('***', ji = jl,jm-1)
                ENDDO
-               jl = jl+ip_freq
+               jl = jl+il_freq
             ENDDO
          
@@ -439,9 +603,8 @@
 
    END SUBROUTINE mpp_print
-   ! @endcode
    !-------------------------------------------------------------------
    !> @brief
-   !> This function initialised mpp structure, given file name, mask and number of
-   !> processor following I and J
+   !> This function initialise mpp structure, given file name, 
+   !> and optionaly mask and number of processor following I and J
    !> @detail
    !> - If no total number of processor is defined (id_nproc), optimize 
@@ -452,25 +615,27 @@
    !
    !> @author J.Paul
-   !> @date Nov, 2013
-   !
-   !> @param[in] cd_file : file name of one file composing mpp domain
-   !> @param[in] id_mask : domain mask
-   !> @param[in] id_niproc : number of processors following i
-   !> @param[in] id_njproc : number of processors following j
-   !> @param[in] id_nproc  : total number of processors
-   !> @param[in] id_preci  : i-direction overlap region
-   !> @param[in] id_precj  : j-direction overlap region
-   !> @param[in] cd_type   : type of the files (cdf, cdf4, dimg)
+   !> @date November, 2013 - Initial version
+   !
+   !> @param[in] cd_file   file name of one file composing mpp domain
+   !> @param[in] id_mask   domain mask
+   !> @param[in] id_niproc number of processors following i
+   !> @param[in] id_njproc number of processors following j
+   !> @param[in] id_nproc  total number of processors
+   !> @param[in] id_preci  i-direction overlap region
+   !> @param[in] id_precj  j-direction overlap region
+   !> @param[in] cd_type   type of the files (cdf, cdf4, dimg)
+   !> @param[in] id_ew     east-west overlap
+   !> @param[in] id_perio  NEMO periodicity index
+   !> @param[in] id_pivot  NEMO pivot point index F(0),T(1)
    !> @return mpp structure
    !-------------------------------------------------------------------
-   !> @code
    TYPE(TMPP) FUNCTION mpp__init_mask(cd_file, id_mask,              &
    &                                  id_niproc, id_njproc, id_nproc,&
    &                                  id_preci, id_precj,            &
-                                      cd_type)
+                                      cd_type, id_ew, id_perio, id_pivot)
       IMPLICIT NONE
       ! Argument
       CHARACTER(LEN=*),            INTENT(IN) :: cd_file
-      INTEGER(i4), DIMENSION(:,:), INTENT(IN), OPTIONAL :: id_mask
+      INTEGER(i4), DIMENSION(:,:), INTENT(IN) :: id_mask
       INTEGER(i4),                 INTENT(IN), OPTIONAL :: id_niproc
       INTEGER(i4),                 INTENT(IN), OPTIONAL :: id_njproc
@@ -479,4 +644,7 @@
       INTEGER(i4),                 INTENT(IN), OPTIONAL :: id_precj
       CHARACTER(LEN=*),            INTENT(IN), OPTIONAL :: cd_type
+      INTEGER(i4),                 INTENT(IN), OPTIONAL :: id_ew
+      INTEGER(i4),                 INTENT(IN), OPTIONAL :: id_perio
+      INTEGER(i4),                 INTENT(IN), OPTIONAL :: id_pivot
 
       ! local variable
@@ -494,7 +662,4 @@
       ! clean mpp
       CALL mpp_clean(mpp__init_mask)
-
-      ! get mpp name
-      mpp__init_mask%c_name=TRIM(file_rename(cd_file))
 
       ! check type
@@ -518,14 +683,18 @@
       ENDIF
 
-      IF( PRESENT(id_mask) )THEN
-         ! get global domain dimension
-         il_shape(:)=SHAPE(id_mask)
-
-         tl_dim=dim_init('X',il_shape(1))
-         CALL mpp_add_dim(mpp__init_mask, tl_dim)
-
-         tl_dim=dim_init('Y',il_shape(2))
-         CALL mpp_add_dim(mpp__init_mask,tl_dim)
-      ENDIF
+      ! get mpp name
+      mpp__init_mask%c_name=TRIM(file_rename(cd_file))
+
+      ! get global domain dimension
+      il_shape(:)=SHAPE(id_mask)
+
+      tl_dim=dim_init('X',il_shape(1))
+      CALL mpp_add_dim(mpp__init_mask, tl_dim)
+
+      tl_dim=dim_init('Y',il_shape(2))
+      CALL mpp_add_dim(mpp__init_mask, tl_dim)
+
+      ! clean
+      CALL dim_clean(tl_dim)
 
       IF( (       PRESENT(id_niproc)  .AND. (.NOT. PRESENT(id_niproc))) .OR. &
@@ -546,4 +715,10 @@
       IF( PRESENT(id_precj) ) mpp__init_mask%i_precj= id_precj
 
+      ! east-west overlap
+      IF( PRESENT(id_ew) ) mpp__init_mask%i_ew= id_ew
+      ! NEMO periodicity
+      IF( PRESENT(id_perio) ) mpp__init_mask%i_perio= id_perio
+      IF( PRESENT(id_pivot) ) mpp__init_mask%i_pivot= id_pivot
+
       IF( mpp__init_mask%i_nproc  /= 0 .AND. &
       &   mpp__init_mask%i_niproc /= 0 .AND. &
@@ -560,5 +735,6 @@
       ELSE
 
-         IF( mpp__init_mask%i_niproc /= 0 .AND. mpp__init_mask%i_njproc /= 0 )THEN
+         IF( mpp__init_mask%i_niproc /= 0 .AND. &
+         &   mpp__init_mask%i_njproc /= 0 )THEN
             ! compute domain decomposition
             CALL mpp__compute( mpp__init_mask )
@@ -570,9 +746,14 @@
 
          ELSE
-            CALL logger_error("MPP INIT: can't define domain decomposition")
-            CALL logger_debug ("MPP INIT: maximum number of processor to be used "//&
-            &  "or number of processor following I and J direction must "//&
-            &  "be specified.")
+            CALL logger_warn("MPP INIT: number of processor to be used "//&
+            &                "not specify. force to one.")
+            mpp__init_mask%i_nproc  = 1
+            ! optimiz
+            CALL mpp__optimiz( mpp__init_mask, id_mask )
          ENDIF
+         CALL logger_info("MPP INIT: domain decoposition : "//&
+         &  'niproc('//TRIM(fct_str(mpp__init_mask%i_niproc))//') * '//&
+         &  'njproc('//TRIM(fct_str(mpp__init_mask%i_njproc))//') = '//&
+         &  'nproc('//TRIM(fct_str(mpp__init_mask%i_nproc))//')' )
 
          ! get domain type
@@ -593,4 +774,6 @@
             mpp__init_mask%t_proc(ji)%c_type=TRIM(mpp__init_mask%c_type)
 
+            ! clean
+            CALL dim_clean(tl_dim)
          ENDDO
 
@@ -640,12 +823,13 @@
          CALL mpp_add_att(mpp__init_mask, tl_att)         
 
+         ! clean
+         CALL att_clean(tl_att)
       ENDIF
 
    END FUNCTION mpp__init_mask
-   !> @endcode
    !-------------------------------------------------------------------
    !> @brief
-   !> This function initialised mpp structure, given variable strcuture 
-   !> and number of processor following I and J
+   !> This function initialise mpp structure, given variable strcuture 
+   !> and optionaly number of processor following I and J
    !> @detail
    !> - If no total number of processor is defined (id_nproc), optimize 
@@ -656,20 +840,22 @@
    !
    !> @author J.Paul
-   !> @date Nov, 2013
-   !
-   !> @param[in] cd_file : file name of one file composing mpp domain
-   !> @param[in] td_var : variable structure
-   !> @param[in] id_niproc : number of processors following i
-   !> @param[in] id_njproc : number of processors following j
-   !> @param[in] id_nproc  : total number of processors
-   !> @param[in] id_preci  : i-direction overlap region
-   !> @param[in] id_precj  : j-direction overlap region
-   !> @param[in] cd_type   : type of the files (cdf, cdf4, dimg)
+   !> @date November, 2013 - Initial version
+   !
+   !> @param[in] cd_file   file name of one file composing mpp domain
+   !> @param[in] td_var    variable structure
+   !> @param[in] id_niproc number of processors following i
+   !> @param[in] id_njproc number of processors following j
+   !> @param[in] id_nproc  total number of processors
+   !> @param[in] id_preci  i-direction overlap region
+   !> @param[in] id_precj  j-direction overlap region
+   !> @param[in] cd_type   type of the files (cdf, cdf4, dimg)
+   !> @param[in] id_perio  NEMO periodicity index
+   !> @param[in] id_pivot  NEMO pivot point index F(0),T(1)
    !> @return mpp structure
    !-------------------------------------------------------------------
-   !> @code
    TYPE(TMPP) FUNCTION mpp__init_var( cd_file, td_var,               &
    &                                  id_niproc, id_njproc, id_nproc,&
-   &                                  id_preci, id_precj, cd_type )
+   &                                  id_preci, id_precj, cd_type,   &
+   &                                  id_perio, id_pivot )
       IMPLICIT NONE
       ! Argument
@@ -682,16 +868,22 @@
       INTEGER(i4),      INTENT(IN), OPTIONAL :: id_precj
       CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: cd_type
+      INTEGER(i4),      INTENT(IN), OPTIONAL :: id_perio
+      INTEGER(i4),      INTENT(IN), OPTIONAL :: id_pivot
 
       ! local variable
-      INTEGER(i4), DIMENSION(:,:), ALLOCATABLE :: il_mask
+      INTEGER(i4), DIMENSION(:,:,:), ALLOCATABLE :: il_mask
       !----------------------------------------------------------------
 
       IF( ASSOCIATED(td_var%d_value) )THEN
-         ALLOCATE( il_mask(td_var%t_dim(1)%i_len, td_var%t_dim(2)%i_len) )
-         il_mask(:,:)=var_get_mask(td_var)
+         ALLOCATE( il_mask(td_var%t_dim(1)%i_len, &
+         &                 td_var%t_dim(2)%i_len, &
+         &                 td_var%t_dim(3)%i_len) )
+         il_mask(:,:,:)=var_get_mask(td_var)
          
-         mpp__init_var=mpp_init( cd_file, il_mask(:,:),         &
+         mpp__init_var=mpp_init( cd_file, il_mask(:,:,1),       &
          &                       id_niproc, id_njproc, id_nproc,&
-         &                       id_preci, id_precj, cd_type )
+         &                       id_preci, id_precj, cd_type,   &
+         &                       id_ew=td_var%i_ew, &
+         &                       id_perio=id_perio, id_pivot=id_pivot)
 
          DEALLOCATE(il_mask)
@@ -701,31 +893,49 @@
 
    END FUNCTION mpp__init_var
-   !> @endcode
-   !-------------------------------------------------------------------
-   !> @brief This function initalise a mpp structure, 
-   !> reading one restart dimg file, or some netcdf files.
-   !
+   !-------------------------------------------------------------------
+   !> @brief This function initalise a mpp structure given file structure. 
    !> @details 
-   !>
-   !> @warning td_file should be not opened
-   !>
-   !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[in] td_file : file strcuture
+   !> It reads restart dimg files, or some netcdf files.
+   !>
+   !> @warning 
+   !>  netcdf file must contains some attributes:
+   !>    - DOMAIN_number_total 
+   !>    - DOMAIN_size_global
+   !>    - DOMAIN_number
+   !>    - DOMAIN_position_first
+   !>    - DOMAIN_position_last
+   !>    - DOMAIN_halo_size_start
+   !>    - DOMAIN_halo_size_end
+   !>  or the file is assume to be no mpp file.
+   !>  
+   !> 
+   !>
+   !> @author J.Paul
+   !> - November, 2013- Initial Version
+   !
+   !> @param[in] td_file   file strcuture
+   !> @param[in] id_ew     east-west overlap
+   !> @param[in] id_perio  NEMO periodicity index
+   !> @param[in] id_pivot  NEMO pivot point index F(0),T(1)
    !> @return mpp structure
    !-------------------------------------------------------------------
-   ! @code
-   TYPE(TMPP) FUNCTION mpp__init_read( td_file )
+   TYPE(TMPP) FUNCTION mpp__init_file( td_file, id_ew, id_perio, id_pivot )
       IMPLICIT NONE
 
       ! Argument
       TYPE(TFILE), INTENT(IN) :: td_file
+      INTEGER(i4), INTENT(IN), OPTIONAL :: id_ew
+      INTEGER(i4), INTENT(IN), OPTIONAL :: id_perio
+      INTEGER(i4), INTENT(IN), OPTIONAL :: id_pivot
 
       ! local variable
       TYPE(TMPP)  :: tl_mpp
+      
       TYPE(TFILE) :: tl_file
+      
       TYPE(TDIM)  :: tl_dim
+
       TYPE(TATT)  :: tl_att
+
       INTEGER(i4) :: il_nproc
       INTEGER(i4) :: il_attid
@@ -737,5 +947,5 @@
 
       ! clean mpp
-      CALL mpp_clean(mpp__init_read)
+      CALL mpp_clean(mpp__init_file)
 
       ! check file type
@@ -743,6 +953,5 @@
          CASE('cdf')
             ! need to read all file to get domain decomposition
-
-            tl_file=td_file
+            tl_file=file_copy(td_file)
 
             ! open file
@@ -750,5 +959,5 @@
 
             ! read first file domain decomposition
-            tl_mpp=mpp__init_read_cdf(tl_file)
+            tl_mpp=mpp__init_file_cdf(tl_file)
 
             ! get number of processor/file to be read
@@ -779,19 +988,19 @@
 
                   ! read domain decomposition
-                  tl_mpp = mpp__init_read_cdf(tl_file)
+                  tl_mpp = mpp__init_file_cdf(tl_file)
                   IF( ji == 1 )THEN
-                     mpp__init_read=tl_mpp
+                     mpp__init_file=mpp_copy(tl_mpp)
                   ELSE
-                     IF( ANY( mpp__init_read%t_dim(1:2)%i_len /= &
+                     IF( ANY( mpp__init_file%t_dim(1:2)%i_len /= &
                                       tl_mpp%t_dim(1:2)%i_len) )THEN
 
-                        CALL logger_error("INIT READ: dimension from file "//&
+                        CALL logger_error("MPP INIT READ: dimension from file "//&
                         &     TRIM(tl_file%c_name)//" and mpp strcuture "//&
-                        &     TRIM(mpp__init_read%c_name)//"differ ")
+                        &     TRIM(mpp__init_file%c_name)//"differ ")
 
                      ELSE
 
                         ! add processor to mpp strcuture
-                        CALL mpp__add_proc(mpp__init_read, tl_mpp%t_proc(1))
+                        CALL mpp__add_proc(mpp__init_file, tl_mpp%t_proc(1))
 
                      ENDIF
@@ -802,74 +1011,84 @@
 
                ENDDO
-               IF( mpp__init_read%i_nproc /= il_nproc )THEN
-                  CALL logger_error("INIT READ: some processors can't be added &
+               IF( mpp__init_file%i_nproc /= il_nproc )THEN
+                  CALL logger_error("MPP INIT READ: some processors can't be added &
                   &               to mpp structure")
                ENDIF
 
             ELSE
-               mpp__init_read=tl_mpp
+               mpp__init_file=mpp_copy(tl_mpp)
             ENDIF
 
             ! mpp type
-            mpp__init_read%c_type=TRIM(td_file%c_type)
+            mpp__init_file%c_type=TRIM(td_file%c_type)
 
             ! mpp domain type
-            CALL mpp_get_dom(mpp__init_read)
+            CALL mpp_get_dom(mpp__init_file)
 
             ! create some attributes for domain decomposition (use with dimg file)
-            tl_att=att_init( "DOMAIN_number_total", mpp__init_read%i_nproc )
-            CALL mpp_add_att(mpp__init_read, tl_att)
-
-            tl_att=att_init( "DOMAIN_I_position_first", mpp__init_read%t_proc(:)%i_impp )
-            CALL mpp_add_att(mpp__init_read, tl_att)
-
-            tl_att=att_init( "DOMAIN_J_position_first", mpp__init_read%t_proc(:)%i_jmpp )
-            CALL mpp_add_att(mpp__init_read, tl_att)
-
-            tl_att=att_init( "DOMAIN_I_position_last", mpp__init_read%t_proc(:)%i_lci )
-            CALL mpp_add_att(mpp__init_read, tl_att)
-
-            tl_att=att_init( "DOMAIN_J_position_last", mpp__init_read%t_proc(:)%i_lcj )
-            CALL mpp_add_att(mpp__init_read, tl_att)
-
-            tl_att=att_init( "DOMAIN_I_halo_size_start", mpp__init_read%t_proc(:)%i_ldi )
-            CALL mpp_add_att(mpp__init_read, tl_att)
-
-            tl_att=att_init( "DOMAIN_J_halo_size_start", mpp__init_read%t_proc(:)%i_ldj )
-            CALL mpp_add_att(mpp__init_read, tl_att)
-
-            tl_att=att_init( "DOMAIN_I_halo_size_end", mpp__init_read%t_proc(:)%i_lei )
-            CALL mpp_add_att(mpp__init_read, tl_att)
-
-            tl_att=att_init( "DOMAIN_J_halo_size_end", mpp__init_read%t_proc(:)%i_lej )
-            CALL mpp_add_att(mpp__init_read, tl_att)
+            tl_att=att_init( "DOMAIN_number_total", mpp__init_file%i_nproc )
+            CALL mpp_add_att(mpp__init_file, tl_att)
+
+            tl_att=att_init( "DOMAIN_I_position_first", mpp__init_file%t_proc(:)%i_impp )
+            CALL mpp_add_att(mpp__init_file, tl_att)
+
+            tl_att=att_init( "DOMAIN_J_position_first", mpp__init_file%t_proc(:)%i_jmpp )
+            CALL mpp_add_att(mpp__init_file, tl_att)
+
+            tl_att=att_init( "DOMAIN_I_position_last", mpp__init_file%t_proc(:)%i_lci )
+            CALL mpp_add_att(mpp__init_file, tl_att)
+
+            tl_att=att_init( "DOMAIN_J_position_last", mpp__init_file%t_proc(:)%i_lcj )
+            CALL mpp_add_att(mpp__init_file, tl_att)
+
+            tl_att=att_init( "DOMAIN_I_halo_size_start", mpp__init_file%t_proc(:)%i_ldi )
+            CALL mpp_add_att(mpp__init_file, tl_att)
+
+            tl_att=att_init( "DOMAIN_J_halo_size_start", mpp__init_file%t_proc(:)%i_ldj )
+            CALL mpp_add_att(mpp__init_file, tl_att)
+
+            tl_att=att_init( "DOMAIN_I_halo_size_end", mpp__init_file%t_proc(:)%i_lei )
+            CALL mpp_add_att(mpp__init_file, tl_att)
+
+            tl_att=att_init( "DOMAIN_J_halo_size_end", mpp__init_file%t_proc(:)%i_lej )
+            CALL mpp_add_att(mpp__init_file, tl_att)
             
+            ! clean
+            CALL mpp_clean(tl_mpp)
+            CALL att_clean(tl_att)
 
          CASE('dimg')
             ! domain decomposition could be read in one file
 
-            tl_file=td_file
+            tl_file=file_copy(td_file)
             ! open file
+            CALL logger_debug("MPP INIT READ: open file "//TRIM(tl_file%c_name))
             CALL iom_open(tl_file)
 
+            CALL logger_debug("MPP INIT READ: read mpp structure ")
             ! read mpp structure
-            mpp__init_read=mpp__init_read_rstdimg(tl_file)
+            mpp__init_file=mpp__init_file_rstdimg(tl_file)
 
             ! mpp type
-            mpp__init_read%c_type=TRIM(td_file%c_type)
+            mpp__init_file%c_type=TRIM(td_file%c_type)
 
             ! mpp domain type
-            CALL mpp_get_dom(mpp__init_read)
+            CALL logger_debug("MPP INIT READ: mpp_get_dom ")
+            CALL mpp_get_dom(mpp__init_file)
 
             ! get processor size
-            DO ji=1,mpp__init_read%i_nproc
-
-               il_shape(:)=mpp_get_proc_size( mpp__init_read, ji )
+            CALL logger_debug("MPP INIT READ: get processor size ")
+            DO ji=1,mpp__init_file%i_nproc
+
+               il_shape(:)=mpp_get_proc_size( mpp__init_file, ji )
 
                tl_dim=dim_init('X',il_shape(1))
-               CALL file_add_dim(mpp__init_read%t_proc(ji), tl_dim)
+               CALL file_add_dim(mpp__init_file%t_proc(ji), tl_dim)
 
                tl_dim=dim_init('Y',il_shape(2))
-               CALL file_add_dim(mpp__init_read%t_proc(ji), tl_dim)            
+               CALL file_add_dim(mpp__init_file%t_proc(ji), tl_dim)            
+
+               ! clean
+               CALL dim_clean(tl_dim)
 
             ENDDO
@@ -879,10 +1098,30 @@
 
          CASE DEFAULT
-            CALL logger_error("INIT READ: invalid type for file "//&
+            CALL logger_error("MPP INIT READ: invalid type for file "//&
             &              TRIM(tl_file%c_name))
       END SELECT
 
-   END FUNCTION mpp__init_read
-   ! @endcode
+      ! east west overlap
+      IF( PRESENT(id_ew) ) mpp__init_file%i_ew=id_ew
+      ! NEMO periodicity
+      IF( PRESENT(id_perio) )THEN
+         mpp__init_file%i_perio= id_perio
+         SELECT CASE(id_perio)
+         CASE(3,4)
+            mpp__init_file%i_pivot=1
+         CASE(5,6)
+            mpp__init_file%i_pivot=0
+         CASE DEFAULT
+            mpp__init_file%i_pivot=1
+         END SELECT
+      ENDIF
+
+      IF( PRESENT(id_pivot) ) mpp__init_file%i_pivot= id_pivot
+
+      ! clean 
+      CALL file_clean(tl_file)
+
+      CALL logger_debug("MPP INIT READ: fin init_read ")
+   END FUNCTION mpp__init_file
    !-------------------------------------------------------------------
    !> @brief This function initalise a mpp structure, 
@@ -892,11 +1131,10 @@
    !
    !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[in] td_file : file strcuture
+   !> - November, 2013- Initial Version
+   !>
+   !> @param[in] td_file   file strcuture
    !> @return mpp structure
    !-------------------------------------------------------------------
-   ! @code
-   TYPE(TMPP) FUNCTION mpp__init_read_cdf( td_file )
+   TYPE(TMPP) FUNCTION mpp__init_file_cdf( td_file )
       IMPLICIT NONE
 
@@ -906,12 +1144,16 @@
       ! local variable
       INTEGER(i4) :: il_attid  ! attribute id
+      
       LOGICAL     :: ll_exist
       LOGICAL     :: ll_open
 
       TYPE(TATT)  :: tl_att
+
+      TYPE(TDIM)  :: tl_dim
+      
       TYPE(TFILE) :: tl_proc
       !----------------------------------------------------------------
 
-      CALL logger_trace(" INIT READ: netcdf file "//TRIM(td_file%c_name))
+      CALL logger_trace("MPP INIT READ: netcdf file "//TRIM(td_file%c_name))
 
       INQUIRE( FILE=TRIM(td_file%c_name), EXIST=ll_exist, OPENED=ll_open )
@@ -921,13 +1163,13 @@
          IF( td_file%i_id == 0 )THEN
             CALL logger_info(" id "//TRIM(fct_str(td_file%i_id))) 
-            CALL logger_error("INIT READ: netcdf file "//TRIM(td_file%c_name)//&
+            CALL logger_error("MPP INIT READ: netcdf file "//TRIM(td_file%c_name)//&
             &  " not opened")
          ELSE
 
             ! get mpp name
-            mpp__init_read_cdf%c_name=TRIM( file_rename(td_file%c_name) )
+            mpp__init_file_cdf%c_name=TRIM( file_rename(td_file%c_name) )
 
             ! add type
-            mpp__init_read_cdf%c_type="cdf"
+            mpp__init_file_cdf%c_type="cdf"
 
             ! global domain size
@@ -937,22 +1179,24 @@
             ENDIF
             IF( il_attid /= 0 )THEN
-               mpp__init_read_cdf%t_dim(1)= &
-               &  dim_init('X',INT(td_file%t_att(il_attid)%d_value(1)))
-               mpp__init_read_cdf%t_dim(2)= &
-               &  dim_init('Y',INT(td_file%t_att(il_attid)%d_value(2)))
-            ELSE
-               mpp__init_read_cdf%t_dim(1)= &
-               &  dim_init( td_file%t_dim(1)%c_name, td_file%t_dim(1)%i_len)
-               mpp__init_read_cdf%t_dim(2)= &
-               &  dim_init( td_file%t_dim(2)%c_name, td_file%t_dim(2)%i_len)
-
-            ENDIF
-            mpp__init_read_cdf%t_dim(3)= &
-            &  dim_init( td_file%t_dim(3)%c_name, td_file%t_dim(1)%i_len)
-            mpp__init_read_cdf%t_dim(4)= &
-            &  dim_init( td_file%t_dim(4)%c_name, td_file%t_dim(2)%i_len)
+               tl_dim=dim_init('X',INT(td_file%t_att(il_attid)%d_value(1)))
+               CALL mpp_add_dim(mpp__init_file_cdf,tl_dim)
+
+               tl_dim=dim_init('Y',INT(td_file%t_att(il_attid)%d_value(2)))
+               CALL mpp_add_dim(mpp__init_file_cdf,tl_dim)
+            ELSE ! assume only one file (not mpp)
+               tl_dim=dim_init( td_file%t_dim(1)%c_name, td_file%t_dim(1)%i_len)
+               CALL mpp_add_dim(mpp__init_file_cdf,tl_dim)
+
+               tl_dim=dim_init( td_file%t_dim(2)%c_name, td_file%t_dim(2)%i_len)
+               CALL mpp_add_dim(mpp__init_file_cdf,tl_dim)
+            ENDIF
+            tl_dim=dim_init( td_file%t_dim(3)%c_name, td_file%t_dim(3)%i_len)
+            CALL mpp_add_dim(mpp__init_file_cdf,tl_dim)
+
+            tl_dim=dim_init( td_file%t_dim(4)%c_name, td_file%t_dim(4)%i_len)
+            CALL mpp_add_dim(mpp__init_file_cdf,tl_dim)
 
             ! initialise file/processor
-            tl_proc=td_file
+            tl_proc=file_copy(td_file)
 
             ! processor id
@@ -968,5 +1212,5 @@
 
             ! processor dimension
-            tl_proc%t_dim(:)=td_file%t_dim(:)
+            tl_proc%t_dim(:)=dim_copy(td_file%t_dim(:))
 
             ! DOMAIN_position_first
@@ -992,6 +1236,6 @@
                tl_proc%i_lcj = INT(td_file%t_att(il_attid)%d_value(2)) + tl_proc%i_jmpp
             ELSE
-               tl_proc%i_lci = mpp__init_read_cdf%t_dim(1)%i_len
-               tl_proc%i_lcj = mpp__init_read_cdf%t_dim(2)%i_len
+               tl_proc%i_lci = mpp__init_file_cdf%t_dim(1)%i_len
+               tl_proc%i_lcj = mpp__init_file_cdf%t_dim(2)%i_len
             ENDIF
 
@@ -1018,11 +1262,11 @@
                tl_proc%i_lej = INT(td_file%t_att(il_attid)%d_value(2))
             ELSE
-               tl_proc%i_lei = mpp__init_read_cdf%t_dim(1)%i_len
-               tl_proc%i_lej = mpp__init_read_cdf%t_dim(2)%i_len
+               tl_proc%i_lei = mpp__init_file_cdf%t_dim(1)%i_len
+               tl_proc%i_lej = mpp__init_file_cdf%t_dim(2)%i_len
             ENDIF
 
             ! add attributes
             tl_att=att_init( "DOMAIN_size_global", &
-            &                mpp__init_read_cdf%t_dim(:)%i_len)
+            &                mpp__init_file_cdf%t_dim(:)%i_len)
             CALL file_move_att(tl_proc, tl_att)
 
@@ -1047,16 +1291,18 @@
 
             ! add processor to mpp structure
-            CALL mpp__add_proc(mpp__init_read_cdf, tl_proc)
-
+            CALL mpp__add_proc(mpp__init_file_cdf, tl_proc)
+
+            ! clean 
+            CALL file_clean(tl_proc)
+            CALL att_clean(tl_att)
          ENDIF
 
       ELSE
 
-         CALL logger_error("INIT READ: netcdf file "//TRIM(td_file%c_name)//&
+         CALL logger_error("MPP INIT READ: netcdf file "//TRIM(td_file%c_name)//&
          &  " do not exist")
 
       ENDIF      
-   END FUNCTION mpp__init_read_cdf
-   ! @endcode
+   END FUNCTION mpp__init_file_cdf
    !-------------------------------------------------------------------
    !> @brief This function initalise a mpp structure, 
@@ -1066,11 +1312,10 @@
    !
    !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[in] td_file : file strcuture
+   !> - November, 2013- Initial Version
+   !
+   !> @param[in] td_file   file strcuture
    !> @return mpp structure
    !-------------------------------------------------------------------
-   ! @code
-   TYPE(TMPP) FUNCTION mpp__init_read_rstdimg( td_file )
+   TYPE(TMPP) FUNCTION mpp__init_file_rstdimg( td_file )
       IMPLICIT NONE
 
@@ -1079,20 +1324,21 @@
 
       ! local variable
-      INTEGER(i4) :: il_status
-      INTEGER(i4) :: il_recl                          ! record length 
-      INTEGER(i4) :: il_nx, il_ny, il_nz              ! x,y,z dimension 
-      INTEGER(i4) :: il_n0d, il_n1d, il_n2d, il_n3d   ! number of 0/1/2/3D variables 
-      INTEGER(i4) :: il_iglo, il_jglo                 ! domain global size
-      INTEGER(i4) :: il_rhd                           ! record of the header infos
-      INTEGER(i4) :: il_pni, il_pnj, il_pnij          ! domain decomposition
-      INTEGER(i4) :: il_area                          ! domain index
-
-      LOGICAL     ::  ll_exist
-      LOGICAL     ::  ll_open
+      INTEGER(i4)       :: il_status
+      INTEGER(i4)       :: il_recl                          ! record length 
+      INTEGER(i4)       :: il_nx, il_ny, il_nz              ! x,y,z dimension 
+      INTEGER(i4)       :: il_n0d, il_n1d, il_n2d, il_n3d   ! number of 0/1/2/3D variables 
+      INTEGER(i4)       :: il_iglo, il_jglo                 ! domain global size
+      INTEGER(i4)       :: il_rhd                           ! record of the header infos
+      INTEGER(i4)       :: il_pni, il_pnj, il_pnij          ! domain decomposition
+      INTEGER(i4)       :: il_area                          ! domain index
+
+      LOGICAL           ::  ll_exist
+      LOGICAL           ::  ll_open
 
       CHARACTER(LEN=lc) :: cl_file
 
-      TYPE(TDIM)  :: tl_dim ! dimension structure
-      TYPE(TATT)  :: tl_att
+      TYPE(TDIM)        :: tl_dim ! dimension structure
+      TYPE(TATT)        :: tl_att
+      TYPE(TFILE)       :: tl_proc
 
       ! loop indices
@@ -1104,5 +1350,5 @@
 
          IF( .NOT. ll_open )THEN
-            CALL logger_error("INIT READ: dimg file "//TRIM(td_file%c_name)//&
+            CALL logger_error("MPP INIT READ: dimg file "//TRIM(td_file%c_name)//&
             &  " not opened")
          ELSE
@@ -1118,22 +1364,35 @@
             CALL fct_err(il_status)
             IF( il_status /= 0 )THEN
-               CALL logger_error("INIT READ: read first line header of "//&
+               CALL logger_error("MPP INIT READ: read first line header of "//&
                &              TRIM(td_file%c_name))
             ENDIF
 
             ! get mpp name
-            mpp__init_read_rstdimg%c_name=TRIM( file_rename(td_file%c_name) )
+            mpp__init_file_rstdimg%c_name=TRIM( file_rename(td_file%c_name) )
+
+            ! add type
+            mpp__init_file_rstdimg%c_type="dimg"
 
             ! number of processors to be read
-            mpp__init_read_rstdimg%i_nproc  = il_pnij
-            mpp__init_read_rstdimg%i_niproc = il_pni
-            mpp__init_read_rstdimg%i_njproc = il_pnj
-
-            IF( ASSOCIATED(mpp__init_read_rstdimg%t_proc) )THEN
-               DEALLOCATE(mpp__init_read_rstdimg%t_proc)
-            ENDIF
-            ALLOCATE( mpp__init_read_rstdimg%t_proc(il_pnij) , stat=il_status )
+            mpp__init_file_rstdimg%i_nproc  = il_pnij
+            mpp__init_file_rstdimg%i_niproc = il_pni
+            mpp__init_file_rstdimg%i_njproc = il_pnj
+
+            IF( ASSOCIATED(mpp__init_file_rstdimg%t_proc) )THEN
+               CALL file_clean(mpp__init_file_rstdimg%t_proc(:))
+               DEALLOCATE(mpp__init_file_rstdimg%t_proc)
+            ENDIF
+            ALLOCATE( mpp__init_file_rstdimg%t_proc(il_pnij) , stat=il_status )
+
+            tl_proc=file_copy(td_file)
+            ! remove dimension from file
+            CALL dim_clean(tl_proc%t_dim(:))
+            ! initialise file/processors
+            DO ji=1,mpp__init_file_rstdimg%i_nproc
+               mpp__init_file_rstdimg%t_proc(ji)=file_copy(tl_proc)
+            ENDDO
+
             IF( il_status /= 0 )THEN
-               CALL logger_error("INIT READ: not enough space to read domain &
+               CALL logger_error("MPP INIT READ: not enough space to read domain &
                &              decomposition in file "//TRIM(td_file%c_name))
             ENDIF
@@ -1148,132 +1407,135 @@
             &     il_area,                         &
             &     il_iglo, il_jglo,                &
-            &     mpp__init_read_rstdimg%t_proc(:)%i_lci,    &
-            &     mpp__init_read_rstdimg%t_proc(:)%i_lcj,    &
-            &     mpp__init_read_rstdimg%t_proc(:)%i_ldi,    &
-            &     mpp__init_read_rstdimg%t_proc(:)%i_ldj,    &
-            &     mpp__init_read_rstdimg%t_proc(:)%i_lei,    &
-            &     mpp__init_read_rstdimg%t_proc(:)%i_lej,    &
-            &     mpp__init_read_rstdimg%t_proc(:)%i_impp,   &
-            &     mpp__init_read_rstdimg%t_proc(:)%i_jmpp
+            &     mpp__init_file_rstdimg%t_proc(:)%i_lci,    &
+            &     mpp__init_file_rstdimg%t_proc(:)%i_lcj,    &
+            &     mpp__init_file_rstdimg%t_proc(:)%i_ldi,    &
+            &     mpp__init_file_rstdimg%t_proc(:)%i_ldj,    &
+            &     mpp__init_file_rstdimg%t_proc(:)%i_lei,    &
+            &     mpp__init_file_rstdimg%t_proc(:)%i_lej,    &
+            &     mpp__init_file_rstdimg%t_proc(:)%i_impp,   &
+            &     mpp__init_file_rstdimg%t_proc(:)%i_jmpp
             CALL fct_err(il_status)
             IF( il_status /= 0 )THEN
-               CALL logger_error("INIT READ: read first line of "//&
+               CALL logger_error("MPP INIT READ: read first line of "//&
                &              TRIM(td_file%c_name))
             ENDIF
 
-            ! mpp dimension
+            ! global domain size
             tl_dim=dim_init('X',il_iglo)
-            CALL mpp_add_dim(mpp__init_read_rstdimg,tl_dim)
+            CALL mpp_add_dim(mpp__init_file_rstdimg,tl_dim)
             tl_dim=dim_init('Y',il_jglo)
-            CALL mpp_add_dim(mpp__init_read_rstdimg,tl_dim)
-
-            DO ji=1,mpp__init_read_rstdimg%i_nproc
+            CALL mpp_add_dim(mpp__init_file_rstdimg,tl_dim)
+
+            tl_dim=dim_init('Z',il_nz)
+            CALL mpp_add_dim(mpp__init_file_rstdimg,tl_dim)
+
+            DO ji=1,mpp__init_file_rstdimg%i_nproc
                ! get file name
                cl_file =  file_rename(td_file%c_name,ji)
-               mpp__init_read_rstdimg%t_proc(ji)%c_name = TRIM(cl_file)
+               mpp__init_file_rstdimg%t_proc(ji)%c_name = TRIM(cl_file)
                ! update processor id
-               mpp__init_read_rstdimg%t_proc(ji)%i_pid=ji
+               mpp__init_file_rstdimg%t_proc(ji)%i_pid=ji
 
                ! add attributes
                tl_att=att_init( "DOMAIN_number", ji )
-               CALL file_move_att(mpp__init_read_rstdimg%t_proc(ji), tl_att) 
+               CALL file_move_att(mpp__init_file_rstdimg%t_proc(ji), tl_att) 
 
                tl_att=att_init( "DOMAIN_position_first", &
-               &                (/mpp__init_read_rstdimg%t_proc(ji)%i_impp, &
-               &                  mpp__init_read_rstdimg%t_proc(ji)%i_jmpp /) )
-               CALL file_move_att(mpp__init_read_rstdimg%t_proc(ji), tl_att)
+               &                (/mpp__init_file_rstdimg%t_proc(ji)%i_impp, &
+               &                  mpp__init_file_rstdimg%t_proc(ji)%i_jmpp /) )
+               CALL file_move_att(mpp__init_file_rstdimg%t_proc(ji), tl_att)
 
                tl_att=att_init( "DOMAIN_position_last", &
-               &                (/mpp__init_read_rstdimg%t_proc(ji)%i_lci, &
-               &                  mpp__init_read_rstdimg%t_proc(ji)%i_lcj /) )
-               CALL file_move_att(mpp__init_read_rstdimg%t_proc(ji), tl_att)
+               &                (/mpp__init_file_rstdimg%t_proc(ji)%i_lci, &
+               &                  mpp__init_file_rstdimg%t_proc(ji)%i_lcj /) )
+               CALL file_move_att(mpp__init_file_rstdimg%t_proc(ji), tl_att)
 
                tl_att=att_init( "DOMAIN_halo_size_start", &
-               &                (/mpp__init_read_rstdimg%t_proc(ji)%i_ldi, &
-               &                  mpp__init_read_rstdimg%t_proc(ji)%i_ldj /) )
-               CALL file_move_att(mpp__init_read_rstdimg%t_proc(ji), tl_att)               
+               &                (/mpp__init_file_rstdimg%t_proc(ji)%i_ldi, &
+               &                  mpp__init_file_rstdimg%t_proc(ji)%i_ldj /) )
+               CALL file_move_att(mpp__init_file_rstdimg%t_proc(ji), tl_att)               
 
                tl_att=att_init( "DOMAIN_halo_size_end", &
-               &                (/mpp__init_read_rstdimg%t_proc(ji)%i_lei, &
-               &                  mpp__init_read_rstdimg%t_proc(ji)%i_lej /) )
-               CALL file_move_att(mpp__init_read_rstdimg%t_proc(ji), tl_att)
+               &                (/mpp__init_file_rstdimg%t_proc(ji)%i_lei, &
+               &                  mpp__init_file_rstdimg%t_proc(ji)%i_lej /) )
+               CALL file_move_att(mpp__init_file_rstdimg%t_proc(ji), tl_att)
             ENDDO
-      
+ 
             ! add type
-            mpp__init_read_rstdimg%t_proc(:)%c_type="dimg"
+            mpp__init_file_rstdimg%t_proc(:)%c_type="dimg"
 
             ! add attributes
             tl_att=att_init( "DOMAIN_size_global", &
-            &                mpp__init_read_rstdimg%t_dim(:)%i_len)
-            CALL mpp_move_att(mpp__init_read_rstdimg, tl_att)
+            &                mpp__init_file_rstdimg%t_dim(:)%i_len)
+            CALL mpp_move_att(mpp__init_file_rstdimg, tl_att)
 
             tl_att=att_init( "DOMAIN_number_total", &
-            &                 mpp__init_read_rstdimg%i_nproc )
-            CALL mpp_add_att(mpp__init_read_rstdimg, tl_att)
+            &                 mpp__init_file_rstdimg%i_nproc )
+            CALL mpp_move_att(mpp__init_file_rstdimg, tl_att)
 
             tl_att=att_init( "DOMAIN_I_number_total", &
-            &                 mpp__init_read_rstdimg%i_niproc )
-            CALL mpp_add_att(mpp__init_read_rstdimg, tl_att)
+            &                 mpp__init_file_rstdimg%i_niproc )
+            CALL mpp_move_att(mpp__init_file_rstdimg, tl_att)
 
             tl_att=att_init( "DOMAIN_J_number_total", &
-            &                 mpp__init_read_rstdimg%i_njproc )
-            CALL mpp_add_att(mpp__init_read_rstdimg, tl_att)
+            &                 mpp__init_file_rstdimg%i_njproc )
+            CALL mpp_move_att(mpp__init_file_rstdimg, tl_att)
 
             tl_att=att_init( "DOMAIN_I_position_first", &
-            &                 mpp__init_read_rstdimg%t_proc(:)%i_impp )
-            CALL mpp_add_att(mpp__init_read_rstdimg, tl_att)
+            &                 mpp__init_file_rstdimg%t_proc(:)%i_impp )
+            CALL mpp_move_att(mpp__init_file_rstdimg, tl_att)
 
             tl_att=att_init( "DOMAIN_J_position_first", &
-            &                 mpp__init_read_rstdimg%t_proc(:)%i_jmpp )
-            CALL mpp_add_att(mpp__init_read_rstdimg, tl_att)
+            &                 mpp__init_file_rstdimg%t_proc(:)%i_jmpp )
+            CALL mpp_move_att(mpp__init_file_rstdimg, tl_att)
 
             tl_att=att_init( "DOMAIN_I_position_last", &
-            &                 mpp__init_read_rstdimg%t_proc(:)%i_lci )
-            CALL mpp_add_att(mpp__init_read_rstdimg, tl_att)
+            &                 mpp__init_file_rstdimg%t_proc(:)%i_lci )
+            CALL mpp_move_att(mpp__init_file_rstdimg, tl_att)
 
             tl_att=att_init( "DOMAIN_J_position_last", &
-            &                 mpp__init_read_rstdimg%t_proc(:)%i_lcj )
-            CALL mpp_add_att(mpp__init_read_rstdimg, tl_att)
+            &                 mpp__init_file_rstdimg%t_proc(:)%i_lcj )
+            CALL mpp_move_att(mpp__init_file_rstdimg, tl_att)
 
             tl_att=att_init( "DOMAIN_I_halo_size_start", &
-            &                 mpp__init_read_rstdimg%t_proc(:)%i_ldi )
-            CALL mpp_add_att(mpp__init_read_rstdimg, tl_att)
+            &                 mpp__init_file_rstdimg%t_proc(:)%i_ldi )
+            CALL mpp_move_att(mpp__init_file_rstdimg, tl_att)
 
             tl_att=att_init( "DOMAIN_J_halo_size_start", &
-            &                 mpp__init_read_rstdimg%t_proc(:)%i_ldj )
-            CALL mpp_add_att(mpp__init_read_rstdimg, tl_att)
+            &                 mpp__init_file_rstdimg%t_proc(:)%i_ldj )
+            CALL mpp_move_att(mpp__init_file_rstdimg, tl_att)
 
             tl_att=att_init( "DOMAIN_I_halo_size_end", &
-            &                 mpp__init_read_rstdimg%t_proc(:)%i_lei )
-            CALL mpp_add_att(mpp__init_read_rstdimg, tl_att)
+            &                 mpp__init_file_rstdimg%t_proc(:)%i_lei )
+            CALL mpp_move_att(mpp__init_file_rstdimg, tl_att)
 
             tl_att=att_init( "DOMAIN_J_halo_size_end", &
-            &                 mpp__init_read_rstdimg%t_proc(:)%i_lej )
-            CALL mpp_add_att(mpp__init_read_rstdimg, tl_att)
+            &                 mpp__init_file_rstdimg%t_proc(:)%i_lej )
+            CALL mpp_move_att(mpp__init_file_rstdimg, tl_att)
+
+            ! clean
+            CALL dim_clean(tl_dim)
+            CALL att_clean(tl_att)
          ENDIF
 
       ELSE
 
-         CALL logger_error("INIT READ: dimg file "//TRIM(td_file%c_name)//&
+         CALL logger_error("MPP INIT READ: dimg file "//TRIM(td_file%c_name)//&
          &  " do not exist")
 
       ENDIF
 
-   END FUNCTION mpp__init_read_rstdimg
-   ! @endcode
+   END FUNCTION mpp__init_file_rstdimg
    !-------------------------------------------------------------------
    !> @brief This function check if variable and mpp structure use same
    !> dimension.
    !
-   !> @details
-   !
    !> @author J.Paul
    !> - Nov, 2013- Initial Version
    !
-   !> @param[in] td_mpp : mpp structure
-   !> @param[in] td_proc : processor structure
+   !> @param[in] td_mpp    mpp structure
+   !> @param[in] td_proc   processor structure
    !> @return dimension of processor and mpp structure agree (or not)
    !-------------------------------------------------------------------
-   ! @code
    LOGICAL FUNCTION mpp__check_proc_dim(td_mpp, td_proc)
       IMPLICIT NONE
@@ -1301,5 +1563,5 @@
             mpp__check_proc_dim=.FALSE.
 
-            CALL logger_error( " CHECK DIM: processor and mpp dimension differ" )
+            CALL logger_error( "MPP CHECK DIM: processor and mpp dimension differ" )
 
          ENDIF
@@ -1312,5 +1574,5 @@
             mpp__check_proc_dim=.FALSE.
 
-            CALL logger_error( " CHECK DIM: processor and mpp dimension differ" )
+            CALL logger_error( "MPP CHECK DIM: processor and mpp dimension differ" )
 
          ENDIF
@@ -1318,20 +1580,14 @@
 
    END FUNCTION mpp__check_proc_dim
-   ! @endcode
    !-------------------------------------------------------------------
    !> @brief
-   !>    This subroutine add variable to mpp structure.
-   !>
-   !> @detail
-   !
-   !> @author J.Paul
-   !> @date Nov, 2013
-   !
-   !> @param[inout] td_mpp : mpp strcuture
-   !> @param[in]    td_var : variable strcuture
-   !
-   !> @todo 
-   !-------------------------------------------------------------------
-   !> @code
+   !>    This subroutine add variable in all files of mpp structure.
+   !>
+   !> @author J.Paul
+   !> @date November, 2013 - Initial version
+   !
+   !> @param[inout] td_mpp mpp strcuture
+   !> @param[in]    td_var variable strcuture
+   !-------------------------------------------------------------------
    SUBROUTINE mpp_add_var( td_mpp, td_var )
       IMPLICIT NONE
@@ -1350,11 +1606,6 @@
       IF( .NOT. ASSOCIATED(td_mpp%t_proc) )THEN
 
-         CALL logger_error( "MPP ADD VAR: domain decomposition not define "//&
-         &               "for mpp "//TRIM(td_mpp%c_name))
-
-      ELSEIF( td_mpp%i_ndim == 0 )THEN
-
-         CALL logger_error( " MPP ADD VAR: no dimension define for "//&
-         &               " mpp strcuture "//TRIM(td_mpp%c_name))
+         CALL logger_error( "MPP ADD VAR: processor decomposition not "//&
+         &  "define for mpp "//TRIM(td_mpp%c_name))
 
       ELSE
@@ -1367,6 +1618,6 @@
             il_varid=0
             IF( ASSOCIATED(td_mpp%t_proc(1)%t_var) )THEN
-               il_varid=var_get_id( td_mpp%t_proc(1)%t_var(:), &
-               &                    td_var%c_name, td_var%c_stdname )
+               il_varid=var_get_index( td_mpp%t_proc(1)%t_var(:), &
+               &                       td_var%c_name, td_var%c_stdname )
             ENDIF
 
@@ -1393,4 +1644,12 @@
                IF( mpp__check_dim(td_mpp, td_var) )THEN
 
+                  ! update dimension if need be
+                  DO ji=1,ip_maxdim
+                     IF( td_var%t_dim(ji)%l_use .AND. &
+                     &   .NOT. td_mpp%t_dim(ji)%l_use )THEN
+                        CALL mpp_add_dim(td_mpp,td_var%t_dim(ji))
+                     ENDIF
+                  ENDDO
+
                   ! add variable in each processor
                   DO ji=1,td_mpp%i_nproc
@@ -1401,4 +1660,6 @@
                      CALL file_add_var(td_mpp%t_proc(ji), tl_var)
 
+                     ! clean
+                     CALL var_clean(tl_var)
                   ENDDO
 
@@ -1409,20 +1670,16 @@
 
    END SUBROUTINE mpp_add_var
-   !> @endcode
-   !-------------------------------------------------------------------
-   !> @brief This function extract from variable structure, part that will 
+   !-------------------------------------------------------------------
+   !> @brief This function extract, from variable structure, part that will 
    !> be written in processor id_procid.<br/>
    !
-   !> @details
-   !
-   !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[in] td_mpp : mpp structure
-   !> @param[in] td_var : variable structure
-   !> @param[in] id_procid : processor id
+   !> @author J.Paul
+   !> - November, 2013- Initial Version
+   !
+   !> @param[in] td_mpp    mpp structure
+   !> @param[in] td_var    variable structure
+   !> @param[in] id_procid processor id
    !> @return variable structure
    !-------------------------------------------------------------------
-   ! @code   
    TYPE(TVAR) FUNCTION mpp__split_var(td_mpp, td_var, id_procid)
       IMPLICIT NONE
@@ -1444,45 +1701,76 @@
 
       ! copy mpp
-      mpp__split_var=td_var
-
-      ! remove value over global domain from pointer
-      CALL var_del_value( mpp__split_var )
-
-      ! get processor dimension
-      il_size(:)=mpp_get_proc_size( td_mpp, id_procid )
-
-      ! define new dimension in variable structure 
-      IF( td_var%t_dim(1)%l_use )THEN
-         tl_dim=dim_init( TRIM(td_var%t_dim(1)%c_name), il_size(1) )
-         CALL var_move_dim( mpp__split_var, tl_dim )
-      ENDIF
-      IF( td_var%t_dim(2)%l_use )THEN
-         tl_dim=dim_init( TRIM(td_var%t_dim(2)%c_name), il_size(2) )
-         CALL var_move_dim( mpp__split_var, tl_dim )      
-      ENDIF
-
-      ! get processor indices
-      il_ind(:)=mpp_get_proc_index( td_mpp, id_procid )
-      il_i1 = il_ind(1)
-      il_i2 = il_ind(2)
-      il_j1 = il_ind(3)
-      il_j2 = il_ind(4)
-
-      IF( .NOT. td_var%t_dim(1)%l_use )THEN
-         il_i1=1 
-         il_i2=1 
-      ENDIF
-
-      IF( .NOT. td_var%t_dim(2)%l_use )THEN
-         il_j1=1 
-         il_j2=1 
-      ENDIF      
-
-      ! add variable value on processor
-      CALL var_add_value( mpp__split_var, &
-      &                   td_var%d_value(il_i1:il_i2, il_j1:il_j2, :, :) )
+      mpp__split_var=var_copy(td_var)
+
+      IF( ASSOCIATED(td_var%d_value) )THEN
+         ! remove value over global domain from pointer
+         CALL var_del_value( mpp__split_var )
+
+         ! get processor dimension
+         il_size(:)=mpp_get_proc_size( td_mpp, id_procid )
+
+         ! define new dimension in variable structure 
+         IF( td_var%t_dim(1)%l_use )THEN
+            tl_dim=dim_init( TRIM(td_var%t_dim(1)%c_name), il_size(1) )
+            CALL var_move_dim( mpp__split_var, tl_dim )
+         ENDIF
+         IF( td_var%t_dim(2)%l_use )THEN
+            tl_dim=dim_init( TRIM(td_var%t_dim(2)%c_name), il_size(2) )
+            CALL var_move_dim( mpp__split_var, tl_dim )      
+         ENDIF
+
+         ! get processor indices
+         il_ind(:)=mpp_get_proc_index( td_mpp, id_procid )
+         il_i1 = il_ind(1)
+         il_i2 = il_ind(2)
+         il_j1 = il_ind(3)
+         il_j2 = il_ind(4)
+
+         IF( .NOT. td_var%t_dim(1)%l_use )THEN
+            il_i1=1 
+            il_i2=1 
+         ENDIF
+
+         IF( .NOT. td_var%t_dim(2)%l_use )THEN
+            il_j1=1 
+            il_j2=1 
+         ENDIF      
+
+         ! add variable value on processor
+         CALL var_add_value( mpp__split_var, &
+         &                   td_var%d_value(il_i1:il_i2, il_j1:il_j2, :, :) )
+      ENDIF
 
    END FUNCTION mpp__split_var
-   !> @endcode
+   !-------------------------------------------------------------------
+   !> @brief 
+   !>  This subroutine delete all variable in mpp strcuture.
+   !>
+   !> @author J.Paul
+   !> @date October, 2014 - Initial version
+   !>
+   !> @param[inout] td_mpp mpp strcuture
+   !-------------------------------------------------------------------
+   SUBROUTINE mpp__del_var_mpp( td_mpp )
+      IMPLICIT NONE
+      ! Argument
+      TYPE(TMPP), INTENT(INOUT) :: td_mpp
+
+      ! local variable
+      ! loop indices
+      INTEGER(i4) :: ji
+      !----------------------------------------------------------------
+
+      CALL logger_info( &
+      &  "MPP CLEAN VAR: reset all variable "//&
+      &  "in mpp strcuture "//TRIM(td_mpp%c_name) )
+
+      IF( ASSOCIATED(td_mpp%t_proc) )THEN
+         DO ji=td_mpp%t_proc(1)%i_nvar,1,-1
+            CALL mpp_del_var(td_mpp, td_mpp%t_proc(1)%t_var(ji))
+         ENDDO
+      ENDIF
+
+   END SUBROUTINE mpp__del_var_mpp
    !-------------------------------------------------------------------
    !> @brief
@@ -1490,15 +1778,10 @@
    !> structure.
    !>
-   !> @detail
-   !
-   !> @author J.Paul
-   !> @date Nov, 2013
-   !
-   !> @param[inout] td_mpp : mpp strcuture
-   !> @param[in]    td_var : variable strcuture
-   !
-   !> @todo 
-   !-------------------------------------------------------------------
-   !> @code
+   !> @author J.Paul
+   !> @date November, 2013 - Initial version
+   !
+   !> @param[inout] td_mpp mpp strcuture
+   !> @param[in]    td_var variable strcuture
+   !-------------------------------------------------------------------
    SUBROUTINE mpp__del_var_str( td_mpp, td_var )
       IMPLICIT NONE
@@ -1517,5 +1800,5 @@
       IF( .NOT. ASSOCIATED(td_mpp%t_proc) )THEN
 
-         CALL logger_error( " DEL VAR: domain decomposition not define "//&
+         CALL logger_error( "MPP DEL VAR: domain decomposition not define "//&
          &               " in mpp strcuture "//TRIM(td_mpp%c_name))
 
@@ -1525,14 +1808,14 @@
          il_varid = 0
          IF( ASSOCIATED(td_mpp%t_proc(1)%t_var) )THEN
-            il_varid=var_get_id( td_mpp%t_proc(1)%t_var(:), &
-            &                    td_var%c_name, td_var%c_stdname )
+            il_varid=var_get_index( td_mpp%t_proc(1)%t_var(:), &
+            &                       td_var%c_name, td_var%c_stdname )
          ENDIF
          IF( il_varid == 0 )THEN
             CALL logger_error( &
-            &  " DEL VAR: no variable "//TRIM(td_var%c_name)//&
+            &  "MPP DEL VAR: no variable "//TRIM(td_var%c_name)//&
             &  ", in mpp structure "//TRIM(td_mpp%c_name) )
 
             DO ji=1,td_mpp%t_proc(1)%i_nvar
-               CALL logger_debug( " DEL VAR: in mpp structure : &
+               CALL logger_debug( "MPP DEL VAR: in mpp structure : &
                &  variable : "//TRIM(td_mpp%t_proc(1)%t_var(ji)%c_name)//&
                &  ", standard name "//&
@@ -1551,20 +1834,14 @@
       ENDIF
    END SUBROUTINE mpp__del_var_str
-   !> @endcode
    !-------------------------------------------------------------------
    !> @brief
    !>    This subroutine delete variable in mpp structure, given variable name.
    !>
-   !> @detail
-   !
-   !> @author J.Paul
-   !> @date Nov, 2013
-   !
-   !> @param[inout] td_mpp : mpp strcuture
-   !> @param[in]    cd_name: variable name
-   !
-   !> @todo 
-   !-------------------------------------------------------------------
-   !> @code
+   !> @author J.Paul
+   !> @date November, 2013 - Initial version
+   !
+   !> @param[inout] td_mpp    mpp strcuture
+   !> @param[in]    cd_name   variable name
+   !-------------------------------------------------------------------
    SUBROUTINE mpp__del_var_name( td_mpp, cd_name )
       IMPLICIT NONE
@@ -1579,5 +1856,5 @@
       IF( .NOT. ASSOCIATED(td_mpp%t_proc) )THEN
 
-         CALL logger_error( " DEL VAR: domain decomposition not define "//&
+         CALL logger_error( "MPP DEL VAR: domain decomposition not define "//&
          &               " in mpp strcuture "//TRIM(td_mpp%c_name))
 
@@ -1585,5 +1862,5 @@
 
          IF( td_mpp%t_proc(1)%i_nvar == 0 )THEN
-            CALL logger_debug( " DEL VAR NAME: no variable associated to mpp &
+            CALL logger_debug( "MPP DEL VAR NAME: no variable associated to mpp &
             &                 structure "//TRIM(td_mpp%c_name) )
          ELSE
@@ -1592,11 +1869,12 @@
             il_varid=0
             IF( ASSOCIATED(td_mpp%t_proc(1)%t_var) )THEN
-               il_varid=var_get_id( td_mpp%t_proc(1)%t_var(:), &
-               &                    cd_name )
-            ENDIF
+               il_varid=var_get_index( td_mpp%t_proc(1)%t_var(:), &
+               &                       cd_name )
+            ENDIF
+
             IF( il_varid == 0 )THEN
 
                CALL logger_warn( &
-               &  "DEL VAR : there is no variable with name "//&
+               &  "MPP DEL VAR : there is no variable with name "//&
                &  "or standard name "//TRIM(ADJUSTL(cd_name))//&
                &  " in mpp structure "//TRIM(td_mpp%c_name))
@@ -1611,22 +1889,14 @@
       ENDIF
    END SUBROUTINE mpp__del_var_name
-   !> @endcode
    !-------------------------------------------------------------------
    !> @brief
    !>    This subroutine overwrite variable in mpp structure.
    !>
-   !> @detail
-   !
-   !> @author J.Paul
-   !> @date Nov, 2013
-   !
-   !> @param[inout] td_mpp : mpp strcuture
-   !> @param[in]    td_var : variable structure
-   !> @todo
-   !> - voir si il ne faut pas redefinir (__copy) variable si elle vient de mpp
-   !> exemple CALL  mpp_move_var( td_mpp, td_mpp%t_proc()%t_var )
-   !> remarque cas probabelement impossible puisque td_var doit avoir dim de td_mpp
-   !-------------------------------------------------------------------
-   !> @code
+   !> @author J.Paul
+   !> @date November, 2013 - Initial version
+   !
+   !> @param[inout] td_mpp mpp strcuture
+   !> @param[in]    td_var variable structure
+   !-------------------------------------------------------------------
    SUBROUTINE mpp_move_var( td_mpp, td_var )
       IMPLICIT NONE
@@ -1639,5 +1909,5 @@
       !----------------------------------------------------------------
       ! copy variable
-      tl_var=td_var
+      tl_var=var_copy(td_var)
 
       ! remove processor
@@ -1647,4 +1917,7 @@
       CALL mpp_add_var(td_mpp, tl_var)
 
+      ! clean 
+      CALL var_clean(tl_var)
+
    END SUBROUTINE mpp_move_var
    !> @endcode
@@ -1653,16 +1926,13 @@
    !>    This subroutine add processor to mpp structure.
    !>
-   !> @detail
-   !
-   !> @author J.Paul
-   !> @date Nov, 2013
-   !
-   !> @param[inout] td_mpp : mpp strcuture
-   !> @param[in]    td_proc : processor strcuture
+   !> @author J.Paul
+   !> @date November, 2013 - Initial version
+   !
+   !> @param[inout] td_mpp    mpp strcuture
+   !> @param[in]    td_proc   processor strcuture
    !
    !> @todo 
    !> - check proc type
    !-------------------------------------------------------------------
-   !> @code
    SUBROUTINE mpp__add_proc( td_mpp, td_proc )
       IMPLICIT NONE
@@ -1698,10 +1968,10 @@
 
             CALL logger_error( &
-            &  " ADD PROC: processor "//TRIM(fct_str(td_proc%i_pid))//&
+            &  "MPP ADD PROC: processor "//TRIM(fct_str(td_proc%i_pid))//&
             &  ", already in mpp structure " )
 
       ELSE
-         
-         CALL logger_trace("ADD PROC: add processor "//&
+ 
+         CALL logger_trace("MPP ADD PROC: add processor "//&
          &               TRIM(fct_str(td_mpp%i_nproc+1))//" in mpp structure")
 
@@ -1716,16 +1986,17 @@
             IF(il_status /= 0 )THEN
 
-               CALL logger_error( " ADD PROC: not enough space to put processor &
+               CALL logger_error( "MPP ADD PROC: not enough space to put processor &
                &               in mpp structure")
 
             ELSE
                ! save temporary mpp structure
-               tl_proc(:)=td_mpp%t_proc(:)
-
-               DEALLOCATE( td_mpp%t_proc )
+               tl_proc(:)=file_copy(td_mpp%t_proc(:))
+
+               CALL file_clean( td_mpp%t_proc(:) )
+               DEALLOCATE(td_mpp%t_proc)
                ALLOCATE( td_mpp%t_proc(td_mpp%i_nproc+1), stat=il_status)
                IF(il_status /= 0 )THEN
 
-                  CALL logger_error( " ADD PROC: not enough space to put "//&
+                  CALL logger_error( "MPP ADD PROC: not enough space to put "//&
                   &  "processor in mpp structure ")
 
@@ -1733,11 +2004,13 @@
 
                ! copy processor in mpp before
-               ! processor with lesser id than new processor
-               td_mpp%t_proc( 1:il_procid ) = tl_proc( 1:il_procid )
+               ! processor with lower id than new processor
+               td_mpp%t_proc( 1:il_procid ) = file_copy(tl_proc( 1:il_procid ))
 
                ! processor with greater id than new processor
                td_mpp%t_proc( il_procid+1 : td_mpp%i_nproc+1 ) = &
-               &                 tl_proc( il_procid : td_mpp%i_nproc )
-
+               &              file_copy(tl_proc( il_procid : td_mpp%i_nproc ))
+
+               ! clean
+               CALL file_clean(tl_proc(:))
                DEALLOCATE(tl_proc)
             ENDIF
@@ -1746,4 +2019,5 @@
             ! no processor in mpp structure
             IF( ASSOCIATED(td_mpp%t_proc) )THEN
+               CALL file_clean(td_mpp%t_proc(:))
                DEALLOCATE(td_mpp%t_proc)
             ENDIF
@@ -1751,5 +2025,5 @@
             IF(il_status /= 0 )THEN
 
-               CALL logger_error( " ADD PROC: not enough space to put "//&
+               CALL logger_error( "MPP ADD PROC: not enough space to put "//&
                &  "processor in mpp structure " )
 
@@ -1759,10 +2033,10 @@
          ! check dimension
          IF( ANY(td_mpp%t_dim(1:2)%i_len < td_proc%t_dim(1:2)%i_len) )THEN
-            CALL logger_error( "ADD PROC: mpp structure and new processor "//&
+            CALL logger_error( "MPP ADD PROC: mpp structure and new processor "//&
             &  " dimension differ. ")
-            CALL logger_debug("ADD PROC: mpp dimension ("//&
+            CALL logger_debug("MPP ADD PROC: mpp dimension ("//&
             &  TRIM(fct_str(td_mpp%t_dim(1)%i_len))//","//&
             &  TRIM(fct_str(td_mpp%t_dim(2)%i_len))//")" )
-            CALL logger_debug("ADD PROC: processor dimension ("//&
+            CALL logger_debug("MPP ADD PROC: processor dimension ("//&
             &  TRIM(fct_str(td_proc%t_dim(1)%i_len))//","//&
             &  TRIM(fct_str(td_proc%t_dim(2)%i_len))//")" )
@@ -1771,25 +2045,19 @@
 
             ! add new processor
-            td_mpp%t_proc(td_mpp%i_nproc)=td_proc
+            td_mpp%t_proc(td_mpp%i_nproc)=file_copy(td_proc)
          ENDIF
 
       ENDIF
    END SUBROUTINE mpp__add_proc
-   !> @endcode
    !-------------------------------------------------------------------
    !> @brief
    !>    This subroutine delete processor in mpp structure, given processor id.
    !>
-   !> @detail
-   !
-   !> @author J.Paul
-   !> @date Nov, 2013
-   !
-   !> @param[inout] td_mpp : mpp strcuture
-   !> @param[in]    id_procid : processor id
-   !
-   !> @todo check proc id exist
-   !-------------------------------------------------------------------
-   !> @code
+   !> @author J.Paul
+   !> @date November, 2013 - Initial version
+   !>
+   !> @param[inout] td_mpp    mpp strcuture
+   !> @param[in]    id_procid processor id
+   !-------------------------------------------------------------------
    SUBROUTINE mpp__del_proc_id( td_mpp, id_procid )
       IMPLICIT NONE
@@ -1803,4 +2071,6 @@
       INTEGER(i4), DIMENSION(1) :: il_ind
       TYPE(TFILE), DIMENSION(:), ALLOCATABLE :: tl_proc
+
+      ! loop indices
       !----------------------------------------------------------------
 
@@ -1808,14 +2078,16 @@
       il_procid=il_ind(1)
       IF( il_procid == 0 )THEN
-         CALL logger_error("DEL PROC: no processor "//TRIM(fct_str(id_procid))//&
-         &              " associated to mpp structure")
+         CALL logger_error("MPP DEL PROC: no processor "//&
+         &                 TRIM(fct_str(id_procid))//&
+         &                 " associated to mpp structure")
       ELSE
-         CALL logger_trace("DEL PROC: remove processor "//TRIM(fct_str(id_procid)))
+         CALL logger_trace("DEL PROC: remove processor "//&
+         &                 TRIM(fct_str(id_procid)))
 
          IF( td_mpp%i_nproc > 1 )THEN
             ALLOCATE( tl_proc(td_mpp%i_nproc-1), stat=il_status )
             IF(il_status /= 0 )THEN
-               CALL logger_error( " DEL PROC: not enough space to put processor &
-               &                 in temporary mpp structure")
+               CALL logger_error( "MPP DEL PROC: not enough space to put &
+               &  processor in temporary mpp structure")
 
             ELSE
@@ -1823,22 +2095,26 @@
                ! save temporary processor's mpp structure
                IF( il_procid > 1 )THEN
-                  tl_proc(1:il_procid-1)=td_mpp%t_proc(1:il_procid-1)
+                  tl_proc(1:il_procid-1)=file_copy(td_mpp%t_proc(1:il_procid-1))
                ENDIF
-               tl_proc(il_procid:)=td_mpp%t_proc(il_procid+1:)
+
+               IF( il_procid < td_mpp%i_nproc )THEN
+                  tl_proc(il_procid:)=file_copy(td_mpp%t_proc(il_procid+1:))
+               ENDIF
 
                ! new number of processor in mpp
                td_mpp%i_nproc=td_mpp%i_nproc-1
 
-               DEALLOCATE( td_mpp%t_proc )
+               CALL file_clean( td_mpp%t_proc(:) )
+               DEALLOCATE(td_mpp%t_proc)
                ALLOCATE( td_mpp%t_proc(td_mpp%i_nproc), stat=il_status )
                IF(il_status /= 0 )THEN
 
-                  CALL logger_error( " DEL PROC: not enough space to put processors &
-                  &               in mpp structure " )
+                  CALL logger_error( "MPP DEL PROC: not enough space &
+                  &  to put processors in mpp structure " )
 
                ELSE
 
                   ! copy processor in mpp before
-                  td_mpp%t_proc(:)=tl_proc(:)
+                  td_mpp%t_proc(:)=file_copy(tl_proc(:))
 
                   ! update processor id
@@ -1848,6 +2124,10 @@
                ENDIF
             ENDIF
+            ! clean
+            CALL file_clean( tl_proc(:) )
+            DEALLOCATE(tl_proc)
          ELSE
-            DEALLOCATE( td_mpp%t_proc )
+            CALL file_clean( td_mpp%t_proc(:) )
+            DEALLOCATE(td_mpp%t_proc)
 
             ! new number of processor in mpp
@@ -1856,5 +2136,4 @@
       ENDIF
    END SUBROUTINE mpp__del_proc_id
-   !> @endcode
    !-------------------------------------------------------------------
    !> @brief
@@ -1862,15 +2141,10 @@
    !>    structure.
    !>
-   !> @detail
-   !
-   !> @author J.Paul
-   !> @date Nov, 2013
+   !> @author J.Paul
+   !> @date November, 2013 - Initial version
    !
    !> @param[inout] td_mpp : mpp strcuture
    !> @param[in]    td_proc : file/processor structure
-   !
-   !> @todo check proc id exist
-   !-------------------------------------------------------------------
-   !> @code
+   !-------------------------------------------------------------------
    SUBROUTINE mpp__del_proc_str( td_mpp, td_proc )
       IMPLICIT NONE
@@ -1883,9 +2157,8 @@
          CALL mpp__del_proc( td_mpp, td_proc%i_pid )
       ELSE
-         CALL logger_error("DEL PROC: processor not defined")
+         CALL logger_error("MPP DEL PROC: processor not defined")
       ENDIF
 
    END SUBROUTINE mpp__del_proc_str
-   !> @endcode
    !-------------------------------------------------------------------
    !> @brief
@@ -1895,13 +2168,9 @@
    !
    !> @author J.Paul
-   !> @date Nov, 2013
-   !
-   !> @param[inout] td_mpp : mpp strcuture
-   !> @param[in]    id_procid : processor id
-   !> @todo
-   !> - voir si il ne faut pas redefinir (__copy) proc si il vient de mpp
-   !> exemple CALL  mpp_move_proc( td_mpp, td_mpp%t_proc )   
-   !-------------------------------------------------------------------
-   !> @code
+   !> @date Nov, 2013 - Initial version
+   !
+   !> @param[inout] td_mpp    mpp strcuture
+   !> @param[in]    id_procid processor id
+   !-------------------------------------------------------------------
    SUBROUTINE mpp__move_proc( td_mpp, td_proc )
       IMPLICIT NONE
@@ -1918,21 +2187,15 @@
 
    END SUBROUTINE mpp__move_proc
-   !> @endcode
    !-------------------------------------------------------------------
    !> @brief This subroutine add a dimension structure in a mpp 
    !> structure.
    !> Do not overwrite, if dimension already in mpp structure.
-   !
-   !> @details
-   !
-   !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[inout] td_mpp : mpp structure
-   !> @param[in] td_dim : dimension structure
-   !
-   !> @todo 
-   !-------------------------------------------------------------------
-   ! @code
+   !>
+   !> @author J.Paul
+   !> - November, 2013- Initial Version
+   !>
+   !> @param[inout] td_mpp mpp structure
+   !> @param[in] td_dim    dimension structure
+   !-------------------------------------------------------------------
    SUBROUTINE mpp_add_dim(td_mpp, td_dim)
       IMPLICIT NONE
@@ -1942,47 +2205,52 @@
 
       ! local variable
-      INTEGER(i4) :: il_dimid
+      INTEGER(i4) :: il_ind
 
       ! loop indices
-      !----------------------------------------------------------------
-      IF( td_mpp%i_ndim <= 4 )THEN
+      INTEGER(i4) :: ji
+      !----------------------------------------------------------------
+      IF( td_mpp%i_ndim <= ip_maxdim )THEN
 
          ! check if dimension already in mpp structure
-         il_dimid=dim_get_id(td_mpp%t_dim(:), td_dim%c_name, td_dim%c_sname)
-         IF( il_dimid /= 0 )THEN
-
-            CALL logger_error( &
-            &  " ADD DIM: dimension "//TRIM(td_dim%c_name)//&
-            &  ", short name "//TRIM(td_dim%c_sname)//&
-            &  ", already in mpp "//TRIM(td_mpp%c_name) )
+         il_ind=dim_get_index(td_mpp%t_dim(:), td_dim%c_name, td_dim%c_sname)
+         IF( il_ind /= 0 )THEN
+
+            IF( td_mpp%t_dim(il_ind)%l_use )THEN
+               CALL logger_error( &
+               &  "MPP ADD DIM: dimension "//TRIM(td_dim%c_name)//&
+               &  ", short name "//TRIM(td_dim%c_sname)//&
+               &  ", already used in mpp "//TRIM(td_mpp%c_name) )
+            ELSE
+               ! replace dimension
+               td_mpp%t_dim(il_ind)=dim_copy(td_dim)
+               td_mpp%t_dim(il_ind)%i_id=il_ind
+               td_mpp%t_dim(il_ind)%l_use=.TRUE.
+            ENDIF
 
          ELSE
 
-            CALL logger_debug( &
-            &  " ADD DIM: add dimension "//TRIM(td_dim%c_name)//&
-            &  ", short name "//TRIM(td_dim%c_sname)//&
-            &  ", in mpp "//TRIM(td_mpp%c_name) )
-
-            IF( td_mpp%i_ndim == 4 )THEN
+            IF( td_mpp%i_ndim == ip_maxdim )THEN
+               CALL logger_error( &
+               &  "MPP ADD DIM: can not add dimension "//TRIM(td_dim%c_name)//&
+               &  ", short name "//TRIM(td_dim%c_sname)//&
+               &  ", in mpp "//TRIM(td_mpp%c_name)//". Already "//&
+               &  TRIM(fct_str(ip_maxdim))//" dimensions." )
+            ELSE
                ! search empty dimension
-               il_dimid=dim_get_void_id(td_mpp%t_dim(:),TRIM(td_dim%c_name), &
-               &                                        TRIM(td_dim%c_sname))
-               ! replace empty dimension
-               td_mpp%t_dim(il_dimid)=td_dim
-               td_mpp%t_dim(il_dimid)%i_id=il_dimid
-               td_mpp%t_dim(il_dimid)%l_use=.TRUE.
-            ELSE
-               il_dimid=dim_get_void_id(td_mpp%t_dim(:),TRIM(td_dim%c_name), &
-               &                                        TRIM(td_dim%c_sname))
-               ! add new dimension
-               td_mpp%t_dim(il_dimid)=td_dim
-               td_mpp%t_dim(il_dimid)%i_id=td_mpp%i_ndim+1
-               td_mpp%t_dim(il_dimid)%l_use=.TRUE.
+               DO ji=1,ip_maxdim
+                  IF( td_mpp%t_dim(ji)%i_id == 0 )THEN
+                     il_ind=ji 
+                     EXIT
+                  ENDIF
+               ENDDO
+ 
+               ! add new dimension    
+               td_mpp%t_dim(il_ind)=dim_copy(td_dim)
                ! update number of attribute
                td_mpp%i_ndim=COUNT(td_mpp%t_dim(:)%l_use)
-            ENDIF
-
-            ! reorder dimension to ('x','y','z','t')
-            CALL dim_reorder(td_mpp%t_dim)
+
+               td_mpp%t_dim(il_ind)%l_use=.TRUE.
+               td_mpp%t_dim(il_ind)%i_id=td_mpp%i_ndim
+            ENDIF
 
          ENDIF
@@ -1990,25 +2258,19 @@
       ELSE
          CALL logger_error( &
-         &  " ADD DIM: too much dimension in mpp "//&
+         &  "MPP ADD DIM: too much dimension in mpp "//&
          &  TRIM(td_mpp%c_name)//" ("//TRIM(fct_str(td_mpp%i_ndim))//")")
       ENDIF
 
    END SUBROUTINE mpp_add_dim
-   ! @endcode
    !-------------------------------------------------------------------
    !> @brief This subroutine delete a dimension structure in a mpp 
    !> structure.<br/>
-   !
-   !> @details
-   !
-   !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[inout] td_mpp : mpp structure
-   !> @param[in] td_dim : dimension structure
-   !
-   !> @todo 
-   !-------------------------------------------------------------------
-   ! @code
+   !>
+   !> @author J.Paul
+   !> - November, 2013- Initial Version
+   !>
+   !> @param[inout] td_mpp mpp structure
+   !> @param[in] td_dim    dimension structure
+   !-------------------------------------------------------------------
    SUBROUTINE mpp_del_dim(td_mpp, td_dim)
       IMPLICIT NONE
@@ -2019,97 +2281,68 @@
       ! local variable
       INTEGER(i4) :: il_status
-      INTEGER(i4) :: il_dimid
+      INTEGER(i4) :: il_ind
       TYPE(TDIM), DIMENSION(:), ALLOCATABLE  :: tl_dim
 
       ! loop indices
-      !----------------------------------------------------------------
-      IF( td_mpp%i_ndim <= 4 )THEN
-
-         ! check if dimension already in mpp structure
-         il_dimid=dim_get_id(td_mpp%t_dim(:), td_dim%c_name, td_dim%c_sname)
-         IF( il_dimid == 0 )THEN
+      INTEGER(i4) :: ji
+      !----------------------------------------------------------------
+      ! check if dimension already in mpp structure
+      il_ind=dim_get_index(td_mpp%t_dim(:), td_dim%c_name, td_dim%c_sname)
+      IF( il_ind == 0 )THEN
+
+         CALL logger_error( &
+         &  "MPP DEL DIM: no dimension "//TRIM(td_dim%c_name)//&
+         &  ", short name "//TRIM(td_dim%c_sname)//&
+         &  ", in mpp "//TRIM(td_mpp%c_name) )
+
+      ELSE
+
+         ALLOCATE( tl_dim(td_mpp%i_ndim-1), stat=il_status )
+         IF(il_status /= 0 )THEN
 
             CALL logger_error( &
-            &  " DEL DIM: no dimension "//TRIM(td_dim%c_name)//&
-            &  ", short name "//TRIM(td_dim%c_sname)//&
-            &  ", in mpp "//TRIM(td_mpp%c_name) )
+            &  "MPP DEL DIM: not enough space to put dimensions from "//&
+            &  TRIM(td_mpp%c_name)//" in temporary dimension structure")
 
          ELSE
 
-            CALL logger_debug( &
-            &  " DEL DIM: delete dimension "//TRIM(td_dim%c_name)//&
-            &  ", short name "//TRIM(td_dim%c_sname)//&
-            &  ", in mpp "//TRIM(td_mpp%c_name) )
-
-            IF( td_mpp%i_ndim == 4 )THEN
-               ALLOCATE( tl_dim(1), stat=il_status )
-               IF(il_status /= 0 )THEN
-                  CALL logger_error( &
-                  &  " DEL DIM: not enough space to put dimensions from "//&
-                  &  TRIM(td_mpp%c_name)//" in temporary dimension structure")
-               ELSE
-                  ! replace dimension by empty one
-                  td_mpp%t_dim(il_dimid)=tl_dim(1)
-               ENDIF
-               DEALLOCATE(tl_dim)
-            ELSE
-               ! 
-               ALLOCATE( tl_dim(td_mpp%i_ndim), stat=il_status )
-               IF(il_status /= 0 )THEN
-
-                  CALL logger_error( &
-                  &  " DEL DIM: not enough space to put dimensions from "//&
-                  &  TRIM(td_mpp%c_name)//" in temporary dimension structure")
-
-               ELSE
-
-                  ! save temporary dimension's mpp structure
-                  tl_dim( 1 : il_dimid-1 ) = td_mpp%t_dim( 1 : il_dimid-1 )
-                  tl_dim( il_dimid : td_mpp%i_ndim-1 ) = &
-                  &           td_mpp%t_dim( il_dimid+1 : td_mpp%i_ndim )
-
-                  ! copy dimension in file, except one
-                  td_mpp%t_dim(1:td_mpp%i_ndim)=tl_dim(:)
-
-                  ! update number of dimension
-                  td_mpp%i_ndim=td_mpp%i_ndim-1
-
-               ENDIF
-            ENDIF
-
-            ! reorder dimension to ('x','y','z','t')
-            CALL dim_reorder(td_mpp%t_dim)
-
-            !IF( ASSOCIATED(td_mpp%t_proc) )THEN
-            !   ! del dimension of processor
-            !   DO ji=1,td_mpp%i_nproc
-            !      CALL file_del_dim(td_mpp%t_proc(ji), td_dim)
-            !   ENDDO
-            !ENDIF
+            ! save temporary dimension's mpp structure
+            tl_dim( 1 : il_ind-1 ) = dim_copy(td_mpp%t_dim( 1 : il_ind-1 ))
+            tl_dim( il_ind : td_mpp%i_ndim-1 ) = &
+            &           dim_copy(td_mpp%t_dim( il_ind+1 : td_mpp%i_ndim ))
+
+            ! remove dimension from file
+            CALL dim_clean(td_mpp%t_dim(:))
+            ! copy dimension in file, except one
+            td_mpp%t_dim(1:td_mpp%i_ndim)=dim_copy(tl_dim(:))
+
+            ! update number of dimension
+            td_mpp%i_ndim=td_mpp%i_ndim-1
+
+            ! update dimension id
+            DO ji=1,td_mpp%i_ndim
+               td_mpp%t_dim(ji)%i_id=ji
+            ENDDO
+
+            ! clean
+            CALL dim_clean(tl_dim(:))
+            DEALLOCATE(tl_dim)
 
          ENDIF
-      ELSE
-         CALL logger_error( &
-         &  " DEL DIM: too much dimension in mpp "//&
-         &  TRIM(td_mpp%c_name)//" ("//TRIM(fct_str(td_mpp%i_ndim))//")")
+
       ENDIF
 
    END SUBROUTINE mpp_del_dim
-   ! @endcode
    !-------------------------------------------------------------------
    !> @brief This subroutine move a dimension structure 
    !> in mpp structure.
    !> @warning dimension order may have changed
-   !
-   !> @details
-   !
-   !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[inout] td_mpp : mpp structure
-   !> @param[in] td_dim : dimension structure
-   !> @todo
-   !-------------------------------------------------------------------
-   ! @code
+   !>
+   !> @author J.Paul
+   !> - November, 2013- Initial Version
+   !>
+   !> @param[inout] td_mpp mpp structure
+   !> @param[in] td_dim    dimension structure
+   !-------------------------------------------------------------------
    SUBROUTINE mpp_move_dim(td_mpp, td_dim)
       IMPLICIT NONE
@@ -2119,35 +2352,39 @@
 
       ! local variable
+      INTEGER(i4) :: il_ind
       INTEGER(i4) :: il_dimid
-
-      !----------------------------------------------------------------
-
-      il_dimid=dim_get_id(td_mpp%t_dim(:), TRIM(td_dim%c_name), &
-      &                                    TRIM(td_dim%c_sname))
-      IF( il_dimid /= 0 )THEN
-         ! remove dimension with same name
-         CALL mpp_del_dim(td_mpp, td_dim)
-      ENDIF
-
-      ! add new dimension
-      CALL mpp_add_dim(td_mpp, td_dim)
-
+      !----------------------------------------------------------------
+      IF( td_mpp%i_ndim <= ip_maxdim )THEN
+
+         ! check if dimension already in mpp structure
+         il_ind=dim_get_index(td_mpp%t_dim(:), td_dim%c_name, td_dim%c_sname)
+         IF( il_ind /= 0 )THEN
+
+            il_dimid=td_mpp%t_dim(il_ind)%i_id
+            ! replace dimension
+            td_mpp%t_dim(il_ind)=dim_copy(td_dim)
+            td_mpp%t_dim(il_ind)%i_id=il_dimid
+            td_mpp%t_dim(il_ind)%l_use=.TRUE.
+
+         ELSE
+            CALL mpp_add_dim(td_mpp, td_dim)
+         ENDIF
+
+      ELSE
+         CALL logger_error( &
+         &  "MPP MOVE DIM: too much dimension in mpp "//&
+         &  TRIM(td_mpp%c_name)//" ("//TRIM(fct_str(td_mpp%i_ndim))//")")
+      ENDIF
    END SUBROUTINE mpp_move_dim
-   ! @endcode
    !-------------------------------------------------------------------
    !> @brief
    !>    This subroutine add global attribute to mpp structure.
    !>
-   !> @detail
-   !
-   !> @author J.Paul
-   !> @date Nov, 2013
-   !
-   !> @param[inout] td_mpp : mpp strcuture
-   !> @param[in]    td_att : attribute strcuture
-   !
-   !> @todo 
-   !-------------------------------------------------------------------
-   !> @code
+   !> @author J.Paul
+   !> @date November, 2013 - Initial version
+   !>
+   !> @param[inout] td_mpp mpp strcuture
+   !> @param[in]    td_att attribute strcuture
+   !-------------------------------------------------------------------
    SUBROUTINE mpp_add_att( td_mpp, td_att )
       IMPLICIT NONE
@@ -2176,11 +2413,12 @@
             il_attid=0
             IF( ASSOCIATED(td_mpp%t_proc(1)%t_att) )THEN
-               il_attid=att_get_id( td_mpp%t_proc(1)%t_att(:), &
+               il_attid=att_get_index( td_mpp%t_proc(1)%t_att(:), &
                &                    td_att%c_name )
             ENDIF
             IF( il_attid /= 0 )THEN
 
-               CALL logger_error( " MPP ADD ATT: attribute "//TRIM(td_att%c_name)//&
-               &  ", already in mpp "//TRIM(td_mpp%c_name) )
+               CALL logger_error( " MPP ADD ATT: attribute "//&
+               &                 TRIM(td_att%c_name)//&
+               &                 ", already in mpp "//TRIM(td_mpp%c_name) )
 
                DO ji=1,td_mpp%t_proc(1)%i_natt
@@ -2192,5 +2430,5 @@
             
                CALL logger_info( &
-               &  " MPP ADD VAR: add attribute "//TRIM(td_att%c_name)//&
+               &  " MPP ADD ATT: add attribute "//TRIM(td_att%c_name)//&
                &  ", in mpp "//TRIM(td_mpp%c_name) )
 
@@ -2207,5 +2445,4 @@
 
    END SUBROUTINE mpp_add_att
-   !> @endcode
    !-------------------------------------------------------------------
    !> @brief
@@ -2213,19 +2450,10 @@
    !> structure.
    !>
-   !> @detail
-   !
-   !> @author J.Paul
-   !> @date Nov, 2013
-   !
-   !> @param[inout] td_mpp : mpp strcuture
-   !> @param[in]    td_att : attribute strcuture
-   !
-   !> @todo 
-   !> - check proc id exist
-   !> - check proc dimension
-   !> - check proc file name
-   !> - check proc type
-   !-------------------------------------------------------------------
-   !> @code
+   !> @author J.Paul
+   !> @date November, 2013 - Initial version
+   !>
+   !> @param[inout] td_mpp mpp strcuture
+   !> @param[in]    td_att attribute strcuture
+   !-------------------------------------------------------------------
    SUBROUTINE mpp__del_att_str( td_mpp, td_att )
       IMPLICIT NONE
@@ -2244,5 +2472,5 @@
       IF( .NOT. ASSOCIATED(td_mpp%t_proc) )THEN
 
-         CALL logger_error( " DEL VAR: domain decomposition not define "//&
+         CALL logger_warn( "MPP DEL VAR: domain decomposition not define "//&
          &               " in mpp strcuture "//TRIM(td_mpp%c_name))
 
@@ -2252,20 +2480,24 @@
          il_attid=0
          IF( ASSOCIATED(td_mpp%t_proc(1)%t_att) )THEN
-            il_attid=att_get_id( td_mpp%t_proc(1)%t_att(:), &
+            il_attid=att_get_index( td_mpp%t_proc(1)%t_att(:), &
             &                    td_att%c_name )
          ENDIF
          IF( il_attid == 0 )THEN
-            CALL logger_error( &
-            &  " DEL VAR: no attribute "//TRIM(td_att%c_name)//&
+            CALL logger_warn( &
+            &  "MPP DEL VAR: no attribute "//TRIM(td_att%c_name)//&
             &  ", in mpp structure "//TRIM(td_mpp%c_name) )
 
-            DO ji=1,td_mpp%t_proc(1)%i_natt
-               CALL logger_debug( " DEL ATT: in mpp structure : &
-               &  attribute : "//TRIM(td_mpp%t_proc(1)%t_var(ji)%c_name) )
-            ENDDO
+            IF( ASSOCIATED(td_mpp%t_proc(1)%t_var) )THEN
+               DO ji=1,td_mpp%t_proc(1)%i_natt
+                  CALL logger_debug( "MPP DEL ATT: in mpp structure : &
+                  &  attribute : "//TRIM(td_mpp%t_proc(1)%t_var(ji)%c_name) )
+               ENDDO
+            ENDIF
 
          ELSE
 
             cl_name=TRIM(td_att%c_name)
+            CALL logger_debug( "MPP DEL ATT: delete in mpp structure : &
+            &  attribute : "//TRIM(cl_name) )
             DO ji=1,td_mpp%i_nproc
                CALL file_del_att(td_mpp%t_proc(ji), TRIM(cl_name)) 
@@ -2276,5 +2508,4 @@
       ENDIF
    END SUBROUTINE mpp__del_att_str
-   !> @endcode
    !-------------------------------------------------------------------
    !> @brief
@@ -2284,16 +2515,9 @@
    !
    !> @author J.Paul
-   !> @date Nov, 2013
-   !
-   !> @param[inout] td_mpp : mpp strcuture
-   !> @param[in]    cd_name: attribute name
-   !
-   !> @todo 
-   !> - check proc id exist
-   !> - check proc dimension
-   !> - check proc file name
-   !> - check proc type
-   !-------------------------------------------------------------------
-   !> @code
+   !> @date November, 2013 - Initial version
+   !
+   !> @param[inout] td_mpp    mpp strcuture
+   !> @param[in]    cd_name   attribute name
+   !-------------------------------------------------------------------
    SUBROUTINE mpp__del_att_name( td_mpp, cd_name )
       IMPLICIT NONE
@@ -2308,5 +2532,5 @@
       IF( .NOT. ASSOCIATED(td_mpp%t_proc) )THEN
 
-         CALL logger_error( " DEL ATT: domain decomposition not define "//&
+         CALL logger_warn( "MPP DEL ATT: domain decomposition not define "//&
          &               " in mpp strcuture "//TRIM(td_mpp%c_name))
 
@@ -2314,5 +2538,5 @@
 
          IF( td_mpp%t_proc(1)%i_natt == 0 )THEN
-            CALL logger_debug( " DEL ATT NAME: no attribute associated to mpp &
+            CALL logger_debug( "MPP DEL ATT NAME: no attribute associated to mpp &
             &                 structure "//TRIM(td_mpp%c_name) )
          ELSE
@@ -2328,5 +2552,5 @@
 
                CALL logger_warn( &
-               &  " DEL ATT : there is no attribute with "//&
+               &  "MPP DEL ATT : there is no attribute with "//&
                &  "name "//TRIM(cd_name)//" in mpp structure "//&
                &  TRIM(td_mpp%c_name))
@@ -2341,19 +2565,14 @@
       ENDIF
    END SUBROUTINE mpp__del_att_name
-   !> @endcode
    !-------------------------------------------------------------------
    !> @brief
    !>    This subroutine overwrite attribute in mpp structure.
    !>
-   !> @detail
-   !
-   !> @author J.Paul
-   !> @date Nov, 2013
-   !
-   !> @param[inout] td_mpp : mpp strcuture
-   !> @param[in]    td_att : attribute structure
-   !> @todo
-   !-------------------------------------------------------------------
-   !> @code
+   !> @author J.Paul
+   !> @date November, 2013 - Initial version
+   !
+   !> @param[inout] td_mpp mpp strcuture
+   !> @param[in]    td_att attribute structure
+   !-------------------------------------------------------------------
    SUBROUTINE mpp_move_att( td_mpp, td_att )
       IMPLICIT NONE
@@ -2363,8 +2582,8 @@
 
       !local variable
-      TYPE(TATT) :: tl_att
+      TYPE(TATT)  :: tl_att
       !----------------------------------------------------------------
       ! copy variable
-      tl_att=td_att
+      tl_att=att_copy(td_att)
 
       ! remove processor
@@ -2374,6 +2593,8 @@
       CALL mpp_add_att(td_mpp, tl_att)
 
+      ! clean
+      CALL att_clean(tl_att)
+
    END SUBROUTINE mpp_move_att
-   !> @endcode
    !-------------------------------------------------------------------
    !> @brief
@@ -2388,9 +2609,8 @@
    !
    !> @author J.Paul
-   !> @date Nov, 2013
-   !
-   !> @param[inout] td_mpp : mpp strcuture
-   !-------------------------------------------------------------------
-   !> @code
+   !> @date November, 2013 - Initial version
+   !
+   !> @param[inout] td_mpp mpp strcuture
+   !-------------------------------------------------------------------
    SUBROUTINE mpp__compute( td_mpp )
       IMPLICIT NONE
@@ -2410,5 +2630,5 @@
       CHARACTER(LEN=lc)                        :: cl_file
       TYPE(TFILE)                              :: tl_proc
-      TYPE(TATT)                               ::tl_att
+      TYPE(TATT)                               :: tl_att
 
       ! loop indices
@@ -2421,5 +2641,5 @@
       td_mpp%i_nproc=0
 
-      CALL logger_trace( "COMPUTE: compute domain decomposition with "//&
+      CALL logger_trace( "MPP COMPUTE: compute domain decomposition with "//&
       &               TRIM(fct_str(td_mpp%i_niproc))//" x "//&
       &               TRIM(fct_str(td_mpp%i_njproc))//" processors")
@@ -2498,5 +2718,4 @@
             &                (/tl_proc%i_lci, tl_proc%i_lcj/) )
             CALL file_add_att(tl_proc, tl_att)
-
 
             ! compute first and last indoor indices
@@ -2544,4 +2763,8 @@
             CALL mpp__add_proc(td_mpp, tl_proc)
 
+            ! clean
+            CALL att_clean(tl_att)
+            CALL file_clean(tl_proc)
+
          ENDDO
       ENDDO
@@ -2551,16 +2774,14 @@
 
    END SUBROUTINE mpp__compute
-   !> @endcode
    !-------------------------------------------------------------------
    !> @brief 
    !>  This subroutine remove land processor from domain decomposition.
-   !
-   !> @author J.Paul
-   !> @date Nov, 2013
-   !
-   !> @param[inout] td_mpp : mpp strcuture
-   !> @param[in] id_mask : sub domain mask (sea=1, land=0)
-   !-------------------------------------------------------------------
-   !> @code
+   !>
+   !> @author J.Paul
+   !> @date November, 2013 - Initial version
+   !>
+   !> @param[inout] td_mpp mpp strcuture
+   !> @param[in] id_mask   sub domain mask (sea=1, land=0)
+   !-------------------------------------------------------------------
    SUBROUTINE mpp__del_land( td_mpp, id_mask )
       IMPLICIT NONE
@@ -2583,9 +2804,8 @@
          ENDDO
       ELSE
-         CALL logger_error("DEL LAND: domain decomposition not define.")
+         CALL logger_error("MPP DEL LAND: domain decomposition not define.")
       ENDIF
 
    END SUBROUTINE mpp__del_land
-   !> @endcode
    !-------------------------------------------------------------------
    !> @brief 
@@ -2596,9 +2816,9 @@
    !
    !> @author J.Paul
-   !> @date Nov, 2013
-   !
-   !> @param[inout] td_mpp : mpp strcuture
-   !-------------------------------------------------------------------
-   !> @code
+   !> @date November, 2013 - Initial version
+   !
+   !> @param[inout] td_mpp mpp strcuture
+   !> @param[in] id_mask   sub domain mask (sea=1, land=0) 
+   !-------------------------------------------------------------------
    SUBROUTINE mpp__optimiz( td_mpp, id_mask )
       IMPLICIT NONE
@@ -2617,6 +2837,6 @@
       !----------------------------------------------------------------
 
-      CALL logger_trace("OPTIMIZ: look for best domain decomposition")
-      tl_mpp=td_mpp
+      CALL logger_trace("MPP OPTIMIZ: look for best domain decomposition")
+      tl_mpp=mpp_copy(td_mpp)
 
       ! save maximum number of processor to be used
@@ -2629,4 +2849,5 @@
             ! clean mpp processor
             IF( ASSOCIATED(tl_mpp%t_proc) )THEN
+               CALL file_clean(tl_mpp%t_proc(:))
                DEALLOCATE(tl_mpp%t_proc)
             ENDIF
@@ -2641,5 +2862,5 @@
             CALL mpp__del_land( tl_mpp, id_mask )
 
-            CALL logger_info("OPTIMIZ: number of processor "//&
+            CALL logger_info("MPP OPTIMIZ: number of processor "//&
             &  TRIM(fct_str(tl_mpp%i_nproc)) )
             IF( tl_mpp%i_nproc > td_mpp%i_nproc .AND. &
@@ -2650,18 +2871,22 @@
                CALL mpp_clean(td_mpp)
 
-               ! save processor table
+               ! save processor array
                ALLOCATE( tl_proc(tl_mpp%i_nproc) )
-               tl_proc(:)=tl_mpp%t_proc(:)
-
-               ! remove pointer on processor table
+               tl_proc(:)=file_copy(tl_mpp%t_proc(:))
+
+               ! remove pointer on processor array
+               CALL file_clean(tl_mpp%t_proc(:))
                DEALLOCATE(tl_mpp%t_proc)
  
-               ! save data except processor table
-               td_mpp=tl_mpp
-               ! save processor table
+               ! save data except processor array
+               td_mpp=mpp_copy(tl_mpp)
+
+               ! save processor array
                ALLOCATE( td_mpp%t_proc(td_mpp%i_nproc) )
-               td_mpp%t_proc(:)=tl_proc(:)
-
-               DEALLOCATE( tl_proc )
+               td_mpp%t_proc(:)=file_copy(tl_proc(:))
+
+               ! clean
+               CALL file_clean( tl_proc(:) )
+               DEALLOCATE(tl_proc)
 
             ENDIF
@@ -2670,18 +2895,19 @@
       ENDDO
 
+      ! clean
+      CALL mpp_clean(tl_mpp)
+
    END SUBROUTINE mpp__optimiz
-   !> @endcode
    !-------------------------------------------------------------------
    !> @brief
    !>    This function check if processor is a land processor.
-   !
-   !> @author J.Paul
-   !> @date Nov, 2013
-   !
-   !> @param[in] td_mpp : mpp strcuture
-   !> @param[in] id_proc : processor id
-   !> @param[in] id_mask : sub domain mask (sea=1, land=0)
-   !-------------------------------------------------------------------
-   !> @code
+   !>
+   !> @author J.Paul
+   !> @date November, 2013 - Initial version
+   !>
+   !> @param[in] td_mpp    mpp strcuture
+   !> @param[in] id_proc   processor id
+   !> @param[in] id_mask   sub domain mask (sea=1, land=0)
+   !-------------------------------------------------------------------
    LOGICAL FUNCTION mpp__land_proc( td_mpp , id_proc, id_mask )
       IMPLICIT NONE
@@ -2695,5 +2921,5 @@
       !----------------------------------------------------------------
 
-      CALL logger_trace("LAND PROC: check processor "//TRIM(fct_str(id_proc))//&
+      CALL logger_trace("MPP LAND PROC: check processor "//TRIM(fct_str(id_proc))//&
       &  " of mpp "//TRIM(td_mpp%c_name) )
       mpp__land_proc=.FALSE.
@@ -2703,5 +2929,11 @@
          IF( il_shape(1) /= td_mpp%t_dim(1)%i_len .OR. &
          &   il_shape(2) /= td_mpp%t_dim(2)%i_len )THEN
-             CALL logger_error("LAND PROC: mask and domain size differ")
+             CALL logger_debug("MPP LAND PROC: mask size ("//&
+             &                  TRIM(fct_str(il_shape(1)))//","//&
+             &                  TRIM(fct_str(il_shape(2)))//")")
+             CALL logger_debug("MPP LAND PROC: domain size ("//&
+             &                  TRIM(fct_str(td_mpp%t_dim(1)%i_len))//","//&
+             &                  TRIM(fct_str(td_mpp%t_dim(2)%i_len))//")")
+             CALL logger_error("MPP LAND PROC: mask and domain size differ")
          ELSE
             IF( ALL(id_mask( td_mpp%t_proc(id_proc)%i_impp +            &
@@ -2715,5 +2947,5 @@
             &      /= 1 ) )THEN
                ! land domain
-               CALL logger_info(" LAND PROC: processor "//TRIM(fct_str(id_proc))//&
+               CALL logger_info("MPP LAND PROC: processor "//TRIM(fct_str(id_proc))//&
                &             " is land processor")
                mpp__land_proc=.TRUE.
@@ -2722,20 +2954,18 @@
 
       ELSE
-         CALL logger_error("LAND PROC: domain decomposition not define.")
+         CALL logger_error("MPP LAND PROC: domain decomposition not define.")
       ENDIF
 
    END FUNCTION mpp__land_proc
-   !> @endcode
    !-------------------------------------------------------------------
    !> @brief 
    !>  This subroutine clean mpp strcuture.
-   !
-   !> @author J.Paul
-   !> @date Nov, 2013
-   !
-   !> @param[inout] td_mpp : mpp strcuture
-   !-------------------------------------------------------------------
-   !> @code
-   SUBROUTINE mpp_clean( td_mpp )
+   !>
+   !> @author J.Paul
+   !> @date November, 2013 - Initial version
+   !>
+   !> @param[inout] td_mpp mpp strcuture
+   !-------------------------------------------------------------------
+   SUBROUTINE mpp__clean_unit( td_mpp )
       IMPLICIT NONE
       ! Argument
@@ -2746,52 +2976,80 @@
 
       ! loop indices
-      INTEGER(i4) :: ji
       !----------------------------------------------------------------
 
       CALL logger_info( &
-      &  " CLEAN: reset mpp "//TRIM(td_mpp%c_name) )
+      &  "MPP CLEAN: reset mpp "//TRIM(td_mpp%c_name) )
 
       ! del dimension
       IF( td_mpp%i_ndim /= 0 )THEN
-         DO ji=td_mpp%i_ndim,1,-1
-            CALL dim_clean( td_mpp%t_dim(ji) )
-         ENDDO
+         CALL dim_clean( td_mpp%t_dim(:) )
       ENDIF
 
       IF( ASSOCIATED(td_mpp%t_proc) )THEN
-         ! clean each proc
-         DO ji=1,td_mpp%i_nproc
-            CALL file_clean( td_mpp%t_proc(ji) )
-         ENDDO
+         ! clean array of file processor
+         CALL file_clean( td_mpp%t_proc(:) )
          DEALLOCATE(td_mpp%t_proc)
       ENDIF
 
       ! replace by empty structure
-      td_mpp=tl_mpp
-
-   END SUBROUTINE mpp_clean
-   !> @endcode
+      td_mpp=mpp_copy(tl_mpp)
+
+   END SUBROUTINE mpp__clean_unit
+   !-------------------------------------------------------------------
+   !> @brief 
+   !>  This subroutine clean mpp strcuture.
+   !>
+   !> @author J.Paul
+   !> @date November, 2013 - Initial version
+   !>
+   !> @param[inout] td_mpp mpp strcuture
+   !-------------------------------------------------------------------
+   SUBROUTINE mpp__clean_arr( td_mpp )
+      IMPLICIT NONE
+      ! Argument
+      TYPE(TMPP),  DIMENSION(:), INTENT(INOUT) :: td_mpp
+
+      ! local variable
+      ! loop indices
+      INTEGER(i4) :: ji
+      !----------------------------------------------------------------
+
+      DO ji=SIZE(td_mpp(:)),1,-1
+         CALL mpp_clean(td_mpp(ji))
+      ENDDO
+
+   END SUBROUTINE mpp__clean_arr
    !-------------------------------------------------------------------
    !> @brief 
    !>  This subroutine get sub domains which cover "zoom domain".
-   !
-   !> @author J.Paul
-   !> @date Nov, 2013
-   !
-   !> @param[inout] td_mpp : mpp strcuture
-   !> @param[in] td_dom : domain strcuture
-   !-------------------------------------------------------------------
-   !> @code
-   SUBROUTINE mpp_get_use( td_mpp, td_dom )
+   !>
+   !> @author J.Paul
+   !> @date November, 2013 - Initial version
+   !>
+   !> @param[inout] td_mpp mpp strcuture
+   !> @param[in] id_imin   i-direction lower indice
+   !> @param[in] id_imax   i-direction upper indice
+   !> @param[in] id_jmin   j-direction lower indice
+   !> @param[in] id_jmax   j-direction upper indice
+   !-------------------------------------------------------------------
+   SUBROUTINE mpp__get_use_unit( td_mpp, id_imin, id_imax, &
+   &                                     id_jmin, id_jmax )
       IMPLICIT NONE
       ! Argument
-      TYPE(TMPP),  INTENT(INOUT) :: td_mpp
-      TYPE(TDOM),  INTENT(IN)    :: td_dom
+      TYPE(TMPP) ,  INTENT(INOUT) :: td_mpp
+      INTEGER(i4),  INTENT(IN), OPTIONAL :: id_imin
+      INTEGER(i4),  INTENT(IN), OPTIONAL :: id_imax
+      INTEGER(i4),  INTENT(IN), OPTIONAL :: id_jmin
+      INTEGER(i4),  INTENT(IN), OPTIONAL :: id_jmax
 
       ! local variable
-      INTEGER(i4) :: il_jmin
       LOGICAL     :: ll_iuse
       LOGICAL     :: ll_juse
 
+      INTEGER(i4) :: il_imin
+      INTEGER(i4) :: il_imax
+      INTEGER(i4) :: il_jmin
+      INTEGER(i4) :: il_jmax
+
       ! loop indices
       INTEGER(i4) :: jk
@@ -2799,8 +3057,27 @@
       IF( ASSOCIATED(td_mpp%t_proc) )THEN
    
+         il_imin=1
+         il_imax=td_mpp%t_dim(1)%i_len
+         IF( PRESENT(id_imin) ) il_imin=id_imin
+         IF( PRESENT(id_imax) ) il_imax=id_imax
+         il_jmin=1
+         il_jmax=td_mpp%t_dim(2)%i_len
+         IF( PRESENT(id_jmin) ) il_jmin=id_jmin
+         IF( PRESENT(id_jmax) ) il_jmax=id_jmax
+
          ! check domain
-         IF( td_mpp%t_dim(1)%i_len == td_dom%t_dim0(1)%i_len .AND. &
-         &   td_mpp%t_dim(2)%i_len == td_dom%t_dim0(2)%i_len )THEN
-
+         IF( il_imin < 1 .OR. il_imin > td_mpp%t_dim(1)%i_len .OR. &
+         &   il_imax < 1 .OR. il_imax > td_mpp%t_dim(1)%i_len .OR. &
+         &   il_jmin < 1 .OR. il_jmin > td_mpp%t_dim(2)%i_len .OR. &
+         &   il_jmax < 1 .OR. il_jmax > td_mpp%t_dim(2)%i_len )THEN
+            CALL logger_debug("MPP GET USE: mpp gloabl size "//&
+            &        TRIM(fct_str(td_mpp%t_dim(1)%i_len))//","//&
+            &        TRIM(fct_str(td_mpp%t_dim(2)%i_len)))
+            CALL logger_debug("MPP GET USE: i-indices "//&
+            &        TRIM(fct_str(il_imin))//","//TRIM(fct_str(il_imax)))
+            CALL logger_debug("MPP GET USE: j-indices "//&
+            &        TRIM(fct_str(il_jmin))//","//TRIM(fct_str(il_jmax)))
+            CALL logger_error("MPP GET USE: invalid indices ")
+         ELSE
             td_mpp%t_proc(:)%l_use=.FALSE.
             DO jk=1,td_mpp%i_nproc
@@ -2808,28 +3085,25 @@
                ! check i-direction
                ll_iuse=.FALSE.
-               IF( td_dom%i_imin < td_dom%i_imax )THEN
+               IF( il_imin < il_imax )THEN
 
                   ! not overlap east west boundary
                   IF( td_mpp%t_proc(jk)%i_impp + td_mpp%t_proc(jk)%i_lci > &
-                  &   td_dom%i_imin .AND.                                  &
-                  &   td_mpp%t_proc(jk)%i_impp < td_dom%i_imax )THEN
+                  &   il_imin .AND.                                  &
+                  &   td_mpp%t_proc(jk)%i_impp < il_imax )THEN
                       ll_iuse=.TRUE.
                   ENDIF
 
-               ELSEIF( td_dom%i_imin == td_dom%i_imax )THEN
+               ELSEIF( il_imin == il_imax )THEN
 
                   ! east west cyclic
                   ll_iuse=.TRUE.
 
-               ELSE ! td_dom%i_imin > td_dom%i_imax
+               ELSE ! il_imin > id_imax
 
                   ! overlap east west boundary
                   IF( ( td_mpp%t_proc(jk)%i_impp + td_mpp%t_proc(jk)%i_lci >  &
-                  &     td_dom%i_imin .AND.                                   &
-                  &     td_mpp%t_proc(jk)%i_impp < td_dom%t_dim0(1)%i_len )    &
+                  &     il_imin )                                             &
                   &   .OR.                                                    &
-                  &   ( td_mpp%t_proc(jk)%i_impp + td_mpp%t_proc(jk)%i_lci >  &
-                  &     1 .AND.                                               &
-                  &     td_mpp%t_proc(jk)%i_impp < td_dom%i_imax) )THEN
+                  &   ( td_mpp%t_proc(jk)%i_impp < il_imax) )THEN
                      ll_iuse=.TRUE.
                   ENDIF
@@ -2839,16 +3113,15 @@
                ! check j-direction
                ll_juse=.FALSE.
-               IF( td_dom%i_jmin < td_dom%i_jmax )THEN
+               IF( il_jmin < il_jmax )THEN
 
                   ! not overlap north fold
                   IF( td_mpp%t_proc(jk)%i_jmpp + td_mpp%t_proc(jk)%i_lcj > &
-                  &   td_dom%i_jmin .AND.                                  &
-                  &   td_mpp%t_proc(jk)%i_jmpp < td_dom%i_jmax )THEN
+                  &   il_jmin .AND.                                  &
+                  &   td_mpp%t_proc(jk)%i_jmpp < il_jmax )THEN
                      ll_juse=.TRUE.
                   ENDIF
 
-               ELSE ! td_dom%i_jmin >= td_dom%i_jmax
-
-                  il_jmin=MIN(td_dom%i_jmin,td_dom%i_jmax)
+               ELSE ! id_jmin >= id_jmax
+
                   IF( td_mpp%t_proc(jk)%i_jmpp + td_mpp%t_proc(jk)%i_lcj > &
                   &  il_jmin )THEN
@@ -2861,24 +3134,20 @@
 
             ENDDO
-         ELSE
-            CALL logger_error("GET USE: domain differ")
          ENDIF
 
       ELSE
-         CALL logger_error("GET USE: domain decomposition not define.")
-      ENDIF
-
-   END SUBROUTINE mpp_get_use
-   !> @endcode
+         CALL logger_error("MPP GET USE: mpp decomposition not define.")
+      ENDIF
+
+   END SUBROUTINE mpp__get_use_unit
    !-------------------------------------------------------------------
    !> @brief 
    !>  This subroutine get sub domains which form global domain border.
-   !
-   !> @author J.Paul
-   !> @date Nov, 2013
-   !
-   !> @param[inout] td_mpp : mpp strcuture
-   !-------------------------------------------------------------------
-   !> @code
+   !>
+   !> @author J.Paul
+   !> @date November, 2013
+   !>
+   !> @param[inout] td_mpp mpp strcuture
+   !-------------------------------------------------------------------
    SUBROUTINE mpp_get_contour( td_mpp )
       IMPLICIT NONE
@@ -2892,5 +3161,5 @@
       IF( ASSOCIATED(td_mpp%t_proc) )THEN
 
-         td_mpp%t_proc(:)%l_ctr = .FALSE.
+         td_mpp%t_proc(:)%l_use = .FALSE.
          DO jk=1,td_mpp%i_nproc
             IF( td_mpp%t_proc(jk)%i_ldi == 1 .OR. &
@@ -2899,33 +3168,31 @@
             &   td_mpp%t_proc(jk)%i_lej == td_mpp%t_proc(jk)%i_lcj )THEN
 
-               td_mpp%t_proc(jk)%l_ctr = .TRUE.
-            
+               td_mpp%t_proc(jk)%l_use = .TRUE.
+ 
             ENDIF
          ENDDO
    
       ELSE
-         CALL logger_error("GET CONTOUR: domain decomposition not define.")
+         CALL logger_error("MPP GET CONTOUR: domain decomposition not define.")
       ENDIF
 
    END SUBROUTINE mpp_get_contour
-   !> @endcode
    !-------------------------------------------------------------------
    !> @brief
    !> This function return processor indices, without overlap boundary,
-   !> given processor id. This depends of domain decompisition type. 
-   !
-   !> @author J.Paul
-   !> @date Nov, 2013
-   !
-   !> @param[in] td_mpp : mpp strcuture
-   !> @param[in] id_procid : processor id
-   !> @return table of index (/ i1, i2, j1, j2 /)
-   !-------------------------------------------------------------------
-   !> @code
+   !> given processor id. 
+   !>
+   !> @author J.Paul
+   !> @date November, 2013
+   !>
+   !> @param[in] td_mpp    mpp strcuture
+   !> @param[in] id_procid processor id
+   !> @return array of index (/ i1, i2, j1, j2 /)
+   !-------------------------------------------------------------------
    FUNCTION mpp_get_proc_index( td_mpp, id_procid )
       IMPLICIT NONE
 
       ! Argument
-      TYPE(TMPP),  INTENT(IN) :: td_mpp
+      TYPE(TMPP) , INTENT(IN) :: td_mpp
       INTEGER(i4), INTENT(IN) :: id_procid
 
@@ -2936,18 +3203,14 @@
       INTEGER(i4) :: il_i1, il_i2
       INTEGER(i4) :: il_j1, il_j2
-      TYPE(TMPP)  :: tl_mpp
       !----------------------------------------------------------------
 
       IF( ASSOCIATED(td_mpp%t_proc) )THEN
 
-         tl_mpp=td_mpp
-         !IF( TRIM(td_mpp%c_dom) == "unknown" )THEN
          IF( TRIM(td_mpp%c_dom) == '' )THEN
-            CALL logger_warn("GET PROC INDEX: decomposition type unknown. "//&
-            &             "look for it")
-            CALL mpp_get_dom( tl_mpp )
+            CALL logger_fatal("MPP GET PROC INDEX: decomposition type unknown. "//&
+            &                 "you should ahve run mpp_get_dom before.")
          ENDIF
 
-         SELECT CASE(TRIM(tl_mpp%c_dom))
+         SELECT CASE(TRIM(td_mpp%c_dom))
             CASE('full')
                il_i1 = 1 ; il_i2 = td_mpp%t_dim(1)%i_len
@@ -2957,5 +3220,5 @@
                 il_j1 = td_mpp%t_proc(id_procid)%i_jmpp
 
-                il_i2 = il_i1 + td_mpp%t_proc(id_procid)%i_lci - 1 ! attention lei dans ioRestartDimg
+                il_i2 = il_i1 + td_mpp%t_proc(id_procid)%i_lci - 1 
                 il_j2 = il_j1 + td_mpp%t_proc(id_procid)%i_lcj - 1 
             CASE('nooverlap')
@@ -2970,5 +3233,5 @@
                &        td_mpp%t_proc(id_procid)%i_lej - 1
             CASE DEFAULT
-               CALL logger_error("GET PROC INDEX: invalid decomposition type.")
+               CALL logger_error("MPP GET PROC INDEX: invalid decomposition type.")
          END SELECT
 
@@ -2976,9 +3239,8 @@
 
       ELSE
-         CALL logger_error("GET PROC INDEX: domain decomposition not define.")
+         CALL logger_error("MPP GET PROC INDEX: domain decomposition not define.")
       ENDIF
 
    END FUNCTION mpp_get_proc_index
-   !> @endcode
    !-------------------------------------------------------------------
    !> @brief
@@ -2987,11 +3249,10 @@
    !
    !> @author J.Paul
-   !> @date Nov, 2013
-   !
-   !> @param[in] td_mpp : mpp strcuture
-   !> @param[in] id_procid : sub domain id
-   !> @return table of index (/ isize, jsize /)
-   !-------------------------------------------------------------------
-   !> @code
+   !> @date November, 2013
+   !
+   !> @param[in] td_mpp    mpp strcuture
+   !> @param[in] id_procid sub domain id
+   !> @return array of index (/ isize, jsize /)
+   !-------------------------------------------------------------------
    FUNCTION mpp_get_proc_size( td_mpp, id_procid )
       IMPLICIT NONE
@@ -3007,18 +3268,14 @@
       INTEGER(i4) :: il_isize
       INTEGER(i4) :: il_jsize
-      TYPE(TMPP)  :: tl_mpp
       !----------------------------------------------------------------
 
       IF( ASSOCIATED(td_mpp%t_proc) )THEN
 
-         tl_mpp=td_mpp
-         !IF( TRIM(td_mpp%c_dom) == "unknown" )THEN
          IF( TRIM(td_mpp%c_dom) == '' )THEN
-            CALL logger_warn("GET PROC SIZE: decomposition type unknown. "//&
-            &              "look for it")
-            CALL mpp_get_dom( tl_mpp )
+            CALL logger_fatal("MPP GET PROC SIZE: decomposition type unknown. "//&
+            &                 "you should ahve run mpp_get_dom before.")
          ENDIF
 
-         SELECT CASE(TRIM(tl_mpp%c_dom))
+         SELECT CASE(TRIM(td_mpp%c_dom))
             CASE('full')
                
@@ -3037,6 +3294,6 @@
                &          td_mpp%t_proc(id_procid)%i_ldj + 1
             CASE DEFAULT
-               CALL logger_error("GET PROC SIZE: invalid decomposition type : "//&
-               &  TRIM(tl_mpp%c_dom) )
+               CALL logger_error("MPP GET PROC SIZE: invalid decomposition type : "//&
+               &  TRIM(td_mpp%c_dom) )
          END SELECT
 
@@ -3044,22 +3301,18 @@
 
       ELSE
-         CALL logger_error("GET PROC SIZE: domain decomposition not define.")
+         CALL logger_error("MPP GET PROC SIZE: domain decomposition not define.")
       ENDIF
 
    END FUNCTION mpp_get_proc_size
-   !> @endcode
    !-------------------------------------------------------------------
    !> @brief 
    !>  This subroutine determine domain decomposition type.
    !>  (full, overlap, noverlap)
-   !
-   !> @author J.Paul
-   !> @date Nov, 2013
-   !
-   !> @param[inout] td_mpp : mpp strcuture
-   !> @todo
-   !> - change name, confusing with domain.f90
-   !-------------------------------------------------------------------
-   !> @code
+   !>
+   !> @author J.Paul
+   !> @date November, 2013
+   !>
+   !> @param[inout] td_mpp mpp strcuture
+   !-------------------------------------------------------------------
    SUBROUTINE mpp_get_dom( td_mpp )
       IMPLICIT NONE
@@ -3075,5 +3328,5 @@
 
          IF( td_mpp%i_niproc == 0 .AND. td_mpp%i_niproc == 0 )THEN
-            CALL logger_info("GET DOM: use indoor indices to get domain "//&
+            CALL logger_info("MPP GET DOM: use indoor indices to get domain "//&
             &             "decomposition type.")
             IF((td_mpp%t_proc(1)%t_dim(1)%i_len ==                         &
@@ -3100,24 +3353,24 @@
             ELSE
 
-               CALL logger_error("GET DOM: should have been an impossible case")
+               CALL logger_error("MPP GET DOM: should have been an impossible case")
 
                il_isize=td_mpp%t_proc(1)%t_dim(1)%i_len
                il_jsize=td_mpp%t_proc(1)%t_dim(2)%i_len
-               CALL logger_debug("GET DOM: proc size "//&
+               CALL logger_debug("MPP GET DOM: proc size "//&
                &  TRIM(fct_str(il_isize))//" x "//TRIM(fct_str(il_jsize)) )
 
                il_isize=td_mpp%t_proc(1)%i_lei - td_mpp%t_proc(1)%i_ldi + 1
                il_jsize=td_mpp%t_proc(1)%i_lej - td_mpp%t_proc(1)%i_ldj + 1
-               CALL logger_debug("GET DOM: no overlap size "//&
+               CALL logger_debug("MPP GET DOM: no overlap size "//&
                &  TRIM(fct_str(il_isize))//" x "//TRIM(fct_str(il_jsize)) )
 
                il_isize=td_mpp%t_proc(1)%i_lci
                il_jsize=td_mpp%t_proc(1)%i_lcj
-               CALL logger_debug("GET DOM: overlap size "//&
+               CALL logger_debug("MPP GET DOM: overlap size "//&
                &  TRIM(fct_str(il_isize))//" x "//TRIM(fct_str(il_jsize)) )
 
                il_isize=td_mpp%t_dim(1)%i_len
                il_jsize=td_mpp%t_dim(2)%i_len
-               CALL logger_debug("GET DOM: full size "//&
+               CALL logger_debug("MPP GET DOM: full size "//&
                &  TRIM(fct_str(il_isize))//" x "//TRIM(fct_str(il_jsize)) )
 
@@ -3126,5 +3379,5 @@
          ELSE
 
-            CALL logger_info("GET DOM: use number of processors following "//&
+            CALL logger_info("MPP GET DOM: use number of processors following "//&
             &             "I and J to get domain decomposition type.")
             IF( td_mpp%i_niproc*td_mpp%i_njproc==td_mpp%i_nproc )THEN
@@ -3140,23 +3393,21 @@
 
       ELSE
-         CALL logger_error("GET DOM: domain decomposition not define.")
+         CALL logger_error("MPP GET DOM: domain decomposition not define.")
       ENDIF
 
    END SUBROUTINE mpp_get_dom
-   !> @endcode
    !-------------------------------------------------------------------
    !> @brief This function check if variable  and mpp structure use same
    !> dimension.
-   !
+   !>
    !> @details
-   !
-   !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[in] td_mpp : mpp structure
-   !> @param[in] td_var : variable structure
+   !>
+   !> @author J.Paul
+   !> - November, 2013- Initial Version
+   !>
+   !> @param[in] td_mpp mpp structure
+   !> @param[in] td_var variable structure
    !> @return dimension of variable and mpp structure agree (or not)
    !-------------------------------------------------------------------
-   ! @code
    LOGICAL FUNCTION mpp__check_var_dim(td_mpp, td_var)
       IMPLICIT NONE
@@ -3179,5 +3430,5 @@
 
          CALL logger_error( &
-         &  " CHECK DIM: variable and mpp dimension differ"//&
+         &  "MPP CHECK DIM: variable and mpp dimension differ"//&
          &  " for variable "//TRIM(td_var%c_name)//&
          &  " and mpp "//TRIM(td_mpp%c_name))
@@ -3189,5 +3440,5 @@
          DO ji = 1, il_ndim
             CALL logger_debug( &
-            &  " CHECK DIM: for dimension "//&
+            &  "MPP CHECK DIM: for dimension "//&
             &  TRIM(td_mpp%t_dim(ji)%c_name)//&
             &  ", mpp length: "//&
@@ -3200,5 +3451,156 @@
 
    END FUNCTION mpp__check_var_dim
-   ! @endcode
+   !-------------------------------------------------------------------
+   !> @brief This function return the mpp id, in a array of mpp
+   !> structure,  given mpp base name. 
+   !
+   !> @author J.Paul
+   !> - November, 2013- Initial Version
+   !
+   !> @param[in] td_file   array of file structure
+   !> @param[in] cd_name   file name
+   !> @return file id in array of file structure (0 if not found)
+   !-------------------------------------------------------------------
+   INTEGER(i4) FUNCTION mpp_get_index(td_mpp, cd_name)
+      IMPLICIT NONE
+      ! Argument      
+      TYPE(TMPP)      , DIMENSION(:), INTENT(IN) :: td_mpp
+      CHARACTER(LEN=*),               INTENT(IN) :: cd_name
+
+      ! local variable
+      CHARACTER(LEN=lc) :: cl_name
+      INTEGER(i4)       :: il_size
+
+      ! loop indices
+      INTEGER(i4) :: ji
+      !----------------------------------------------------------------
+      mpp_get_index=0
+      il_size=SIZE(td_mpp(:))
+
+      cl_name=TRIM( file_rename(cd_name) )
+
+      ! check if mpp is in array of mpp structure
+      DO ji=1,il_size
+         ! look for file name
+         IF( TRIM(fct_lower(td_mpp(ji)%c_name)) == TRIM(fct_lower(cd_name)) )THEN
+ 
+            mpp_get_index=ji
+            EXIT
+
+         ENDIF
+      ENDDO
+
+   END FUNCTION mpp_get_index
+   !-------------------------------------------------------------------
+   !> @brief This function recombine variable splitted mpp structure. 
+   !
+   !> @author J.Paul
+   !> - Ocotber, 2014- Initial Version
+   !
+   !> @param[in] td_mpp   mpp file structure
+   !> @param[in] cd_name  variable name
+   !> @return variable strucutre
+   !-------------------------------------------------------------------
+   TYPE(TVAR) FUNCTION mpp_recombine_var(td_mpp, cd_name) 
+   IMPLICIT NONE
+      ! Argument      
+      TYPE(TMPP)      , INTENT(IN) :: td_mpp
+      CHARACTER(LEN=*), INTENT(IN) :: cd_name
+
+      ! local variable
+      INTEGER(i4)                       :: il_varid
+      INTEGER(i4)                       :: il_status
+      INTEGER(i4)                       :: il_i1p
+      INTEGER(i4)                       :: il_i2p
+      INTEGER(i4)                       :: il_j1p
+      INTEGER(i4)                       :: il_j2p
+      INTEGER(i4), DIMENSION(4)         :: il_ind
+
+      INTEGER(i4), DIMENSION(ip_maxdim) :: il_strt
+      INTEGER(i4), DIMENSION(ip_maxdim) :: il_cnt
+
+      TYPE(TVAR)                        :: tl_tmp
+      TYPE(TVAR)                        :: tl_var
+
+      ! loop indices
+      INTEGER(i4) :: ji
+      INTEGER(i4) :: jk
+      !----------------------------------------------------------------
+
+      il_varid=var_get_index( td_mpp%t_proc(1)%t_var(:), cd_name)
+      IF( il_varid /= 0 )THEN
+      
+         tl_var=var_copy(td_mpp%t_proc(1)%t_var(il_varid))
+         ! Allocate space to hold variable value in structure 
+         IF( ASSOCIATED(tl_var%d_value) )THEN
+            DEALLOCATE(tl_var%d_value)   
+         ENDIF
+         ! 
+         DO ji=1,ip_maxdim
+            IF( tl_var%t_dim(ji)%l_use )THEN
+               tl_var%t_dim(ji)%i_len=td_mpp%t_dim(ji)%i_len
+            ENDIF
+         ENDDO
+
+         ALLOCATE(tl_var%d_value( tl_var%t_dim(1)%i_len, &
+         &                        tl_var%t_dim(2)%i_len, &
+         &                        tl_var%t_dim(3)%i_len, &
+         &                        tl_var%t_dim(4)%i_len),&
+         &        stat=il_status)
+         IF(il_status /= 0 )THEN
+
+           CALL logger_error( &
+            &  " MPP RECOMBINE VAR: not enough space to put variable "//&
+            &  TRIM(tl_var%c_name)//" in variable structure")
+
+         ENDIF
+
+         ! FillValue by default
+         tl_var%d_value(:,:,:,:)=tl_var%d_fill
+
+         ! read processor 
+         DO jk=1,td_mpp%i_nproc
+            IF( td_mpp%t_proc(jk)%l_use )THEN
+               ! get processor indices
+               il_ind(:)=mpp_get_proc_index( td_mpp, jk )
+               il_i1p = il_ind(1)
+               il_i2p = il_ind(2)
+               il_j1p = il_ind(3)
+               il_j2p = il_ind(4)
+ 
+               il_strt(:)=(/ 1,1,1,1 /)
+
+               il_cnt(:)=(/ il_i2p-il_i1p+1,         &
+               &            il_j2p-il_j1p+1,         &
+               &            tl_var%t_dim(3)%i_len, &
+               &            tl_var%t_dim(4)%i_len /)
+
+               tl_tmp=iom_read_var( td_mpp%t_proc(jk), tl_var%c_name,&
+               &                    il_strt(:), il_cnt(:) )
+               
+               ! replace value in output variable structure
+               tl_var%d_value( il_i1p : il_i2p,  &
+               &               il_j1p : il_j2p,  &
+               &               :,:) = tl_tmp%d_value(:,:,:,:)
+
+               ! clean
+               CALL var_clean(tl_tmp)
+
+            ENDIF
+         ENDDO
+
+         mpp_recombine_var=var_copy(tl_var)
+
+         ! clean
+         CALL var_clean(tl_var)
+
+      ELSE
+
+         CALL logger_error( &
+         &  " MPP RECOMBINE VAR: there is no variable with "//&
+         &  "name or standard name"//TRIM(cd_name)//&
+         &  " in mpp file "//TRIM(td_mpp%c_name))
+      ENDIF
+   END FUNCTION mpp_recombine_var
 END MODULE mpp
 
