Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/cfg/dummy.cfg
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/cfg/dummy.cfg	(revision 6392)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/cfg/dummy.cfg	(revision 6392)
@@ -0,0 +1,5 @@
+&namdum
+   cn_dumvar=""
+   cn_dumdim=""
+   cn_dumatt="history"
+/
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/cfg/variable.cfg
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/cfg/variable.cfg	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/cfg/variable.cfg	(revision 6392)
@@ -1,7 +1,7 @@
 # name       | units          | axis | pt| interpolation   | long name                             | standard name                                  
-X            | 1              | X    |   |                 |                                       | projection_x_coordinate               
-Y            | 1              | Y    |   |                 |                                       | projection_y_coordinate               
-Z            | 1              | Z    |   |                 |                                       | projection_z_coordinate               
-T            | 1              | T    |   |                 |                                       | projection_t_coordinate               
+X            | unitless       | X    |   |                 |                                       | projection_x_coordinate               
+Y            | unitless       | Y    |   |                 |                                       | projection_y_coordinate               
+Z            | unitless       | Z    |   |                 |                                       | projection_z_coordinate               
+T            | unitless       | T    |   |                 |                                       | projection_t_coordinate               
 nav_lon      | degrees_east   | XY   | T | cubic           | Longitude                             | longitude                                   
 nav_lat      | degrees_north  | XY   | T | cubic           | Latitude                              | latitude                         
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/Doxyfile
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/Doxyfile	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/Doxyfile	(revision 6392)
@@ -45,5 +45,5 @@
 # quick idea about the purpose of the project. Keep the description short.
 
-PROJECT_BRIEF          = "System and Interface for oceanic RElocable Nesting"
+PROJECT_BRIEF          = "System and Interface for oceanic RElocatable Nesting"
 
 # With the PROJECT_LOGO tag one can specify an logo or icon that is included in
@@ -2069,5 +2069,5 @@
 # The default value is: NO.
 
-HAVE_DOT               = YES
+HAVE_DOT               = NO
 
 # The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/attribute.f90
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/attribute.f90	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/attribute.f90	(revision 6392)
@@ -83,4 +83,6 @@
 !> @date November, 2014 
 !> - Fix memory leaks bug
+!> @date September, 2015
+!> - manage useless (dummy) attributes
 !
 !> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -98,4 +100,6 @@
    PUBLIC :: TATT       !< attribute structure
 
+   PRIVATE :: cm_dumatt !< dummy attribute array
+
    ! function and subroutine
    PUBLIC :: att_init       !< initialize attribute structure
@@ -105,4 +109,6 @@
    PUBLIC :: att_get_index  !< get attribute index, in an array of attribute structure
    PUBLIC :: att_get_id     !< get attribute id, read from file
+   PUBLIC :: att_get_dummy  !< fill dummy attribute array
+   PUBLIC :: att_is_dummy   !< check if attribute is defined as dummy attribute
 
    PRIVATE :: att__clean_unit ! clean attribute strcuture
@@ -135,4 +141,6 @@
    END TYPE TATT
 
+   CHARACTER(LEN=lc), DIMENSION(ip_maxdum), SAVE :: cm_dumatt !< dummy attribute
+
    INTERFACE att_init
       MODULE PROCEDURE att__init_c    
@@ -1251,4 +1259,98 @@
 
    END SUBROUTINE att__clean_arr
+   !-------------------------------------------------------------------
+   !> @brief This subroutine fill dummy attribute array
+   !
+   !> @author J.Paul
+   !> @date September, 2015 - Initial Version
+   !> @date Marsh, 2016
+   !> - close file (bugfix)
+   !
+   !> @param[in] cd_dummy dummy configuration file
+   !-------------------------------------------------------------------
+   SUBROUTINE att_get_dummy( cd_dummy )
+      IMPLICIT NONE
+      ! Argument
+      CHARACTER(LEN=*), INTENT(IN) :: cd_dummy
+
+      ! local variable
+      INTEGER(i4)   :: il_fileid
+      INTEGER(i4)   :: il_status
+
+      LOGICAL       :: ll_exist
+
+      ! loop indices
+      ! namelist
+      CHARACTER(LEN=lc), DIMENSION(ip_maxdum) :: cn_dumvar
+      CHARACTER(LEN=lc), DIMENSION(ip_maxdum) :: cn_dumdim
+      CHARACTER(LEN=lc), DIMENSION(ip_maxdum) :: cn_dumatt
+
+      !----------------------------------------------------------------
+      NAMELIST /namdum/ &   !< dummy namelist
+      &  cn_dumvar, &       !< variable  name
+      &  cn_dumdim, &       !< dimension name
+      &  cn_dumatt          !< attribute name
+      !----------------------------------------------------------------
+
+      ! init
+      cm_dumatt(:)=''
+
+      ! read namelist
+      INQUIRE(FILE=TRIM(cd_dummy), EXIST=ll_exist)
+      IF( ll_exist )THEN
+    
+         il_fileid=fct_getunit()
+   
+         OPEN( il_fileid, FILE=TRIM(cd_dummy), &
+         &                FORM='FORMATTED',       &
+         &                ACCESS='SEQUENTIAL',    &
+         &                STATUS='OLD',           &
+         &                ACTION='READ',          &
+         &                IOSTAT=il_status)
+         CALL fct_err(il_status)
+         IF( il_status /= 0 )THEN
+            CALL logger_fatal("DIM GET DUMMY: opening "//TRIM(cd_dummy))
+         ENDIF
+   
+         READ( il_fileid, NML = namdum )
+         cm_dumatt(:)=cn_dumatt(:)
+
+         CLOSE( il_fileid )
+
+      ENDIF
+   
+   END SUBROUTINE att_get_dummy
+   !-------------------------------------------------------------------
+   !> @brief This function check if attribute is defined as dummy attribute
+   !> in configuraton file
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - Initial Version
+   !
+   !> @param[in] td_att attribute structure
+   !> @return true if attribute is dummy attribute
+   !-------------------------------------------------------------------
+   FUNCTION att_is_dummy(td_att)
+      IMPLICIT NONE
+
+      ! Argument      
+      TYPE(TATT), INTENT(IN) :: td_att
+      
+      ! function
+      LOGICAL :: att_is_dummy
+      
+      ! loop indices
+      INTEGER(i4) :: ji
+      !----------------------------------------------------------------
+
+      att_is_dummy=.FALSE.
+      DO ji=1,ip_maxdum
+         IF( fct_lower(td_att%c_name) == fct_lower(cm_dumatt(ji)) )THEN
+            att_is_dummy=.TRUE.
+            EXIT
+         ENDIF
+      ENDDO
+
+   END FUNCTION att_is_dummy
 END MODULE att
 
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/boundary.f90
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/boundary.f90	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/boundary.f90	(revision 6392)
@@ -482,5 +482,5 @@
    !> ex : cn_north='index1,first1,last1(width)|index2,first2,last2'
    !>
-   !> @note Boundaries are compute on T point, but expressed on U,V point.
+   !> @warn Boundaries are compute on T point, but expressed on U,V point.
    !> change will be done to get data on other point when need be. 
    !>
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/create_bathy.f90
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/create_bathy.f90	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/create_bathy.f90	(revision 6392)
@@ -8,5 +8,5 @@
 !> @file
 !> @brief 
-!> This program create fine grid bathymetry file.
+!> This program creates fine grid bathymetry file.
 !>
 !> @details
@@ -27,5 +27,5 @@
 !>    you could find a template of the namelist in templates directory.
 !>
-!>    create_bathy.nam comprise 7 namelists:<br/>
+!>    create_bathy.nam contains 7 namelists:<br/>
 !>       - logger namelist (namlog)
 !>       - config namelist (namcfg)
@@ -36,8 +36,4 @@
 !>       - output namelist (namout)
 !>    
-!>    @note 
-!>       All namelists have to be in file create_bathy.nam, however variables of
-!>       those namelists are all optional.
-!>
 !>    * _logger namelist (namlog)_:<br/>
 !>       - cn_logfile   : log filename
@@ -49,4 +45,6 @@
 !>       - cn_varcfg : variable configuration file 
 !> (see ./SIREN/cfg/variable.cfg)
+!>       - cn_dumcfg : useless (dummy) configuration file, for useless 
+!> dimension or variable (see ./SIREN/cfg/dummy.cfg).
 !>
 !>    * _coarse grid namelist (namcrs)_:<br/>
@@ -61,30 +59,4 @@
 !>
 !>    * _variable namelist (namvar)_:<br/>
-!>       - cn_varinfo : list of variable and extra information about request(s) 
-!>       to be used.<br/>
-!>          each elements of *cn_varinfo* is a string character
-!>          (separated by ',').<br/>
-!>          it is composed of the variable name follow by ':', 
-!>          then request(s) to be used on this variable.<br/> 
-!>          request could be:
-!>             - int = interpolation method
-!>             - ext = extrapolation method
-!>             - flt = filter method
-!>             - min = minimum value
-!>             - max = maximum value
-!>             - unt = new units
-!>             - unf = unit scale factor (linked to new units)
-!>
-!>                requests must be separated by ';'.<br/>
-!>                order of requests does not matter.<br/>
-!>
-!>          informations about available method could be find in @ref interp,
-!>          @ref extrap and @ref filter modules.<br/>
-!>          Example: 'Bathymetry: flt=2*hamming(2,3); min=0'
-!>          @note 
-!>             If you do not specify a method which is required, 
-!>             default one is apply.
-!>          @warning 
-!>             variable name must be __Bathymetry__ here.
 !>       - cn_varfile : list of variable, and corresponding file.<br/> 
 !>          *cn_varfile* is the path and filename of the file where find
@@ -108,4 +80,31 @@
 !>             - 'Bathymetry:5000,5000,5000/5000,3000,5000/5000,5000,5000'
 !>
+!>       - cn_varinfo : list of variable and extra information about request(s) 
+!>       to be used.<br/>
+!>          each elements of *cn_varinfo* is a string character
+!>          (separated by ',').<br/>
+!>          it is composed of the variable name follow by ':', 
+!>          then request(s) to be used on this variable.<br/> 
+!>          request could be:
+!>             - int = interpolation method
+!>             - ext = extrapolation method
+!>             - flt = filter method
+!>             - min = minimum value
+!>             - max = maximum value
+!>             - unt = new units
+!>             - unf = unit scale factor (linked to new units)
+!>
+!>                requests must be separated by ';'.<br/>
+!>                order of requests does not matter.<br/>
+!>
+!>          informations about available method could be find in @ref interp,
+!>          @ref extrap and @ref filter modules.<br/>
+!>          Example: 'Bathymetry: flt=2*hamming(2,3); min=0'
+!>          @note 
+!>             If you do not specify a method which is required, 
+!>             default one is apply.
+!>          @warning 
+!>             variable name must be __Bathymetry__ here.
+!>
 !>    * _nesting namelist (namnst)_:<br/>
 !>       - in_rhoi  : refinement factor in i-direction
@@ -127,8 +126,13 @@
 !> - extrapolate all land points.
 !> - allow to change unit.
+!> @date September, 2015
+!> - manage useless (dummy) variable, attributes, and dimension
+!> @date January,2016
+!> - add create_bathy_check_depth as in create_boundary
+!> - add create_bathy_check_time  as in create_boundary
+!> @date February, 2016
+!> - do not closed sea for east-west cyclic domain
 !
 !> @todo
-!> - use create_bathy_check_depth as in create_boundary
-!> - use create_bathy_check_time  as in create_boundary
 !> - check tl_multi is not empty
 !>
@@ -167,5 +171,4 @@
    INTEGER(i4)                                        :: il_status
    INTEGER(i4)                                        :: il_fileid
-   INTEGER(i4)                                        :: il_varid
    INTEGER(i4)                                        :: il_attid
    INTEGER(i4)                                        :: il_imin0
@@ -179,4 +182,5 @@
 
    LOGICAL                                            :: ll_exist
+   LOGICAL                                            :: ll_fillclosed
 
    TYPE(TMPP)                                         :: tl_coord0
@@ -208,30 +212,31 @@
    ! namelist variable
    ! namlog
-   CHARACTER(LEN=lc) :: cn_logfile = 'create_bathy.log' 
-   CHARACTER(LEN=lc) :: cn_verbosity = 'warning' 
-   INTEGER(i4)       :: in_maxerror = 5
+   CHARACTER(LEN=lc)                       :: cn_logfile = 'create_bathy.log' 
+   CHARACTER(LEN=lc)                       :: cn_verbosity = 'warning' 
+   INTEGER(i4)                             :: in_maxerror = 5
 
    ! namcfg
-   CHARACTER(LEN=lc) :: cn_varcfg = 'variable.cfg' 
+   CHARACTER(LEN=lc)                       :: cn_varcfg = './cfg/variable.cfg' 
+   CHARACTER(LEN=lc)                       :: cn_dumcfg = './cfg/dummy.cfg' 
 
    ! namcrs
-   CHARACTER(LEN=lc) :: cn_coord0 = '' 
-   INTEGER(i4)       :: in_perio0 = -1
+   CHARACTER(LEN=lc)                       :: cn_coord0 = '' 
+   INTEGER(i4)                             :: in_perio0 = -1
 
    ! namfin
-   CHARACTER(LEN=lc) :: cn_coord1 = ''
-   INTEGER(i4)       :: in_perio1 = -1
-   LOGICAL           :: ln_fillclosed = .TRUE.
+   CHARACTER(LEN=lc)                       :: cn_coord1 = ''
+   INTEGER(i4)                             :: in_perio1 = -1
+   LOGICAL                                 :: ln_fillclosed = .TRUE.
 
    ! namvar
+   CHARACTER(LEN=lc), DIMENSION(ip_maxvar) :: cn_varfile = ''
    CHARACTER(LEN=lc), DIMENSION(ip_maxvar) :: cn_varinfo = ''
-   CHARACTER(LEN=lc), DIMENSION(ip_maxvar) :: cn_varfile = ''
 
    ! namnst
-   INTEGER(i4)       :: in_rhoi  = 1
-   INTEGER(i4)       :: in_rhoj  = 1
+   INTEGER(i4)                             :: in_rhoi  = 1
+   INTEGER(i4)                             :: in_rhoj  = 1
 
    ! namout
-   CHARACTER(LEN=lc) :: cn_fileout = 'bathy_fine.nc' 
+   CHARACTER(LEN=lc)                       :: cn_fileout = 'bathy_fine.nc' 
    !-------------------------------------------------------------------
 
@@ -242,5 +247,6 @@
 
    NAMELIST /namcfg/ &   !< configuration namelist
-   &  cn_varcfg          !< variable configuration file
+   &  cn_varcfg, &       !< variable configuration file
+   &  cn_dumcfg          !< dummy configuration file
 
    NAMELIST /namcrs/ &   !< coarse grid namelist
@@ -254,6 +260,6 @@
  
    NAMELIST /namvar/ &   !< variable namelist
-   &  cn_varinfo, &      !< list of variable and interpolation method to be used. (ex: 'votemper:linear','vosaline:cubic' )
-   &  cn_varfile         !< list of variable file
+   &  cn_varfile, &      !< list of variable file
+   &  cn_varinfo         !< list of variable and interpolation method to be used. (ex: 'votemper:linear','vosaline:cubic' )
    
    NAMELIST /namnst/ &   !< nesting namelist
@@ -302,4 +308,11 @@
       CALL var_def_extra(TRIM(cn_varcfg))
 
+      ! get dummy variable
+      CALL var_get_dummy(TRIM(cn_dumcfg))
+      ! get dummy dimension
+      CALL dim_get_dummy(TRIM(cn_dumcfg))
+      ! get dummy attribute
+      CALL att_get_dummy(TRIM(cn_dumcfg))
+
       READ( il_fileid, NML = namcrs )
       READ( il_fileid, NML = namfin )
@@ -309,5 +322,5 @@
       ! match variable with file
       tl_multi=multi_init(cn_varfile)
-      
+ 
       READ( il_fileid, NML = namnst )
       READ( il_fileid, NML = namout )
@@ -322,4 +335,5 @@
 
       PRINT *,"ERROR in create_bathy: can't find "//TRIM(cl_namelist)
+      STOP
 
    ENDIF
@@ -343,4 +357,8 @@
       &     "check namelist")
    ENDIF
+
+   ! do not closed sea for east-west cyclic domain
+   ll_fillclosed=ln_fillclosed
+   IF( tl_coord1%i_perio == 1 ) ll_fillclosed=.FALSE.
 
    ! check
@@ -417,42 +435,14 @@
 
             ! get or check depth value
-            IF( tl_multi%t_mpp(ji)%t_proc(1)%i_depthid /= 0 )THEN
-               il_varid=tl_multi%t_mpp(ji)%t_proc(1)%i_depthid
-               IF( ASSOCIATED(tl_depth%d_value) )THEN
-                  tl_tmp=iom_mpp_read_var(tl_mpp,il_varid)
-                  IF( ANY( tl_depth%d_value(:,:,:,:) /= &
-                  &        tl_tmp%d_value(:,:,:,:) ) )THEN
-                     CALL logger_fatal("CREATE BATHY: depth value from "//&
-                     &  TRIM(tl_multi%t_mpp(ji)%c_name)//" not conform "//&
-                     &  " to those from former file(s).")
-                  ENDIF
-                  CALL var_clean(tl_tmp)
-               ELSE
-                  tl_depth=iom_mpp_read_var(tl_mpp,il_varid)
-               ENDIF
-            ENDIF
+            CALL create_bathy_check_depth( tl_mpp, tl_depth )
 
             ! get or check time value
-            IF( tl_multi%t_mpp(ji)%t_proc(1)%i_timeid /= 0 )THEN
-               il_varid=tl_multi%t_mpp(ji)%t_proc(1)%i_timeid
-               IF( ASSOCIATED(tl_time%d_value) )THEN
-                  tl_tmp=iom_mpp_read_var(tl_mpp,il_varid)
-                  IF( ANY( tl_time%d_value(:,:,:,:) /= &
-                  &        tl_tmp%d_value(:,:,:,:) ) )THEN
-                     CALL logger_fatal("CREATE BATHY: time value from "//&
-                     &  TRIM(tl_multi%t_mpp(ji)%c_name)//" not conform "//&
-                     &  " to those from former file(s).")
-                  ENDIF
-                  CALL var_clean(tl_tmp)
-               ELSE
-                  tl_time=iom_mpp_read_var(tl_mpp,il_varid)
-               ENDIF
-            ENDIF
+            CALL create_bathy_check_time( tl_mpp, tl_time )
 
             ! close mpp file
             CALL iom_mpp_close(tl_mpp)
 
-            IF( ANY( tl_mpp%t_dim(1:2)%i_len /= &
-            &        tl_coord0%t_dim(1:2)%i_len) )THEN
+            IF( ANY(tl_mpp%t_dim(1:2)%i_len /= tl_coord0%t_dim(1:2)%i_len).OR.&
+            &   ALL(il_rho(:)==1) )THEN
                !- extract bathymetry from fine grid bathymetry 
                DO jj=1,tl_multi%t_mpp(ji)%t_proc(1)%i_nvar
@@ -505,5 +495,5 @@
 
          ! fill closed sea
-         IF( ln_fillclosed )THEN
+         IF( ll_fillclosed )THEN
             ALLOCATE( il_mask(tl_var(jk)%t_dim(1)%i_len, &
             &                 tl_var(jk)%t_dim(2)%i_len) )
@@ -526,5 +516,5 @@
          &   dl_minbat <= 0._dp  )THEN
             CALL logger_debug("CREATE BATHY: min value "//TRIM(fct_str(dl_minbat)))
-            CALL logger_error("CREATE BATHY: Bathymetry has value <= 0")
+            CALL logger_fatal("CREATE BATHY: Bathymetry has value <= 0")
          ENDIF
 
@@ -973,4 +963,6 @@
       CALL dom_del_extra( tl_var, tl_dom, il_rho(:) )
 
+      CALL dom_clean_extra( tl_dom )
+
       !- add ghost cell
       CALL grid_add_ghost(tl_var,tl_dom%i_ghost(:,:))
@@ -1109,3 +1101,111 @@
 
    END SUBROUTINE create_bathy_interp
+   !-------------------------------------------------------------------
+   !> @brief
+   !> This subroutine get depth variable value in an open mpp structure
+   !> and check if agree with already input depth variable.
+   !> 
+   !> @details 
+   !>
+   !> @author J.Paul
+   !> @date January, 2016 - Initial Version
+   !>
+   !> @param[in] td_mpp       mpp structure
+   !> @param[inout] td_depth  depth variable structure 
+   !-------------------------------------------------------------------
+   SUBROUTINE create_bathy_check_depth( td_mpp, td_depth )
+
+      IMPLICIT NONE
+
+      ! Argument
+      TYPE(TMPP) , INTENT(IN   ) :: td_mpp
+      TYPE(TVAR) , INTENT(INOUT) :: td_depth
+
+      ! local variable
+      INTEGER(i4) :: il_varid
+      TYPE(TVAR)  :: tl_depth
+      ! loop indices
+      !----------------------------------------------------------------
+
+      ! get or check depth value
+      IF( td_mpp%t_proc(1)%i_depthid /= 0 )THEN
+
+         il_varid=td_mpp%t_proc(1)%i_depthid
+         IF( ASSOCIATED(td_depth%d_value) )THEN
+
+            tl_depth=iom_mpp_read_var(td_mpp, il_varid)
+
+            IF( ANY( td_depth%d_value(:,:,:,:) /= &
+            &        tl_depth%d_value(:,:,:,:) ) )THEN
+
+               CALL logger_warn("CREATE BATHY: depth value from "//&
+               &  TRIM(td_mpp%c_name)//" not conform "//&
+               &  " to those from former file(s).")
+
+            ENDIF
+            CALL var_clean(tl_depth)
+
+         ELSE
+            td_depth=iom_mpp_read_var(td_mpp,il_varid)
+         ENDIF
+
+      ENDIF
+      
+   END SUBROUTINE create_bathy_check_depth
+   !-------------------------------------------------------------------
+   !> @brief
+   !> This subroutine get date and time in an open mpp structure
+   !> and check if agree with date and time already read.
+   !> 
+   !> @details 
+   !>
+   !> @author J.Paul
+   !> @date January, 2016 - Initial Version
+   !>
+   !> @param[in] td_mpp      mpp structure
+   !> @param[inout] td_time  time variable structure 
+   !-------------------------------------------------------------------
+   SUBROUTINE create_bathy_check_time( td_mpp, td_time )
+
+      IMPLICIT NONE
+
+      ! Argument
+      TYPE(TMPP), INTENT(IN   ) :: td_mpp
+      TYPE(TVAR), INTENT(INOUT) :: td_time
+
+      ! local variable
+      INTEGER(i4) :: il_varid
+      TYPE(TVAR)  :: tl_time
+
+      TYPE(TDATE) :: tl_date1
+      TYPE(TDATE) :: tl_date2
+      ! loop indices
+      !----------------------------------------------------------------
+
+      ! get or check depth value
+      IF( td_mpp%t_proc(1)%i_timeid /= 0 )THEN
+
+         il_varid=td_mpp%t_proc(1)%i_timeid
+         IF( ASSOCIATED(td_time%d_value) )THEN
+
+            tl_time=iom_mpp_read_var(td_mpp, il_varid)
+
+            tl_date1=var_to_date(td_time)
+            tl_date2=var_to_date(tl_time)
+            IF( tl_date1 - tl_date2 /= 0 )THEN
+
+               CALL logger_warn("CREATE BATHY: date from "//&
+               &  TRIM(td_mpp%c_name)//" not conform "//&
+               &  " to those from former file(s).")
+
+            ENDIF
+            CALL var_clean(tl_time)
+
+         ELSE
+            td_time=iom_mpp_read_var(td_mpp,il_varid)
+         ENDIF
+
+      ENDIF
+      
+   END SUBROUTINE create_bathy_check_time
 END PROGRAM create_bathy
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/create_boundary.F90
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/create_boundary.F90	(revision 6392)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/create_boundary.F90	(revision 6392)
@@ -0,0 +1,1764 @@
+!----------------------------------------------------------------------
+! NEMO system team, System and Interface for oceanic RElocable Nesting
+!----------------------------------------------------------------------
+!
+!
+! PROGRAM: create_boundary
+!
+! DESCRIPTION:
+!> @file
+!> @brief 
+!> This program creates boundary files.
+!>
+!> @details
+!> @section sec1 method
+!> Variables are read from coarse grid standard output, 
+!> extracted or interpolated on fine grid. 
+!> Variables could also be manually written.<br/>
+!> @note 
+!>    method could be different for each variable.
+!>
+!> @section sec2 how to 
+!>    to create boundaries files:<br/>
+!> @code{.sh}
+!>    ./SIREN/bin/create_boundary create_boundary.nam
+!> @endcode
+!>  <br/> 
+!> \image html  boundary_NEATL36_70.png 
+!> \image latex boundary_NEATL36_70.png
+!>
+!> @note 
+!>    you could find a template of the namelist in templates directory.
+!>
+!>    create_boundary.nam contains 9 namelists:<br/>
+!>       - logger namelist (namlog)
+!>       - config namelist (namcfg)
+!>       - coarse grid namelist (namcrs)
+!>       - fine grid namelist (namfin)
+!>       - variable namelist (namvar)
+!>       - nesting namelist (namnst)
+!>       - boundary namelist (nambdy)
+!>       - vertical grid namelist (namzgr)
+!>       - output namelist (namout)
+!>    
+!>    * _logger namelist (namlog)_:<br/>
+!>       - cn_logfile   : log filename
+!>       - cn_verbosity : verbosity ('trace','debug','info',
+!> 'warning','error','fatal','none')
+!>       - in_maxerror  : maximum number of error allowed
+!>
+!>    * _config namelist (namcfg)_:<br/>
+!>       - cn_varcfg : variable configuration file
+!> (see ./SIREN/cfg/variable.cfg)
+!>       - cn_dumcfg : useless (dummy) configuration file, for useless 
+!> dimension or variable (see ./SIREN/cfg/dummy.cfg).
+!>
+!>    * _coarse grid namelist (namcrs)_:<br/>
+!>       - cn_coord0 : coordinate file
+!>       - in_perio0 : NEMO periodicity index (see Model Boundary Condition in
+!> [NEMO documentation](http://www.nemo-ocean.eu/About-NEMO/Reference-manuals))
+!>
+!>    * _fine grid namelist (namfin)_:<br/>
+!>       - cn_coord1 : coordinate file
+!>       - cn_bathy1 : bathymetry file
+!>       - in_perio1 : periodicity index
+!>
+!>    * _vertical grid namelist (namzgr)_:<br/>
+!>       - dn_pp_to_be_computed  :
+!>       - dn_ppsur              :
+!>       - dn_ppa0               :
+!>       - dn_ppa1               :
+!>       - dn_ppa2               : 
+!>       - dn_ppkth              :
+!>       - dn_ppkth2             :
+!>       - dn_ppacr              :
+!>       - dn_ppacr2             :
+!>       - dn_ppdzmin            :
+!>       - dn_pphmax             :
+!>       - in_nlevel             : number of vertical level
+!>
+!>    * _partial step namelist (namzps)_:<br/>
+!>       - dn_e3zps_min          :
+!>       - dn_e3zps_rat          : 
+!>
+!>    * _variable namelist (namvar)_:<br/>
+!>       - cn_varfile : list of variable, and associated file<br/> 
+!>          *cn_varfile* is the path and filename of the file where find
+!>          variable.<br/> 
+!>          @note 
+!>             *cn_varfile* could be a matrix of value, if you want to filled
+!>             manually variable value.<br/>
+!>             the variable array of value is split into equal subdomain.<br/>
+!>             Each subdomain is filled with the corresponding value 
+!>             of the matrix.<br/>          
+!>             separators used to defined matrix are:
+!>                - ',' for line
+!>                - '/' for row
+!>                - '\' for level<br/>
+!>                Example:<br/>
+!>                   3,2,3/1,4,5  =>  @f$ \left( \begin{array}{ccc}
+!>                                         3 & 2 & 3 \\\\
+!>                                         1 & 4 & 5 \end{array} \right) @f$
+!>          @warning 
+!>             the same matrix is used for all boundaries.
+!>
+!>       Examples: 
+!>          - 'votemper:gridT.nc', 'vozocrtx:gridU.nc'
+!>          - 'votemper:10\25', 'vozocrtx:gridU.nc'
+!>
+!>       - cn_varinfo : list of variable and extra information about request(s)
+!>          to be used (separated by ',').<br/>
+!>          each elements of *cn_varinfo* is a string character.<br/>
+!>          it is composed of the variable name follow by ':', 
+!>          then request(s) to be used on this variable.<br/> 
+!>          request could be:
+!>             - int = interpolation method
+!>             - ext = extrapolation method
+!>             - flt = filter method
+!>             - min = minimum value
+!>             - max = maximum value
+!>             - unt = new units
+!>             - unf = unit scale factor (linked to new units)
+!>
+!>                requests must be separated by ';'.<br/>
+!>                order of requests does not matter.
+!>
+!>          informations about available method could be find in @ref interp,
+!>          @ref extrap and @ref filter.<br/>
+!>
+!>          Example: 'votemper:int=linear;flt=hann;ext=dist_weight', 
+!>                   'vosaline:int=cubic'
+!>          @note 
+!>             If you do not specify a method which is required, 
+!>             default one is apply.
+!>
+!>    * _nesting namelist (namnst)_:<br/>
+!>       - in_rhoi  : refinement factor in i-direction
+!>       - in_rhoj  : refinement factor in j-direction
+!>
+!>    * _boundary namelist (nambdy)_:<br/>
+!>       - ln_north  : use north boundary
+!>       - ln_south  : use south boundary
+!>       - ln_east   : use east  boundary
+!>       - ln_west   : use west  boundary
+!>       - cn_north  : north boundary indices on fine grid
+!>          *cn_north* is a string character defining boundary
+!>          segmentation.<br/>
+!>          segments are separated by '|'.<br/>
+!>          each segments of the boundary is composed of:
+!>             - indice of velocity (orthogonal to boundary .ie. 
+!>                for north boundary, J-indice). 
+!>             - indice of segment start (I-indice for north boundary) 
+!>             - indice of segment end   (I-indice for north boundary)<br/>
+!>                indices must be separated by ':' .<br/>
+!>             - optionally, boundary size could be added between '(' and ')' 
+!>             in the definition of the first segment.
+!>                @note 
+!>                   boundary width is the same for all segments of one boundary.
+!>
+!>          Examples:
+!>             - cn_north='index1,first1:last1(width)'
+!>             - cn_north='index1(width),first1:last1|index2,first2:last2'
+!>             \image html  boundary_50.png 
+!>             \image latex boundary_50.png
+!>       - cn_south  : south boundary indices on fine grid
+!>       - cn_east   : east  boundary indices on fine grid
+!>       - cn_west   : west  boundary indices on fine grid
+!>       - ln_oneseg : force to use only one segment for each boundary or not
+!>
+!>    * _output namelist (namout)_:<br/>
+!>       - cn_fileout : fine grid boundary basename
+!>         (cardinal point and segment number will be automatically added)
+!>       - dn_dayofs  : date offset in day (change only ouput file name)
+!>       - ln_extrap  : extrapolate land point or not
+!>
+!>          Examples: 
+!>             - cn_fileout='boundary.nc'<br/>
+!>                if time_counter (16/07/2015 00h) is read on input file (see varfile), 
+!>                west boundary will be named boundary_west_y2015m07d16
+!>             - dn_dayofs=-2.<br/>
+!>                if you use day offset you get boundary_west_y2015m07d14
+!>       
+!>
+!> @author J.Paul
+! REVISION HISTORY:
+!> @date November, 2013 - Initial Version
+!> @date September, 2014
+!> - add header for user
+!> - take into account grid point to compue boundaries
+!> - reorder output dimension for north and south boundaries
+!> @date June, 2015
+!> - extrapolate all land points, and add ln_extrap in namelist.
+!> - allow to change unit.
+!> @date July, 2015
+!> - add namelist parameter to shift date of output file name.
+!> @date September, 2015
+!> - manage useless (dummy) variable, attributes, and dimension
+!> - allow to run on multi processors with key_mpp_mpi
+!> @date January, 2016
+!> - same process use for variable extracted or interpolated from input file.
+!>
+!> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+!----------------------------------------------------------------------
+PROGRAM create_boundary
+
+   USE netcdf                          ! nf90 library
+   USE global                          ! global variable
+   USE phycst                          ! physical constant
+   USE kind                            ! F90 kind parameter
+   USE fct                             ! basic useful function
+   USE date                            ! date manager
+   USE att                             ! attribute manager
+   USE dim                             ! dimension manager
+   USE var                             ! variable manager
+   USE file                            ! file manager
+   USE multi                           ! multi file manager
+   USE boundary                        ! boundary manager
+   USE iom                             ! I/O manager
+   USE dom                             ! domain manager
+   USE grid                            ! grid manager
+   USE vgrid                           ! vertical grid manager
+   USE extrap                          ! extrapolation manager
+   USE interp                          ! interpolation manager
+   USE filter                          ! filter manager
+   USE mpp                             ! MPP manager
+   USE iom_mpp                         ! MPP I/O manager
+
+   IMPLICIT NONE
+
+   ! local variable
+   INTEGER(i4)                                        :: il_narg
+
+#if defined key_mpp_mpi
+   ! mpp variable
+   CHARACTER(LEN=lc), DIMENSION(:)      , ALLOCATABLE :: cl_namelist
+   INTEGER(i4)                                        :: ierror
+   INTEGER(i4)                                        :: iproc
+   INTEGER(i4)                                        :: nproc
+   INTEGER(i4)      , DIMENSION(:)      , ALLOCATABLE :: il_nprog
+
+   ! loop indices
+   INTEGER(i4) :: jm
+#else
+   CHARACTER(LEN=lc)                                  :: cl_namelist
+#endif
+   !-------------------------------------------------------------------
+#if defined key_mpp_mpi
+   INCLUDE 'mpif.h'
+#endif
+   !-------------------------------------------------------------------
+
+   il_narg=COMMAND_ARGUMENT_COUNT() !f03 intrinsec
+#if ! defined key_mpp_mpi
+
+   IF( il_narg/=1 )THEN
+      PRINT *,"CREATE BOUNDARY: ERROR. need one namelist"
+      STOP
+   ELSE
+      CALL GET_COMMAND_ARGUMENT(1,cl_namelist) !f03 intrinsec
+   ENDIF
+
+   CALL create__boundary(cl_namelist)
+
+#else
+
+   ! Initialize MPI
+   CALL mpi_init(ierror)
+   CALL mpi_comm_rank(mpi_comm_world,iproc,ierror)
+   CALL mpi_comm_size(mpi_comm_world,nproc,ierror)
+
+   IF( il_narg==0 )THEN
+      PRINT *,"CREATE BOUNDARY: ERROR. need at least one namelist"
+      STOP
+   ELSE
+      ALLOCATE(cl_namelist(il_narg))
+      DO jm=1,il_narg
+         CALL GET_COMMAND_ARGUMENT(jm,cl_namelist(jm))
+      ENDDO
+   ENDIF
+
+   ALLOCATE(il_nprog(il_narg))
+   DO jm=1, il_narg
+      il_nprog(jm)= MOD(jm,nproc)
+   ENDDO
+
+   DO jm=1, il_narg
+      IF ( il_nprog(jm) .eq. iproc ) THEN
+         CALL create__boundary(cl_namelist(jm))
+      ENDIF
+   ENDDO
+
+   CALL mpi_finalize(ierror)
+
+   DEALLOCATE(cl_namelist)
+   DEALLOCATE(il_nprog)
+#endif
+
+CONTAINS
+SUBROUTINE create__boundary(cd_namelist)
+   !-------------------------------------------------------------------
+   !> @brief
+   !> This subroutine create boundary files.
+   !> 
+   !> @details 
+   !>
+   !> @author J.Paul
+   !> @date January, 2016 - Initial Version
+   !>
+   !> @param[in] cd_namelist namelist file 
+   !-------------------------------------------------------------------
+
+   USE logger                          ! log file manager
+
+   IMPLICIT NONE
+   ! Argument
+   CHARACTER(LEN=lc), INTENT(IN) :: cd_namelist 
+
+   ! local variable
+   CHARACTER(LEN=lc)                                  :: cl_date
+   CHARACTER(LEN=lc)                                  :: cl_name
+   CHARACTER(LEN=lc)                                  :: cl_bdyout
+   CHARACTER(LEN=lc)                                  :: cl_data
+   CHARACTER(LEN=lc)                                  :: cl_dimorder
+   CHARACTER(LEN=lc)                                  :: cl_fmt
+
+   INTEGER(i4)                                        :: il_status
+   INTEGER(i4)                                        :: il_fileid
+   INTEGER(i4)                                        :: il_imin0
+   INTEGER(i4)                                        :: il_imax0
+   INTEGER(i4)                                        :: il_jmin0
+   INTEGER(i4)                                        :: il_jmax0
+   INTEGER(i4)                                        :: il_shift
+   INTEGER(i4)      , DIMENSION(ip_maxdim)            :: il_rho
+   INTEGER(i4)      , DIMENSION(2,2)                  :: il_offset
+   INTEGER(i4)      , DIMENSION(2,2)                  :: il_ind
+
+   LOGICAL                                            :: ll_exist
+
+   TYPE(TATT)                                         :: tl_att
+   
+   TYPE(TVAR)                                         :: tl_depth   
+   TYPE(TVAR)                                         :: tl_time
+   TYPE(TVAR)                                         :: tl_var1
+   TYPE(TVAR)                                         :: tl_var0
+   TYPE(TVAR)                                         :: tl_lon1
+   TYPE(TVAR)                                         :: tl_lat1
+   TYPE(TVAR)                                         :: tl_lvl1  
+   TYPE(TVAR)       , DIMENSION(:)      , ALLOCATABLE :: tl_level
+   TYPE(TVAR)       , DIMENSION(:,:,:)  , ALLOCATABLE :: tl_seglvl1
+   TYPE(TVAR)       , DIMENSION(:,:,:)  , ALLOCATABLE :: tl_segvar1
+
+   TYPE(TDIM)       , DIMENSION(ip_maxdim)            :: tl_dim
+
+   TYPE(TDATE)                                        :: tl_date
+   
+   TYPE(TBDY)       , DIMENSION(ip_ncard)             :: tl_bdy
+   
+   TYPE(TDOM)                                         :: tl_dom0
+   TYPE(TDOM)                                         :: tl_dom1
+   TYPE(TDOM)       , DIMENSION(:,:,:)  , ALLOCATABLE :: tl_segdom1
+
+   TYPE(TFILE)                                        :: tl_fileout
+   
+   TYPE(TMPP)                                         :: tl_coord0
+   TYPE(TMPP)                                         :: tl_coord1
+   TYPE(TMPP)                                         :: tl_bathy1
+   TYPE(TMPP)                                         :: tl_mpp
+
+   TYPE(TMULTI)                                       :: tl_multi
+
+   ! loop indices
+   INTEGER(i4) :: jvar
+   INTEGER(i4) :: jpoint
+   INTEGER(i4) :: ji
+   INTEGER(i4) :: jj
+   INTEGER(i4) :: jk
+   INTEGER(i4) :: jl
+
+   ! namelist variable
+   ! namlog
+   CHARACTER(LEN=lc)                       :: cn_logfile = 'create_boundary.log' 
+   CHARACTER(LEN=lc)                       :: cn_verbosity = 'warning' 
+   INTEGER(i4)                             :: in_maxerror = 5
+
+   ! namcfg
+   CHARACTER(LEN=lc)                       :: cn_varcfg = 'variable.cfg' 
+   CHARACTER(LEN=lc)                       :: cn_dumcfg = 'dummy.cfg'
+
+   ! namcrs
+   CHARACTER(LEN=lc)                       :: cn_coord0 = '' 
+   INTEGER(i4)                             :: in_perio0 = -1
+
+   ! namfin
+   CHARACTER(LEN=lc)                       :: cn_coord1 = '' 
+   CHARACTER(LEN=lc)                       :: cn_bathy1 = '' 
+   INTEGER(i4)                             :: in_perio1 = -1
+
+   !namzgr
+   REAL(dp)                                :: dn_pp_to_be_computed = 0._dp
+   REAL(dp)                                :: dn_ppsur   = -3958.951371276829_dp
+   REAL(dp)                                :: dn_ppa0    =   103.953009600000_dp
+   REAL(dp)                                :: dn_ppa1    =     2.415951269000_dp
+   REAL(dp)                                :: dn_ppa2    =   100.760928500000_dp
+   REAL(dp)                                :: dn_ppkth   =    15.351013700000_dp
+   REAL(dp)                                :: dn_ppkth2  =    48.029893720000_dp
+   REAL(dp)                                :: dn_ppacr   =     7.000000000000_dp
+   REAL(dp)                                :: dn_ppacr2  =    13.000000000000_dp
+   REAL(dp)                                :: dn_ppdzmin = 6._dp
+   REAL(dp)                                :: dn_pphmax  = 5750._dp
+   INTEGER(i4)                             :: in_nlevel  = 75
+
+   !namzps
+   REAL(dp)                                :: dn_e3zps_min = 25._dp
+   REAL(dp)                                :: dn_e3zps_rat = 0.2_dp
+
+   ! namvar
+   CHARACTER(LEN=lc), DIMENSION(ip_maxvar) :: cn_varfile = ''
+   CHARACTER(LEN=lc), DIMENSION(ip_maxvar) :: cn_varinfo = ''
+
+   ! namnst
+   INTEGER(i4)                             :: in_rhoi  = 0
+   INTEGER(i4)                             :: in_rhoj  = 0
+
+   ! nambdy
+   LOGICAL                                 :: ln_north   = .TRUE.
+   LOGICAL                                 :: ln_south   = .TRUE.
+   LOGICAL                                 :: ln_east    = .TRUE.
+   LOGICAL                                 :: ln_west    = .TRUE.
+   LOGICAL                                 :: ln_oneseg  = .TRUE.
+   CHARACTER(LEN=lc)                       :: cn_north   = ''
+   CHARACTER(LEN=lc)                       :: cn_south   = ''
+   CHARACTER(LEN=lc)                       :: cn_east    = ''
+   CHARACTER(LEN=lc)                       :: cn_west    = ''
+
+   ! namout
+   CHARACTER(LEN=lc)                       :: cn_fileout = 'boundary.nc' 
+   REAL(dp)                                :: dn_dayofs  = 0._dp
+   LOGICAL                                 :: ln_extrap  = .FALSE.
+   !-------------------------------------------------------------------
+
+   NAMELIST /namlog/ &  !< logger namelist
+   &  cn_logfile,    &  !< log file
+   &  cn_verbosity,  &  !< log verbosity
+   &  in_maxerror
+
+   NAMELIST /namcfg/ &  !< config namelist
+   &  cn_varcfg, &       !< variable configuration file
+   &  cn_dumcfg          !< dummy configuration file
+
+   NAMELIST /namcrs/ &  !< coarse grid namelist
+   &  cn_coord0,     &  !< coordinate file
+   &  in_perio0         !< periodicity index
+ 
+   NAMELIST /namfin/ &  !< fine grid namelist
+   &  cn_coord1,     &  !< coordinate file
+   &  cn_bathy1,     &  !< bathymetry file
+   &  in_perio1         !< periodicity index
+ 
+   NAMELIST /namzgr/ &
+   &  dn_pp_to_be_computed, &
+   &  dn_ppsur,     &
+   &  dn_ppa0,      &
+   &  dn_ppa1,      &
+   &  dn_ppa2,      &
+   &  dn_ppkth,     &
+   &  dn_ppkth2,    &
+   &  dn_ppacr,     &
+   &  dn_ppacr2,    &
+   &  dn_ppdzmin,   &
+   &  dn_pphmax,    &
+   &  in_nlevel         !< number of vertical level
+
+   NAMELIST /namzps/ &
+   &  dn_e3zps_min, &
+   &  dn_e3zps_rat
+
+   NAMELIST /namvar/ &  !< variable namelist
+   &  cn_varfile, &     !< list of variable and file where find it. (ex: 'votemper:GLORYS_gridT.nc' ) 
+   &  cn_varinfo        !< list of variable and method to apply on. (ex: 'votemper:linear','vosaline:cubic' )
+ 
+   NAMELIST /namnst/ &  !< nesting namelist
+   &  in_rhoi,       &  !< refinement factor in i-direction
+   &  in_rhoj           !< refinement factor in j-direction
+
+   NAMELIST /nambdy/ &  !< boundary namelist
+   &  ln_north,      &  !< use north boundary
+   &  ln_south,      &  !< use south boundary
+   &  ln_east ,      &  !< use east  boundary
+   &  ln_west ,      &  !< use west  boundary
+   &  cn_north,      &  !< north boundary indices on fine grid
+   &  cn_south,      &  !< south boundary indices on fine grid
+   &  cn_east ,      &  !< east  boundary indices on fine grid
+   &  cn_west ,      &  !< west  boundary indices on fine grid
+   &  ln_oneseg         !< use only one segment for each boundary or not
+
+   NAMELIST /namout/ &  !< output namelist
+   &  cn_fileout,    &  !< fine grid boundary file basename   
+   &  dn_dayofs,     &  !< date offset in day (change only ouput file name)
+   &  ln_extrap         !< extrapolate or not
+   !-------------------------------------------------------------------
+
+   ! read namelist
+   INQUIRE(FILE=TRIM(cd_namelist), EXIST=ll_exist)
+
+   IF( ll_exist )THEN
+      
+      il_fileid=fct_getunit()
+
+      OPEN( il_fileid, FILE=TRIM(cd_namelist), &
+      &                FORM='FORMATTED',       &
+      &                ACCESS='SEQUENTIAL',    &
+      &                STATUS='OLD',           &
+      &                ACTION='READ',          &
+      &                IOSTAT=il_status)
+      CALL fct_err(il_status)
+      IF( il_status /= 0 )THEN
+         PRINT *,"CREATE BOUNDARY: ERROR opening "//TRIM(cd_namelist)
+         STOP
+      ENDIF
+
+      READ( il_fileid, NML = namlog )
+      ! define log file
+      CALL logger_open(TRIM(cn_logfile),TRIM(cn_verbosity),in_maxerror)
+      CALL logger_header()
+
+      READ( il_fileid, NML = namcfg )
+      ! get variable extra information
+      CALL var_def_extra(TRIM(cn_varcfg))
+
+      ! get dummy variable
+      CALL var_get_dummy(TRIM(cn_dumcfg))
+      ! get dummy dimension
+      CALL dim_get_dummy(TRIM(cn_dumcfg))
+      ! get dummy attribute
+      CALL att_get_dummy(TRIM(cn_dumcfg))
+
+      READ( il_fileid, NML = namcrs )
+      READ( il_fileid, NML = namfin )
+      READ( il_fileid, NML = namzgr )
+      READ( il_fileid, NML = namvar )
+      ! add user change in extra information
+      CALL var_chg_extra(cn_varinfo)
+      ! match variable with file
+      tl_multi=multi_init(cn_varfile)
+
+      READ( il_fileid, NML = namnst )
+      READ( il_fileid, NML = nambdy )
+      READ( il_fileid, NML = namout )
+
+      CLOSE( il_fileid, IOSTAT=il_status )
+      CALL fct_err(il_status)
+      IF( il_status /= 0 )THEN
+         CALL logger_error("CREATE BOUNDARY: ERROR closing "//TRIM(cd_namelist))
+      ENDIF
+
+   ELSE
+
+      PRINT *,"CREATE BOUNDARY: ERROR. can not find "//TRIM(cd_namelist)
+      STOP
+
+   ENDIF
+
+   CALL multi_print(tl_multi)
+   IF( tl_multi%i_nvar <= 0 )THEN
+      CALL logger_fatal("CREATE BOUNDARY: no variable to be used."//&
+      &  " check namelist.")
+   ENDIF
+
+   ! open files
+   IF( TRIM(cn_coord0) /= '' )THEN
+      tl_coord0=mpp_init( file_init(TRIM(cn_coord0)), id_perio=in_perio0)
+      CALL grid_get_info(tl_coord0)
+   ELSE
+      CALL logger_fatal("CREATE BOUNDARY: can not find coarse grid "//&
+      &  "coordinate file. check namelist")
+   ENDIF
+
+   IF( TRIM(cn_coord1) /= '' )THEN
+      tl_coord1=mpp_init( file_init(TRIM(cn_coord1)), id_perio=in_perio1)
+      CALL grid_get_info(tl_coord1)
+   ELSE
+      CALL logger_fatal("CREATE BOUNDARY: can not find fine grid coordinate "//&
+      &  "file. check namelist")
+   ENDIF
+
+   IF( TRIM(cn_bathy1) /= '' )THEN
+      tl_bathy1=mpp_init( file_init(TRIM(cn_bathy1)), id_perio=in_perio1)
+      CALL grid_get_info(tl_bathy1)
+   ELSE
+      CALL logger_fatal("CREATE BOUNDARY: can not find fine grid bathymetry "//&
+      &  "file. check namelist")
+   ENDIF
+
+   ! check
+   ! check output file do not already exist
+   ! WARNING: do not work when use time to create output file name
+   DO jk=1,ip_ncard
+      cl_bdyout=boundary_set_filename( TRIM(cn_fileout), &
+      &                                TRIM(cp_card(jk)), 1 )
+      INQUIRE(FILE=TRIM(cl_bdyout), EXIST=ll_exist)
+      IF( ll_exist )THEN
+         CALL logger_fatal("CREATE BOUNDARY: output file "//TRIM(cl_bdyout)//&
+         &  " already exist.")
+      ENDIF
+
+      cl_bdyout=boundary_set_filename( TRIM(cn_fileout), &
+      &                                TRIM(cp_card(jk)) )
+      INQUIRE(FILE=TRIM(cl_bdyout), EXIST=ll_exist)
+      IF( ll_exist )THEN
+         CALL logger_fatal("CREATE BOUNDARY: output file "//TRIM(cl_bdyout)//&
+         &  " already exist.")
+      ENDIF
+   ENDDO
+
+   ! check namelist
+   ! check refinement factor
+   il_rho(:)=1
+   IF( in_rhoi < 1 .OR. in_rhoj < 1 )THEN
+      CALL logger_error("CREATE BOUNDARY: invalid refinement factor."//&
+      &  " check namelist "//TRIM(cd_namelist))
+   ELSE
+      il_rho(jp_I)=in_rhoi
+      il_rho(jp_J)=in_rhoj
+   ENDIF
+
+   !
+   ! compute coarse grid indices around fine grid
+   il_ind(:,:)=grid_get_coarse_index(tl_coord0, tl_coord1, &
+   &                                 id_rho=il_rho(:))
+
+   il_imin0=il_ind(1,1) ; il_imax0=il_ind(1,2)
+   il_jmin0=il_ind(2,1) ; il_jmax0=il_ind(2,2)
+
+   ! check domain validity
+   CALL grid_check_dom(tl_coord0, il_imin0, il_imax0, il_jmin0, il_jmax0)
+
+   ! check coordinate file
+   CALL grid_check_coincidence( tl_coord0, tl_coord1, &
+   &                            il_imin0, il_imax0, &
+   &                            il_jmin0, il_jmax0, &
+   &                            il_rho(:) )      
+
+   ! read or compute boundary
+   CALL mpp_get_contour(tl_bathy1)
+
+   CALL iom_mpp_open(tl_bathy1)
+ 
+   tl_var1=iom_mpp_read_var(tl_bathy1,'Bathymetry')
+ 
+   CALL iom_mpp_close(tl_bathy1)
+
+   ! get boundaries indices
+   tl_bdy(:)=boundary_init(tl_var1, ln_north, ln_south, ln_east, ln_west, &
+   &                                cn_north, cn_south, cn_east, cn_west, &
+   &                                ln_oneseg ) 
+
+
+   CALL var_clean(tl_var1)
+
+   ! compute level
+   ALLOCATE(tl_level(ip_npoint))
+   tl_level(:)=vgrid_get_level(tl_bathy1, cd_namelist )
+
+   ! get coordinate for each segment of each boundary
+   ALLOCATE( tl_segdom1(ip_npoint,ip_maxseg,ip_ncard) )
+   ALLOCATE( tl_seglvl1(ip_npoint,ip_maxseg,ip_ncard) )
+ 
+   DO jl=1,ip_ncard
+      IF( tl_bdy(jl)%l_use )THEN
+         DO jk=1,tl_bdy(jl)%i_nseg
+
+            ! get fine grid segment domain
+            tl_segdom1(:,jk,jl)=create_boundary_get_dom( tl_bathy1, &
+            &                                            tl_bdy(jl), jk )
+
+            IF( .NOT. ln_extrap )THEN
+               ! get fine grid level
+               tl_seglvl1(:,jk,jl)= &
+                  & create_boundary_get_level( tl_level(:), &
+                  &                            tl_segdom1(:,jk,jl))
+            ENDIF
+
+            ! add extra band to fine grid domain (if possible)
+            ! to avoid dimension of one and so be able to compute offset
+            DO jj=1,ip_npoint
+               CALL dom_add_extra(tl_segdom1(jj,jk,jl), &
+               &                  il_rho(jp_I), il_rho(jp_J))
+            ENDDO
+
+         ENDDO
+      ENDIF
+   ENDDO
+
+   ! clean
+   CALL var_clean(tl_level(:))
+   DEALLOCATE(tl_level)
+
+   ! clean bathy
+   CALL mpp_clean(tl_bathy1)
+
+   ALLOCATE( tl_segvar1(tl_multi%i_nvar,ip_maxseg,ip_ncard) )
+   ! compute boundary for variable to be used (see namelist)
+   IF( .NOT. ASSOCIATED(tl_multi%t_mpp) )THEN
+      CALL logger_error("CREATE BOUNDARY: no file to work on. "//&
+      &                 "check cn_varfile in namelist.")
+   ELSE
+
+      jvar=0
+      ! for each file
+      DO ji=1,tl_multi%i_nmpp
+
+         WRITE(cl_data,'(a,i2.2)') 'data-',jvar+1
+
+         IF( .NOT. ASSOCIATED(tl_multi%t_mpp(ji)%t_proc(1)%t_var) )THEN
+
+            CALL logger_error("CREATE BOUNDARY: no variable to work on for "//&
+            &                 "mpp "//TRIM(tl_multi%t_mpp(ji)%c_name)//&
+            &                 ". check cn_varfile in namelist.")
+
+         ELSEIF( TRIM(tl_multi%t_mpp(ji)%c_name) == TRIM(cl_data) )THEN
+         !- use input matrix to fill variable
+
+            WRITE(*,'(a)') "work on data"
+            ! for each variable initialise from matrix
+            DO jj=1,tl_multi%t_mpp(ji)%t_proc(1)%i_nvar
+
+               jvar=jvar+1
+               WRITE(*,'(2x,a,a)') "work on variable "//&
+               &  TRIM(tl_multi%t_mpp(ji)%t_proc(1)%t_var(jj)%c_name)
+
+               tl_var1=var_copy(tl_multi%t_mpp(ji)%t_proc(1)%t_var(jj))
+
+               SELECT CASE(TRIM(tl_var1%c_point))
+               CASE DEFAULT !'T'
+                  jpoint=jp_T
+               CASE('U')
+                  jpoint=jp_U
+               CASE('V')
+                  jpoint=jp_V
+               CASE('F')
+                  jpoint=jp_F
+               END SELECT
+
+               WRITE(*,'(4x,a,a)') 'work on '//TRIM(tl_var1%c_name)
+               DO jl=1,ip_ncard
+                  IF( tl_bdy(jl)%l_use )THEN
+
+                     DO jk=1,tl_bdy(jl)%i_nseg
+
+                        ! fill value with matrix data
+                        tl_segvar1(jvar,jk,jl)=create_boundary_matrix( &
+                        &                          tl_var1, &
+                        &                          tl_segdom1(jpoint,jk,jl), &
+                        &                          in_nlevel )
+
+                        !del extra
+                        CALL dom_del_extra( tl_segvar1(jvar,jk,jl), &
+                        &                   tl_segdom1(jpoint,jk,jl) )
+
+                     ENDDO
+
+                  ENDIF
+               ENDDO
+               
+               ! clean
+               CALL var_clean(tl_var1)
+
+            ENDDO
+
+         !- end of use input matrix to fill variable
+         ELSE
+         !- use mpp file to fill variable
+
+            WRITE(*,'(a)') "work on file "//TRIM(tl_multi%t_mpp(ji)%c_name)
+            ! 
+            tl_mpp=mpp_init(file_init(TRIM(tl_multi%t_mpp(ji)%t_proc(1)%c_name)))
+            CALL grid_get_info(tl_mpp)
+
+            DO jl=1,ip_ncard
+               IF( tl_bdy(jl)%l_use )THEN
+
+                  WRITE(*,'(2x,a,a)') 'work on '//TRIM(tl_bdy(jl)%c_card)//&
+                     &  ' boundary'
+                  DO jk=1,tl_bdy(jl)%i_nseg
+
+                     ! for each variable of this file
+                     DO jj=1,tl_multi%t_mpp(ji)%t_proc(1)%i_nvar
+ 
+                        WRITE(*,'(4x,a,a)') "work on variable "//&
+                        &  TRIM(tl_multi%t_mpp(ji)%t_proc(1)%t_var(jj)%c_name)
+
+                        tl_var0=var_copy(tl_multi%t_mpp(ji)%t_proc(1)%t_var(jj))
+
+                        ! open mpp file
+                        CALL iom_mpp_open(tl_mpp)
+
+                        ! get or check depth value
+                        CALL create_boundary_check_depth( tl_var0, tl_mpp, &
+                        &                                 in_nlevel, tl_depth )
+
+                        ! get or check time value
+                        CALL create_boundary_check_time( tl_var0, tl_mpp, &
+                        &                                tl_time )
+
+                        ! close mpp file
+                        CALL iom_mpp_close(tl_mpp)
+
+                        ! open mpp file on domain
+                        SELECT CASE(TRIM(tl_var0%c_point))
+                           CASE DEFAULT !'T'
+                              jpoint=jp_T
+                           CASE('U')
+                              jpoint=jp_U
+                           CASE('V')
+                              jpoint=jp_V
+                           CASE('F')
+                              jpoint=jp_F
+                        END SELECT
+
+                        tl_dom1=dom_copy(tl_segdom1(jpoint,jk,jl))
+
+                        CALL create_boundary_get_coord( tl_coord1, tl_dom1, &
+                        &                               tl_var0%c_point,    &
+                        &                               tl_lon1, tl_lat1 )
+
+                        ! get coarse grid indices of this segment
+                        il_ind(:,:)=grid_get_coarse_index(tl_coord0, &
+                        &                                 tl_lon1, tl_lat1, &
+                        &                                 id_rho=il_rho(:) )
+
+                        IF( ANY(il_ind(:,:)==0) )THEN
+                           CALL logger_error("CREATE BOUNDARY: error "//&
+                           &  "computing coarse grid indices")
+                        ELSE
+                           il_imin0=il_ind(1,1)
+                           il_imax0=il_ind(1,2)
+
+                           il_jmin0=il_ind(2,1)
+                           il_jmax0=il_ind(2,2)
+                        ENDIF
+
+                        il_offset(:,:)= grid_get_fine_offset( &
+                        &                    tl_coord0, &
+                        &                    il_imin0, il_jmin0,&
+                        &                    il_imax0, il_jmax0,&
+                        &                    tl_lon1%d_value(:,:,1,1),&
+                        &                    tl_lat1%d_value(:,:,1,1),&
+                        &                    il_rho(:),&
+                        &                    TRIM(tl_var0%c_point) )
+
+                        ! compute coarse grid segment domain
+                        tl_dom0=dom_init( tl_coord0,         &
+                        &                 il_imin0, il_imax0,&
+                        &                 il_jmin0, il_jmax0 )
+
+                        ! add extra band (if possible) to compute interpolation
+                        CALL dom_add_extra(tl_dom0)
+
+                        ! open mpp files
+                        CALL iom_dom_open(tl_mpp, tl_dom0)
+
+                        cl_name=tl_var0%c_name
+                        ! read variable value on domain
+                        tl_segvar1(jvar+jj,jk,jl)= &
+                        &    iom_dom_read_var(tl_mpp, TRIM(cl_name), tl_dom0)
+
+                        IF( ANY(il_rho(:)/=1) )THEN
+                           WRITE(*,'(4x,a,a)') "interp variable "//TRIM(cl_name)
+                           ! work on variable
+                           CALL create_boundary_interp( &
+                           &                 tl_segvar1(jvar+jj,jk,jl),&
+                           &                 il_rho(:), il_offset(:,:) )
+                        ENDIF
+
+                        ! remove extraband added to domain
+                        CALL dom_del_extra( tl_segvar1(jvar+jj,jk,jl), &
+                        &                   tl_dom0, il_rho(:) )
+
+                        ! del extra point on fine grid
+                        CALL dom_del_extra( tl_segvar1(jvar+jj,jk,jl), &
+                        &                   tl_dom1 )
+                        ! clean extra point information on coarse grid domain
+                        CALL dom_clean_extra( tl_dom0 )
+
+                        ! add attribute to variable
+                        tl_att=att_init('src_file',&
+                        &  TRIM(fct_basename(tl_mpp%c_name)))
+                        CALL var_move_att(tl_segvar1(jvar+jj,jk,jl), &
+                        &                 tl_att)
+
+                        ! 
+                        tl_att=att_init('src_i_indices',&
+                        &  (/tl_dom0%i_imin, tl_dom0%i_imax/))
+                        CALL var_move_att(tl_segvar1(jvar+jj,jk,jl), &
+                        &                 tl_att)
+
+                        tl_att=att_init('src_j_indices', &
+                        &  (/tl_dom0%i_jmin, tl_dom0%i_jmax/))
+                        CALL var_move_att(tl_segvar1(jvar+jj,jk,jl), &
+                        &                 tl_att)
+
+                        IF( ANY(il_rho(:)/=1) )THEN
+                           tl_att=att_init("refinment_factor", &
+                           &               (/il_rho(jp_I),il_rho(jp_J)/))
+                           CALL var_move_att(tl_segvar1(jvar+jj,jk,jl), &
+                           &                 tl_att)
+                        ENDIF
+
+                        ! clean structure
+                        CALL att_clean(tl_att)
+
+                        ! clean
+                        CALL dom_clean(tl_dom0)
+                        CALL dom_clean(tl_dom1)
+
+                        ! close mpp files
+                        CALL iom_dom_close(tl_mpp)
+
+                        ! clean structure
+                        CALL var_clean(tl_lon1)
+                        CALL var_clean(tl_lat1)
+                        CALL var_clean(tl_lvl1)
+
+                     ENDDO ! jj
+
+                     ! clean
+                     CALL var_clean(tl_var0)
+
+                  ENDDO ! jk
+            
+               ENDIF
+            ENDDO ! jl
+
+            jvar=jvar+tl_multi%t_mpp(ji)%t_proc(1)%i_nvar
+
+            ! clean
+            CALL mpp_clean(tl_mpp)
+
+         !- end of use file to fill variable
+         ENDIF
+      ENDDO ! ji
+   ENDIF
+
+   IF( jvar /= tl_multi%i_nvar )THEN
+      CALL logger_error("CREATE BOUNDARY: it seems some variable "//&
+         &  "can not be read")
+   ENDIF
+
+   ! write file for each segment of each boundary
+   DO jl=1,ip_ncard
+      IF( tl_bdy(jl)%l_use )THEN
+
+         DO jk=1,tl_bdy(jl)%i_nseg
+            !- 
+            CALL create_boundary_get_coord( tl_coord1, tl_segdom1(jp_T,jk,jl),&
+            &                               'T', tl_lon1, tl_lat1 )
+
+            ! force to use nav_lon, nav_lat as variable name
+            tl_lon1%c_name='nav_lon'
+            tl_lat1%c_name='nav_lat'
+
+            ! del extra point on fine grid
+            CALL dom_del_extra( tl_lon1, tl_segdom1(jp_T,jk,jl) )
+            CALL dom_del_extra( tl_lat1, tl_segdom1(jp_T,jk,jl) )
+
+            ! clean
+            DO jpoint=1,ip_npoint
+               CALL dom_clean(tl_segdom1(jpoint,jk,jl))
+            ENDDO
+
+            ! swap array
+            CALL boundary_swap(tl_lon1, tl_bdy(jl))
+            CALL boundary_swap(tl_lat1, tl_bdy(jl))
+            DO jvar=1,tl_multi%i_nvar
+
+               ! use additional request
+               ! change unit and apply factor
+               CALL var_chg_unit(tl_segvar1(jvar,jk,jl))
+
+               ! forced min and max value
+               CALL var_limit_value(tl_segvar1(jvar,jk,jl))
+
+               ! filter
+               CALL filter_fill_value(tl_segvar1(jvar,jk,jl))
+
+               IF( .NOT. ln_extrap )THEN
+                  ! use mask
+                  SELECT CASE(TRIM(tl_segvar1(jvar,jk,jl)%c_point))
+                  CASE DEFAULT !'T'
+                     jpoint=jp_T
+                  CASE('U')
+                     jpoint=jp_U
+                  CASE('V')
+                     jpoint=jp_V
+                  CASE('F')
+                     jpoint=jp_F
+                  END SELECT
+
+                  CALL create_boundary_use_mask(tl_segvar1(jvar,jk,jl), &
+                  &                             tl_seglvl1(jpoint,jk,jl))
+               ENDIF
+
+               ! swap dimension order
+               CALL boundary_swap(tl_segvar1(jvar,jk,jl), tl_bdy(jl))
+
+            ENDDO
+
+            ! create file
+            ! create file structure
+            ! set file namearray of level variable structure
+            IF( tl_bdy(jl)%i_nseg > 1 )THEN
+               IF( ASSOCIATED(tl_time%d_value) )THEN
+                  cl_fmt="('y',i0.4,'m',i0.2,'d',i0.2)"
+                  tl_date=var_to_date(tl_time)
+                  tl_date=tl_date+dn_dayofs
+                  cl_date=date_print( tl_date, cl_fmt ) 
+
+                  cl_bdyout=boundary_set_filename( TRIM(cn_fileout), &
+                  &                                TRIM(tl_bdy(jl)%c_card), jk,&
+                  &                                cd_date=TRIM(cl_date) )
+               ELSE
+                  cl_bdyout=boundary_set_filename( TRIM(cn_fileout), &
+                  &                                TRIM(tl_bdy(jl)%c_card), jk )
+               ENDIF
+            ELSE
+               IF( ASSOCIATED(tl_time%d_value) )THEN
+                  cl_fmt="('y',i0.4,'m',i0.2,'d',i0.2)"
+                  tl_date=var_to_date(tl_time)
+                  tl_date=tl_date+dn_dayofs
+                  cl_date=date_print( tl_date, cl_fmt )
+
+                  cl_bdyout=boundary_set_filename( TRIM(cn_fileout), &
+                  &                                TRIM(tl_bdy(jl)%c_card), &
+                  &                                cd_date=TRIM(cl_date) )
+               ELSE
+                  cl_bdyout=boundary_set_filename( TRIM(cn_fileout), &
+                  &                                TRIM(tl_bdy(jl)%c_card) )
+               ENDIF
+            ENDIF
+            ! 
+            tl_fileout=file_init(TRIM(cl_bdyout),id_perio=in_perio1)
+
+            ! add dimension
+            tl_dim(:)=var_max_dim(tl_segvar1(:,jk,jl))
+
+            SELECT CASE(TRIM(tl_bdy(jl)%c_card))
+               CASE DEFAULT ! 'north','south'
+                  cl_dimorder='xyzt'
+               CASE('east','west')
+                  cl_dimorder='yxzt'
+            END SELECT
+
+            DO ji=1,ip_maxdim
+               IF( tl_dim(ji)%l_use ) CALL file_add_dim(tl_fileout, tl_dim(ji))
+            ENDDO
+
+            ! add variables
+            IF( ALL( tl_dim(1:2)%l_use ) )THEN
+               ! add longitude
+               CALL file_add_var(tl_fileout, tl_lon1)
+               CALL var_clean(tl_lon1)
+
+               ! add latitude
+               CALL file_add_var(tl_fileout, tl_lat1)
+               CALL var_clean(tl_lat1)
+            ENDIF
+            
+
+
+            IF( tl_dim(3)%l_use )THEN
+               IF( ASSOCIATED(tl_depth%d_value) )THEN
+                  ! add depth
+                  CALL file_add_var(tl_fileout, tl_depth)
+               ENDIF
+            ENDIF
+
+            IF( tl_dim(4)%l_use )THEN
+               IF( ASSOCIATED(tl_time%d_value) )THEN
+                  ! add time
+                  CALL file_add_var(tl_fileout, tl_time)
+               ENDIF
+            ENDIF
+
+            ! add other variable
+            DO jvar=tl_multi%i_nvar,1,-1
+               CALL file_add_var(tl_fileout, tl_segvar1(jvar,jk,jl))
+               CALL var_clean(tl_segvar1(jvar,jk,jl))
+            ENDDO
+
+            ! add some attribute
+            tl_att=att_init("Created_by","SIREN create_boundary")
+            CALL file_add_att(tl_fileout, tl_att)
+
+            cl_date=date_print(date_now())
+            tl_att=att_init("Creation_date",cl_date)
+            CALL file_add_att(tl_fileout, tl_att)
+
+            ! add shift on north and east boundary
+            ! boundary compute on T point but express on U or V point
+            SELECT CASE(TRIM(tl_bdy(jl)%c_card))
+            CASE DEFAULT ! 'south','west'
+               il_shift=0
+            CASE('north','east')
+               il_shift=1
+            END SELECT
+
+            ! add indice of velocity row or column
+            tl_att=att_init('bdy_ind',tl_bdy(jl)%t_seg(jk)%i_index-il_shift)
+            CALL file_move_att(tl_fileout, tl_att)
+
+            ! add width of the relaxation zone
+            tl_att=att_init('bdy_width',tl_bdy(jl)%t_seg(jk)%i_width)
+            CALL file_move_att(tl_fileout, tl_att)
+            
+            ! add indice of segment start 
+            tl_att=att_init('bdy_deb',tl_bdy(jl)%t_seg(jk)%i_first)
+            CALL file_move_att(tl_fileout, tl_att)
+            
+            ! add indice of segment end 
+            tl_att=att_init('bdy_end',tl_bdy(jl)%t_seg(jk)%i_last)
+            CALL file_move_att(tl_fileout, tl_att)
+                           
+            ! clean
+            CALL att_clean(tl_att)
+
+            ! create file
+            CALL iom_create(tl_fileout)
+
+            ! write file
+            CALL iom_write_file(tl_fileout, cl_dimorder)
+
+            ! close file
+            CALL iom_close(tl_fileout)
+            CALL file_clean(tl_fileout)
+
+         ENDDO ! jk
+
+      ENDIF
+      ! clean
+      CALL boundary_clean(tl_bdy(jl))
+   ENDDO !jl
+
+   ! clean
+   IF( ASSOCIATED(tl_depth%d_value) ) CALL var_clean(tl_depth)
+   IF( ASSOCIATED(tl_time%d_value) ) CALL var_clean(tl_time)
+   DEALLOCATE( tl_segdom1 )
+   DEALLOCATE( tl_segvar1 )
+   CALL var_clean(tl_seglvl1(:,:,:))
+   DEALLOCATE( tl_seglvl1 )
+
+
+   CALL mpp_clean(tl_coord1)
+   CALL mpp_clean(tl_coord0)
+
+   CALL multi_clean(tl_multi)
+
+   ! close log file
+   CALL logger_footer()
+   CALL logger_close()
+   CALL logger_clean()
+
+END SUBROUTINE create__boundary
+   !-------------------------------------------------------------------
+   !> @brief
+   !> This subroutine compute boundary domain for each grid point (T,U,V,F) 
+   !> 
+   !> @author J.Paul
+   !> @date November, 2013 - Initial Version
+   !> @date September, 2014
+   !> - take into account grid point to compute boundary indices
+   !>
+   !> @param[in] td_bathy1 file structure 
+   !> @param[in] td_bdy    boundary structure
+   !> @param[in] id_seg    segment indice 
+   !> @return array of domain structure 
+   !-------------------------------------------------------------------
+   FUNCTION create_boundary_get_dom( td_bathy1, td_bdy, id_seg )
+
+      IMPLICIT NONE
+
+      ! Argument
+      TYPE(TMPP) , INTENT(IN   ) :: td_bathy1
+      TYPE(TBDY) , INTENT(IN   ) :: td_bdy
+      INTEGER(i4), INTENT(IN   ) :: id_seg
+
+      ! function
+      TYPE(TDOM), DIMENSION(ip_npoint) :: create_boundary_get_dom
+
+      ! local variable
+      INTEGER(i4) :: il_imin1
+      INTEGER(i4) :: il_imax1
+      INTEGER(i4) :: il_jmin1
+      INTEGER(i4) :: il_jmax1
+
+      INTEGER(i4) :: il_imin
+      INTEGER(i4) :: il_imax
+      INTEGER(i4) :: il_jmin
+      INTEGER(i4) :: il_jmax
+
+      INTEGER(i4), DIMENSION(ip_npoint) :: il_ishift
+      INTEGER(i4), DIMENSION(ip_npoint) :: il_jshift
+
+      ! loop indices
+      INTEGER(i4) :: ji
+      INTEGER(i4) :: jk
+      !----------------------------------------------------------------
+      ! init
+      jk=id_seg
+
+      il_ishift(:)=0
+      il_jshift(:)=0
+
+      ! get boundary definition
+      SELECT CASE(TRIM(td_bdy%c_card))
+         CASE('north')
+
+            il_imin1=td_bdy%t_seg(jk)%i_first
+            il_imax1=td_bdy%t_seg(jk)%i_last 
+            il_jmin1=td_bdy%t_seg(jk)%i_index-(td_bdy%t_seg(jk)%i_width-1)
+            il_jmax1=td_bdy%t_seg(jk)%i_index
+
+            il_jshift(jp_V)=-1
+            il_jshift(jp_F)=-1
+
+         CASE('south')
+
+            il_imin1=td_bdy%t_seg(jk)%i_first
+            il_imax1=td_bdy%t_seg(jk)%i_last 
+            il_jmin1=td_bdy%t_seg(jk)%i_index
+            il_jmax1=td_bdy%t_seg(jk)%i_index+(td_bdy%t_seg(jk)%i_width-1)
+
+         CASE('east')
+
+            il_imin1=td_bdy%t_seg(jk)%i_index-(td_bdy%t_seg(jk)%i_width-1)
+            il_imax1=td_bdy%t_seg(jk)%i_index
+            il_jmin1=td_bdy%t_seg(jk)%i_first
+            il_jmax1=td_bdy%t_seg(jk)%i_last 
+
+            il_ishift(jp_U)=-1
+            il_ishift(jp_F)=-1
+
+         CASE('west')
+
+            il_imin1=td_bdy%t_seg(jk)%i_index
+            il_imax1=td_bdy%t_seg(jk)%i_index+(td_bdy%t_seg(jk)%i_width-1)
+            il_jmin1=td_bdy%t_seg(jk)%i_first
+            il_jmax1=td_bdy%t_seg(jk)%i_last 
+
+      END SELECT         
+
+      !-read fine grid domain
+      DO ji=1,ip_npoint
+
+         ! shift domain
+         il_imin=il_imin1+il_ishift(ji)
+         il_imax=il_imax1+il_ishift(ji)
+
+         il_jmin=il_jmin1+il_jshift(ji)
+         il_jmax=il_jmax1+il_jshift(ji)
+
+         ! compute domain
+         create_boundary_get_dom(ji)=dom_init( td_bathy1,       &
+         &                                     il_imin, il_imax,&
+         &                                     il_jmin, il_jmax,&
+         &                                     TRIM(td_bdy%c_card) )
+
+      ENDDO
+
+   END FUNCTION create_boundary_get_dom
+   !-------------------------------------------------------------------
+   !> @brief
+   !> This subroutine get coordinates over boundary domain
+   !> 
+   !> @author J.Paul
+   !> @date November, 2013 - Initial Version
+   !> @date September, 2014 
+   !> - take into account grid point
+   !>
+   !> @param[in] td_coord1 coordinates file structure
+   !> @param[in] td_dom1   boundary domain structure
+   !> @param[in] cd_point  grid point
+   !> @param[out] td_lon1  longitude variable structure
+   !> @param[out] td_lat1  latitude variable structure
+   !-------------------------------------------------------------------
+   SUBROUTINE create_boundary_get_coord( td_coord1, td_dom1, cd_point, &
+   &                                     td_lon1, td_lat1 )
+
+      IMPLICIT NONE
+      ! Argument
+      TYPE(TMPP)      , INTENT(IN   ) :: td_coord1
+      TYPE(TDOM)      , INTENT(IN   ) :: td_dom1
+      CHARACTER(LEN=*), INTENT(IN   ) :: cd_point
+      TYPE(TVAR)      , INTENT(  OUT) :: td_lon1
+      TYPE(TVAR)      , INTENT(  OUT) :: td_lat1 
+
+      ! local variable
+      TYPE(TMPP)        :: tl_coord1
+      
+      CHARACTER(LEN=lc) :: cl_name
+      ! loop indices
+      !----------------------------------------------------------------
+      !read variables on domain (ugly way to do it, have to work on it)
+      ! init mpp structure
+      tl_coord1=mpp_copy(td_coord1)
+      
+      ! open mpp files
+      CALL iom_dom_open(tl_coord1, td_dom1)
+
+      ! read variable value on domain
+      WRITE(cl_name,*) 'longitude_'//TRIM(cd_point)
+      td_lon1=iom_dom_read_var( tl_coord1, TRIM(cl_name), td_dom1)
+      WRITE(cl_name,*) 'latitude_'//TRIM(cd_point)
+      td_lat1=iom_dom_read_var( tl_coord1, TRIM(cl_name), td_dom1)
+
+      ! close mpp files
+      CALL iom_dom_close(tl_coord1)
+
+      ! clean structure
+      CALL mpp_clean(tl_coord1)
+
+   END SUBROUTINE create_boundary_get_coord
+   !-------------------------------------------------------------------
+   !> @brief
+   !> This subroutine interpolate variable on boundary
+   !> 
+   !> @details 
+   !>
+   !> @author J.Paul
+   !> @date November, 2013 - Initial Version
+   !>
+   !> @param[inout] td_var variable structure 
+   !> @param[in] id_rho    array of refinment factor
+   !> @param[in] id_offset array of offset between fine and coarse grid
+   !> @param[in] id_iext   i-direction size of extra bands (default=im_minext)
+   !> @param[in] id_jext   j-direction size of extra bands (default=im_minext)
+   !-------------------------------------------------------------------
+   SUBROUTINE create_boundary_interp( td_var,           &
+   &                                  id_rho,           &
+   &                                  id_offset,        &
+   &                                  id_iext, id_jext )
+
+      IMPLICIT NONE
+
+      ! Argument
+      TYPE(TVAR) ,                 INTENT(INOUT) :: td_var
+      INTEGER(I4), DIMENSION(:)  , INTENT(IN   ) :: id_rho
+      INTEGER(i4), DIMENSION(:,:), INTENT(IN   ) :: id_offset
+
+      INTEGER(i4),                 INTENT(IN   ), OPTIONAL :: id_iext
+      INTEGER(i4),                 INTENT(IN   ), OPTIONAL :: id_jext
+
+
+      ! local variable
+      INTEGER(i4) :: il_iext
+      INTEGER(i4) :: il_jext
+      ! loop indices
+      !----------------------------------------------------------------
+
+      !WARNING: at least two extrabands are required for cubic interpolation
+      il_iext=2
+      IF( PRESENT(id_iext) ) il_iext=id_iext
+
+      il_jext=2
+      IF( PRESENT(id_jext) ) il_jext=id_jext
+
+      IF( il_iext < 2 .AND. td_var%c_interp(1) == 'cubic' )THEN
+         CALL logger_warn("CREATE BOUNDARY INTERP: at least extrapolation "//&
+         &  "on two points are required with cubic interpolation ")
+         il_iext=2
+      ENDIF
+
+      IF( il_jext < 2 .AND. td_var%c_interp(1) == 'cubic' )THEN
+         CALL logger_warn("CREATE BOUNDARY INTERP: at least extrapolation "//&
+         &  "on two points are required with cubic interpolation ")
+         il_jext=2
+      ENDIF
+
+      ! work on variable
+      ! add extraband
+      CALL extrap_add_extrabands(td_var, il_iext, il_jext)
+
+      ! extrapolate variable
+      CALL extrap_fill_value( td_var )
+
+      ! interpolate Bathymetry
+      CALL interp_fill_value( td_var, id_rho(:), &
+      &                       id_offset=id_offset(:,:) )
+
+      ! remove extraband
+      CALL extrap_del_extrabands(td_var, il_iext*id_rho(jp_I), &
+         &                               il_jext*id_rho(jp_J))
+
+   END SUBROUTINE create_boundary_interp
+   !-------------------------------------------------------------------
+   !> @brief
+   !> This function create variable, filled with matrix value
+   !> 
+   !> @details 
+   !> A variable is create with the same name that the input variable, 
+   !> and with dimension of the coordinate file. 
+   !> Then the variable array of value is split into equal subdomain.
+   !> Each subdomain is fill with the associated value of the matrix.
+   !>
+   !> @author J.Paul
+   !> @date November, 2013 - Initial Version
+   !>
+   !> @param[in] td_var    variable structure 
+   !> @param[in] td_dom    domain structure 
+   !> @param[in] id_nlevel number of levels 
+   !> @return variable structure 
+   !-------------------------------------------------------------------
+   FUNCTION create_boundary_matrix(td_var, td_dom, id_nlevel)
+      IMPLICIT NONE
+      ! Argument
+      TYPE(TVAR) , INTENT(IN) :: td_var
+      TYPE(TDOM) , INTENT(IN) :: td_dom
+      INTEGER(i4), INTENT(IN) :: id_nlevel
+
+      ! function
+      TYPE(TVAR) :: create_boundary_matrix
+
+      ! local variable
+      INTEGER(i4)      , DIMENSION(3)                    :: il_dim
+      INTEGER(i4)      , DIMENSION(3)                    :: il_size
+      INTEGER(i4)      , DIMENSION(3)                    :: il_rest
+
+      INTEGER(i4)      , DIMENSION(:)      , ALLOCATABLE :: il_ishape
+      INTEGER(i4)      , DIMENSION(:)      , ALLOCATABLE :: il_jshape
+      INTEGER(i4)      , DIMENSION(:)      , ALLOCATABLE :: il_kshape
+
+      REAL(dp)         , DIMENSION(:,:,:,:), ALLOCATABLE :: dl_value
+
+      TYPE(TDIM)       , DIMENSION(ip_maxdim)            :: tl_dim
+
+      ! loop indices
+      INTEGER(i4) :: ji
+      INTEGER(i4) :: jj
+      INTEGER(i4) :: jk
+      !----------------------------------------------------------------
+
+      ! write value on grid
+      ! get matrix dimension
+      il_dim(:)=td_var%t_dim(1:3)%i_len
+
+      tl_dim(jp_I:jp_J)=dim_copy(td_dom%t_dim(jp_I:jp_J))
+      tl_dim(jp_K)%i_len=id_nlevel
+
+      ! split output domain in N subdomain depending of matrix dimension 
+      il_size(:) = tl_dim(1:3)%i_len / il_dim(:)
+      il_rest(:) = MOD(tl_dim(1:3)%i_len, il_dim(:))
+
+      ALLOCATE( il_ishape(il_dim(1)+1) )
+      il_ishape(:)=0
+      DO ji=2,il_dim(1)+1
+         il_ishape(ji)=il_ishape(ji-1)+il_size(1)
+      ENDDO
+      ! add rest to last cell
+      il_ishape(il_dim(1)+1)=il_ishape(il_dim(1)+1)+il_rest(1)
+      
+      ALLOCATE( il_jshape(il_dim(2)+1) )
+      il_jshape(:)=0
+      DO jj=2,il_dim(2)+1
+         il_jshape(jj)=il_jshape(jj-1)+il_size(2)
+      ENDDO
+      ! add rest to last cell
+      il_jshape(il_dim(2)+1)=il_jshape(il_dim(2)+1)+il_rest(2)
+
+      ALLOCATE( il_kshape(il_dim(3)+1) )
+      il_kshape(:)=0
+      DO jk=2,il_dim(3)+1
+         il_kshape(jk)=il_kshape(jk-1)+il_size(3)
+      ENDDO
+      ! add rest to last cell
+      il_kshape(il_dim(3)+1)=il_kshape(il_dim(3)+1)+il_rest(3)
+
+      ! write ouput array of value 
+      ALLOCATE(dl_value( tl_dim(1)%i_len, &
+      &                  tl_dim(2)%i_len, &
+      &                  tl_dim(3)%i_len, &
+      &                  tl_dim(4)%i_len) )
+
+      dl_value(:,:,:,:)=0
+
+      DO jk=2,il_dim(3)+1
+         DO jj=2,il_dim(2)+1
+            DO ji=2,il_dim(1)+1
+               
+               dl_value( 1+il_ishape(ji-1):il_ishape(ji), &
+               &         1+il_jshape(jj-1):il_jshape(jj), &
+               &         1+il_kshape(jk-1):il_kshape(jk), &
+               &         1 ) = td_var%d_value(ji-1,jj-1,jk-1,1)
+
+            ENDDO
+         ENDDO
+      ENDDO
+
+      ! initialise variable with value
+      create_boundary_matrix=var_init(TRIM(td_var%c_name),dl_value(:,:,:,:))
+
+      DEALLOCATE(dl_value)
+
+   END FUNCTION create_boundary_matrix
+   !-------------------------------------------------------------------
+   !> @brief
+   !> This subroutine use mask to filled land point with _FillValue
+   !> 
+   !> @details 
+   !>
+   !> @author J.Paul
+   !> @date November, 2013 - Initial Version
+   !>
+   !> @param[inout] td_var variable structure 
+   !> @param[in] td_mask   mask variable structure
+   !-------------------------------------------------------------------
+   SUBROUTINE create_boundary_use_mask( td_var, td_mask )
+
+      IMPLICIT NONE
+
+      ! Argument
+      TYPE(TVAR), INTENT(INOUT) :: td_var
+      TYPE(TVAR), INTENT(IN   ) :: td_mask
+
+      ! local variable
+      INTEGER(i4), DIMENSION(:,:), ALLOCATABLE :: il_mask
+
+      ! loop indices
+      INTEGER(i4) :: jk
+      INTEGER(i4) :: jl
+      !----------------------------------------------------------------
+
+      IF( ANY(td_var%t_dim(1:2)%i_len /= &
+      &       td_mask%t_dim(1:2)%i_len) )THEN
+         CALL logger_debug("     mask dimension ( "//&
+         &              TRIM(fct_str(td_mask%t_dim(1)%i_len))//","//&
+         &              TRIM(fct_str(td_mask%t_dim(2)%i_len))//")" )
+         CALL logger_debug(" variable dimension ( "//&
+         &              TRIM(fct_str(td_var%t_dim(1)%i_len))//","//&
+         &              TRIM(fct_str(td_var%t_dim(2)%i_len))//")" )
+         CALL logger_fatal("CREATE BOUNDARY USE MASK: mask and "//&
+         &                 "variable dimension differ."   )
+      ENDIF
+
+      ALLOCATE( il_mask(td_var%t_dim(1)%i_len, &
+      &                 td_var%t_dim(2)%i_len) )
+
+      il_mask(:,:)=INT(td_mask%d_value(:,:,1,1))
+
+      DO jl=1,td_var%t_dim(4)%i_len
+         DO jk=1,td_var%t_dim(3)%i_len
+            WHERE( il_mask(:,:) < jk ) td_var%d_value(:,:,jk,jl)=td_var%d_fill
+         ENDDO
+      ENDDO
+
+      DEALLOCATE( il_mask )
+
+   END SUBROUTINE create_boundary_use_mask
+   !-------------------------------------------------------------------
+   !> @brief
+   !> This function extract level over domain on each grid point, and return
+   !> array of variable structure
+   !>
+   !> @author J.Paul
+   !> @date November, 2013 - Initial Version
+   !>
+   !> @param[in] td_level  array of level variable structure
+   !> @param[in] td_dom    array of domain structure
+   !> @return array of variable structure
+   !-------------------------------------------------------------------
+   FUNCTION create_boundary_get_level(td_level, td_dom)
+      IMPLICIT NONE
+      ! Argument
+      TYPE(TVAR), DIMENSION(:), INTENT(IN) :: td_level
+      TYPE(TDOM), DIMENSION(:), INTENT(IN) :: td_dom
+
+      ! function
+      TYPE(TVAR), DIMENSION(ip_npoint) :: create_boundary_get_level
+
+      ! local variable
+      TYPE(TVAR), DIMENSION(ip_npoint) :: tl_var
+
+      ! loop indices
+      INTEGER(i4) :: ji
+      !----------------------------------------------------------------
+
+      IF( SIZE(td_level(:)) /= ip_npoint .OR. &
+      &   SIZE(td_dom(:)) /= ip_npoint )THEN
+         CALL logger_error("CREATE BDY GET LEVEL: invalid dimension. "//&
+         &  "check input array of level and domain.")
+      ELSE
+
+         DO ji=1,ip_npoint
+
+            tl_var(ji)=var_copy(td_level(ji))
+
+            IF( ASSOCIATED(tl_var(ji)%d_value) ) DEALLOCATE(tl_var(ji)%d_value)
+
+            tl_var(ji)%t_dim(1)%i_len=td_dom(ji)%t_dim(1)%i_len
+            tl_var(ji)%t_dim(2)%i_len=td_dom(ji)%t_dim(2)%i_len
+            ALLOCATE(tl_var(ji)%d_value(tl_var(ji)%t_dim(1)%i_len, &
+            &                           tl_var(ji)%t_dim(2)%i_len, &
+            &                           tl_var(ji)%t_dim(3)%i_len, &
+            &                           tl_var(ji)%t_dim(4)%i_len) )
+
+            tl_var(ji)%d_value(:,:,:,:) = &
+            &  td_level(ji)%d_value( td_dom(ji)%i_imin:td_dom(ji)%i_imax, &
+            &                        td_dom(ji)%i_jmin:td_dom(ji)%i_jmax, :, : )
+
+         ENDDO
+         ! save result
+         create_boundary_get_level(:)=var_copy(tl_var(:))
+
+         ! clean
+         CALL var_clean(tl_var(:))
+
+      ENDIF
+   END FUNCTION create_boundary_get_level
+   !-------------------------------------------------------------------
+   !> @brief
+   !> This subroutine check if variable need depth dimension, 
+   !> get depth variable value in an open mpp structure
+   !> and check if agree with already input depth variable.
+   !> 
+   !> @details 
+   !>
+   !> @author J.Paul
+   !> @date November, 2014 - Initial Version
+   !> @date January, 2016
+   !> - check if variable need/use depth dimension
+   !>
+   !> @param[in] td_var       variable structure
+   !> @param[in] td_mpp       mpp structure
+   !> @param[in] id_nlevel    mpp structure
+   !> @param[inout] td_depth  depth variable structure 
+   !-------------------------------------------------------------------
+   SUBROUTINE create_boundary_check_depth( td_var, td_mpp, id_nlevel, td_depth )
+
+      IMPLICIT NONE
+
+      ! Argument
+      TYPE(TVAR) , INTENT(IN   ) :: td_var
+      TYPE(TMPP) , INTENT(IN   ) :: td_mpp
+      INTEGER(i4), INTENT(IN   ) :: id_nlevel
+      TYPE(TVAR) , INTENT(INOUT) :: td_depth
+
+      ! local variable
+      INTEGER(i4) :: il_varid
+      TYPE(TVAR)  :: tl_depth
+      ! loop indices
+      !----------------------------------------------------------------
+
+      IF( td_var%t_dim(jp_K)%l_use .AND. &
+      &   ( TRIM(td_var%c_axis) == '' .OR. &
+      &     INDEX(TRIM(td_var%c_axis),'Z') /= 0 )&
+      & )THEN
+
+         ! check vertical dimension
+         IF( td_mpp%t_dim(jp_K)%l_use )THEN
+            IF( td_mpp%t_dim(jp_K)%i_len /= id_nlevel .AND. &
+              & td_mpp%t_dim(jp_K)%i_len /= 1 )THEN
+               CALL logger_error("CREATE BOUNDARY: dimension in file "//&
+               &  TRIM(td_mpp%c_name)//" not agree with namelist in_nlevel ")
+            ENDIF
+         ENDIF
+
+         ! get or check depth value
+         IF( td_mpp%t_proc(1)%i_depthid /= 0 )THEN
+
+            il_varid=td_mpp%t_proc(1)%i_depthid
+            IF( ASSOCIATED(td_depth%d_value) )THEN
+
+               tl_depth=iom_mpp_read_var(td_mpp, il_varid)
+
+               IF( ANY( td_depth%d_value(:,:,:,:) /= &
+               &        tl_depth%d_value(:,:,:,:) ) )THEN
+
+                  CALL logger_error("CREATE BOUNDARY: depth value "//&
+                  &  "for variable "//TRIM(td_var%c_name)//&
+                  &  "from "//TRIM(td_mpp%c_name)//" not conform "//&
+                  &  " to those from former file(s).")
+
+               ENDIF
+               CALL var_clean(tl_depth)
+
+            ELSE
+               td_depth=iom_mpp_read_var(td_mpp,il_varid)
+            ENDIF
+
+         ENDIF
+      ELSE
+         CALL logger_debug("CREATE BOUNDARY: no depth dimension use"//&
+         &                 " for variable "//TRIM(td_var%c_name))
+      ENDIF
+      
+   END SUBROUTINE create_boundary_check_depth
+   !-------------------------------------------------------------------
+   !> @brief
+   !> This subroutine check if variable need time dimension, 
+   !> get date and time in an open mpp structure
+   !> and check if agree with date and time already read.
+   !> 
+   !> @details 
+   !>
+   !> @author J.Paul
+   !> @date November, 2014 - Initial Version
+   !> @date January, 2016
+   !> - check if variable need/use time dimension
+   !>
+   !> @param[in] td_var       variable structure
+   !> @param[in] td_mpp      mpp structure
+   !> @param[inout] td_time  time variable structure 
+   !-------------------------------------------------------------------
+   SUBROUTINE create_boundary_check_time( td_var, td_mpp, td_time )
+
+      IMPLICIT NONE
+
+      ! Argument
+      TYPE(TVAR), INTENT(IN   ) :: td_var
+      TYPE(TMPP), INTENT(IN   ) :: td_mpp
+      TYPE(TVAR), INTENT(INOUT) :: td_time
+
+      ! local variable
+      INTEGER(i4) :: il_varid
+      TYPE(TVAR)  :: tl_time
+
+      TYPE(TDATE) :: tl_date1
+      TYPE(TDATE) :: tl_date2
+      ! loop indices
+      !----------------------------------------------------------------
+      IF( td_var%t_dim(jp_L)%l_use .AND. &
+      &   ( TRIM(td_var%c_axis) == '' .OR. &
+      &     INDEX(TRIM(td_var%c_axis),'T') /= 0 )&
+      & )THEN
+
+         ! get or check depth value
+         IF( td_mpp%t_proc(1)%i_timeid /= 0 )THEN
+
+            il_varid=td_mpp%t_proc(1)%i_timeid
+            IF( ASSOCIATED(td_time%d_value) )THEN
+
+               tl_time=iom_mpp_read_var(td_mpp, il_varid)
+
+               tl_date1=var_to_date(td_time)
+               tl_date2=var_to_date(tl_time)
+               IF( tl_date1 - tl_date2 /= 0 )THEN
+
+                  CALL logger_warn("CREATE BOUNDARY: date from "//&
+                  &  TRIM(td_mpp%c_name)//" not conform "//&
+                  &  " to those from former file(s).")
+
+               ENDIF
+               CALL var_clean(tl_time)
+
+            ELSE
+               td_time=iom_mpp_read_var(td_mpp,il_varid)
+            ENDIF
+
+         ENDIF
+
+      ELSE
+         CALL logger_debug("CREATE BOUNDARY: no time dimension use"//&
+         &                 " for variable "//TRIM(td_var%c_name))
+      ENDIF
+
+   END SUBROUTINE create_boundary_check_time
+END PROGRAM create_boundary
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/create_boundary.f90
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/create_boundary.f90	(revision 6384)
+++ 	(revision )
@@ -1,1728 +1,0 @@
-!----------------------------------------------------------------------
-! NEMO system team, System and Interface for oceanic RElocable Nesting
-!----------------------------------------------------------------------
-!
-!
-! PROGRAM: create_boundary
-!
-! DESCRIPTION:
-!> @file
-!> @brief 
-!> This program create boundary files.
-!>
-!> @details
-!> @section sec1 method
-!> Variables are read from coarse grid standard output 
-!> and interpolated on fine grid or manually written.<br/>
-!> @note 
-!>    method could be different for each variable.
-!>
-!> @section sec2 how to 
-!>    to create boundaries files:<br/>
-!> @code{.sh}
-!>    ./SIREN/bin/create_boundary create_boundary.nam
-!> @endcode
-!>  <br/> 
-!> \image html  boundary_NEATL36_70.png 
-!> \image latex boundary_NEATL36_70.png
-!>
-!> @note 
-!>    you could find a template of the namelist in templates directory.
-!>
-!>    create_boundary.nam comprise 9 namelists:<br/>
-!>       - logger namelist (namlog)
-!>       - config namelist (namcfg)
-!>       - coarse grid namelist (namcrs)
-!>       - fine grid namelist (namfin)
-!>       - variable namelist (namvar)
-!>       - nesting namelist (namnst)
-!>       - boundary namelist (nambdy)
-!>       - vertical grid namelist (namzgr)
-!>       - output namelist (namout)
-!>    
-!>    @note 
-!>       All namelists have to be in file create_boundary.nam, 
-!>       however variables of those namelists are all optional.
-!>
-!>    * _logger namelist (namlog)_:<br/>
-!>       - cn_logfile   : log filename
-!>       - cn_verbosity : verbosity ('trace','debug','info',
-!> 'warning','error','fatal','none')
-!>       - in_maxerror  : maximum number of error allowed
-!>
-!>    * _config namelist (namcfg)_:<br/>
-!>       - cn_varcfg : variable configuration file
-!> (see ./SIREN/cfg/variable.cfg)
-!>
-!>    * _coarse grid namelist (namcrs)_:<br/>
-!>       - cn_coord0 : coordinate file
-!>       - in_perio0 : NEMO periodicity index (see Model Boundary Condition in
-!> [NEMO documentation](http://www.nemo-ocean.eu/About-NEMO/Reference-manuals))
-!>
-!>    * _fine grid namelist (namfin)_:<br/>
-!>       - cn_coord1 : coordinate file
-!>       - cn_bathy1 : bathymetry file
-!>       - in_perio1 : periodicity index
-!>
-!>    * _vertical grid namelist (namzgr)_:<br/>
-!>       - dn_pp_to_be_computed  :
-!>       - dn_ppsur              :
-!>       - dn_ppa0               :
-!>       - dn_ppa1               :
-!>       - dn_ppa2               : 
-!>       - dn_ppkth              :
-!>       - dn_ppkth2             :
-!>       - dn_ppacr              :
-!>       - dn_ppacr2             :
-!>       - dn_ppdzmin            :
-!>       - dn_pphmax             :
-!>       - in_nlevel             : number of vertical level
-!>
-!>    * _partial step namelist (namzps)_:<br/>
-!>       - dn_e3zps_mi           :
-!>       - dn_e3zps_rat          : 
-!>
-!>    * _variable namelist (namvar)_:<br/>
-!>       - cn_varinfo : list of variable and extra information about request(s)
-!>          to be used (separated by ',').<br/>
-!>          each elements of *cn_varinfo* is a string character.<br/>
-!>          it is composed of the variable name follow by ':', 
-!>          then request(s) to be used on this variable.<br/> 
-!>          request could be:
-!>             - int = interpolation method
-!>             - ext = extrapolation method
-!>             - flt = filter method
-!>             - unt = new units
-!>             - unf = unit scale factor (linked to new units)
-!>
-!>                requests must be separated by ';'.<br/>
-!>                order of requests does not matter.
-!>
-!>          informations about available method could be find in @ref interp,
-!>          @ref extrap and @ref filter.<br/>
-!>
-!>          Example: 'votemper:int=linear;flt=hann;ext=dist_weight', 'vosaline:int=cubic'
-!>          @note 
-!>             If you do not specify a method which is required, 
-!>             default one is apply.
-!>       - cn_varfile : list of variable, and corresponding file<br/> 
-!>          *cn_varfile* is the path and filename of the file where find
-!>          variable.<br/> 
-!>          @note 
-!>             *cn_varfile* could be a matrix of value, if you want to filled
-!>             manually variable value.<br/>
-!>             the variable array of value is split into equal subdomain.<br/>
-!>             Each subdomain is filled with the corresponding value 
-!>             of the matrix.<br/>          
-!>             separators used to defined matrix are:
-!>                - ',' for line
-!>                - '/' for row
-!>                - '\' for level<br/>
-!>                Example:<br/>
-!>                   3,2,3/1,4,5  =>  @f$ \left( \begin{array}{ccc}
-!>                                         3 & 2 & 3 \\
-!>                                         1 & 4 & 5 \end{array} \right) @f$
-!>          @warning 
-!>             the same matrix is used for all boundaries.
-!>
-!>       Examples: 
-!>          - 'votemper:gridT.nc', 'vozocrtx:gridU.nc'
-!>          - 'votemper:10\25', 'vozocrtx:gridU.nc'
-!>
-!>    * _nesting namelist (namnst)_:<br/>
-!>       - in_rhoi  : refinement factor in i-direction
-!>       - in_rhoj  : refinement factor in j-direction
-!>
-!>    * _boundary namelist (nambdy)_:<br/>
-!>       - ln_north  : use north boundary
-!>       - ln_south  : use south boundary
-!>       - ln_east   : use east  boundary
-!>       - ln_west   : use west  boundary
-!>       - cn_north  : north boundary indices on fine grid
-!>          *cn_north* is a string character defining boundary
-!>          segmentation.<br/>
-!>          segments are separated by '|'.<br/>
-!>          each segments of the boundary is composed of:
-!>             - indice of velocity (orthogonal to boundary .ie. 
-!>                for north boundary, J-indice). 
-!>             - indice of segemnt start (I-indice for north boundary) 
-!>             - indice of segment end   (I-indice for north boundary)<br/>
-!>                indices must be separated by ':' .<br/>
-!>             - optionally, boundary size could be added between '(' and ')' 
-!>             in the first segment defined.
-!>                @note 
-!>                   boundary width is the same for all segments of one boundary.
-!>
-!>          Examples:
-!>             - cn_north='index1,first1:last1(width)'
-!>             - cn_north='index1(width),first1:last1|index2,first2:last2'
-!>             \image html  boundary_50.png 
-!>             \image latex boundary_50.png
-!>       - cn_south  : south boundary indices on fine grid
-!>       - cn_east   : east  boundary indices on fine grid
-!>       - cn_west   : west  boundary indices on fine grid
-!>       - ln_oneseg : use only one segment for each boundary or not
-!>
-!>    * _output namelist (namout)_:<br/>
-!>       - cn_fileout : fine grid boundary basename
-!>         (cardinal and segment number will be automatically added)
-!>       - dn_dayofs  : date offset in day (change only ouput file name)
-!>       - ln_extrap  : extrapolate land point or not
-!>
-!>          Examples: 
-!>             - cn_fileout=boundary.nc<br/>
-!>                if time_counter (16/07/2015 00h) is read on input file (see varfile), 
-!>                west boundary will be named boundary_west_y2015m07d16
-!>             - dn_dayofs=-2.<br/>
-!>                if you use day offset you get boundary_west_y2015m07d14
-!>       
-!>
-!> @author J.Paul
-! REVISION HISTORY:
-!> @date November, 2013 - Initial Version
-!> @date September, 2014
-!> - add header for user
-!> - take into account grid point to compue boundaries
-!> - reorder output dimension for north and south boundaries
-!> @date June, 2015
-!> - extrapolate all land points, and add ln_extrap in namelist.
-!> - allow to change unit.
-!> @date July, 2015
-!> - add namelist parameter to shift date of output file name.  
-!>
-!> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
-!----------------------------------------------------------------------
-PROGRAM create_boundary
-
-   USE netcdf                          ! nf90 library
-   USE global                          ! global variable
-   USE phycst                          ! physical constant
-   USE kind                            ! F90 kind parameter
-   USE logger                          ! log file manager
-   USE fct                             ! basic useful function
-   USE date                            ! date manager
-   USE att                             ! attribute manager
-   USE dim                             ! dimension manager
-   USE var                             ! variable manager
-   USE file                            ! file manager
-   USE multi                           ! multi file manager
-   USE boundary                        ! boundary manager
-   USE iom                             ! I/O manager
-   USE dom                             ! domain manager
-   USE grid                            ! grid manager
-   USE vgrid                           ! vertical grid manager
-   USE extrap                          ! extrapolation manager
-   USE interp                          ! interpolation manager
-   USE filter                          ! filter manager
-   USE mpp                             ! MPP manager
-   USE iom_mpp                         ! MPP I/O manager
-
-   IMPLICIT NONE
-
-   ! local variable
-   CHARACTER(LEN=lc)                                  :: cl_namelist
-   CHARACTER(LEN=lc)                                  :: cl_date
-   CHARACTER(LEN=lc)                                  :: cl_name
-   CHARACTER(LEN=lc)                                  :: cl_bdyout
-   CHARACTER(LEN=lc)                                  :: cl_data
-   CHARACTER(LEN=lc)                                  :: cl_dimorder
-   CHARACTER(LEN=lc)                                  :: cl_point
-   CHARACTER(LEN=lc)                                  :: cl_fmt
-
-   INTEGER(i4)                                        :: il_narg
-   INTEGER(i4)                                        :: il_status
-   INTEGER(i4)                                        :: il_fileid
-   INTEGER(i4)                                        :: il_imin0
-   INTEGER(i4)                                        :: il_imax0
-   INTEGER(i4)                                        :: il_jmin0
-   INTEGER(i4)                                        :: il_jmax0
-   INTEGER(i4)                                        :: il_shift
-   INTEGER(i4)      , DIMENSION(ip_maxdim)            :: il_rho
-   INTEGER(i4)      , DIMENSION(2,2)                  :: il_offset
-   INTEGER(i4)      , DIMENSION(2,2)                  :: il_ind
-
-   LOGICAL                                            :: ll_exist
-
-   TYPE(TATT)                                         :: tl_att
-   
-   TYPE(TVAR)                                         :: tl_depth   
-   TYPE(TVAR)                                         :: tl_time
-   TYPE(TVAR)                                         :: tl_var1
-   TYPE(TVAR)                                         :: tl_var0
-   TYPE(TVAR)                                         :: tl_lon1
-   TYPE(TVAR)                                         :: tl_lat1
-   TYPE(TVAR)                                         :: tl_lvl1  
-   TYPE(TVAR)       , DIMENSION(:)      , ALLOCATABLE :: tl_level
-   TYPE(TVAR)       , DIMENSION(:,:,:)  , ALLOCATABLE :: tl_seglvl1
-   TYPE(TVAR)       , DIMENSION(:,:,:)  , ALLOCATABLE :: tl_segvar1
-
-   TYPE(TDIM)       , DIMENSION(ip_maxdim)            :: tl_dim
-
-   TYPE(TDATE)                                        :: tl_date
-   
-   TYPE(TBDY)       , DIMENSION(ip_ncard)             :: tl_bdy
-   
-   TYPE(TDOM)                                         :: tl_dom0
-   TYPE(TDOM)                                         :: tl_dom1
-   TYPE(TDOM)       , DIMENSION(:,:,:)  , ALLOCATABLE :: tl_segdom1
-
-   TYPE(TFILE)                                        :: tl_fileout
-   
-   TYPE(TMPP)                                         :: tl_coord0
-   TYPE(TMPP)                                         :: tl_coord1
-   TYPE(TMPP)                                         :: tl_bathy1
-   TYPE(TMPP)                                         :: tl_mpp
-
-   TYPE(TMULTI)                                       :: tl_multi
-
-   ! loop indices
-   INTEGER(i4) :: jvar
-   INTEGER(i4) :: jpoint
-   INTEGER(i4) :: ji
-   INTEGER(i4) :: jj
-   INTEGER(i4) :: jk
-   INTEGER(i4) :: jl
-
-   ! namelist variable
-   ! namlog
-   CHARACTER(LEN=lc)  :: cn_logfile = 'create_boundary.log' 
-   CHARACTER(LEN=lc)  :: cn_verbosity = 'warning' 
-   INTEGER(i4)        :: in_maxerror = 5
-
-   ! namcfg
-   CHARACTER(LEN=lc)  :: cn_varcfg = 'variable.cfg' 
-
-   ! namcrs
-   CHARACTER(LEN=lc)  :: cn_coord0 = '' 
-   INTEGER(i4)        :: in_perio0 = -1
-
-   ! namfin
-   CHARACTER(LEN=lc)  :: cn_coord1 = '' 
-   CHARACTER(LEN=lc)  :: cn_bathy1 = '' 
-   INTEGER(i4)        :: in_perio1 = -1
-
-   !namzgr
-   REAL(dp)          :: dn_pp_to_be_computed = 0._dp
-   REAL(dp)          :: dn_ppsur     = -3958.951371276829_dp
-   REAL(dp)          :: dn_ppa0      =   103.9530096000000_dp
-   REAL(dp)          :: dn_ppa1      =     2.4159512690000_dp
-   REAL(dp)          :: dn_ppa2      =   100.7609285000000_dp
-   REAL(dp)          :: dn_ppkth     =    15.3510137000000_dp
-   REAL(dp)          :: dn_ppkth2    =    48.0298937200000_dp
-   REAL(dp)          :: dn_ppacr     =     7.0000000000000_dp
-   REAL(dp)          :: dn_ppacr2    =    13.000000000000_dp
-   REAL(dp)          :: dn_ppdzmin   = 6._dp
-   REAL(dp)          :: dn_pphmax    = 5750._dp
-   INTEGER(i4)       :: in_nlevel    = 75
-
-   !namzps
-   REAL(dp)          :: dn_e3zps_min = 25._dp
-   REAL(dp)          :: dn_e3zps_rat = 0.2_dp
-
-   ! namvar
-   CHARACTER(LEN=lc), DIMENSION(ip_maxvar) :: cn_varinfo = ''
-   CHARACTER(LEN=lc), DIMENSION(ip_maxvar) :: cn_varfile = ''
-
-   ! namnst
-   INTEGER(i4)       :: in_rhoi  = 0
-   INTEGER(i4)       :: in_rhoj  = 0
-
-   ! nambdy
-   LOGICAL           :: ln_north   = .TRUE.
-   LOGICAL           :: ln_south   = .TRUE.
-   LOGICAL           :: ln_east    = .TRUE.
-   LOGICAL           :: ln_west    = .TRUE.
-   CHARACTER(LEN=lc) :: cn_north   = ''
-   CHARACTER(LEN=lc) :: cn_south   = ''
-   CHARACTER(LEN=lc) :: cn_east    = ''
-   CHARACTER(LEN=lc) :: cn_west    = ''
-   LOGICAL           :: ln_oneseg  = .TRUE.
-
-   ! namout
-   CHARACTER(LEN=lc) :: cn_fileout = 'boundary.nc' 
-   REAL(dp)          :: dn_dayofs  = 0._dp
-   LOGICAL           :: ln_extrap  = .FALSE.
-   !-------------------------------------------------------------------
-
-   NAMELIST /namlog/ &  !< logger namelist
-   &  cn_logfile,    &  !< log file
-   &  cn_verbosity,  &  !< log verbosity
-   &  in_maxerror
-
-   NAMELIST /namcfg/ &  !< config namelist
-   &  cn_varcfg         !< variable configuration file
-
-   NAMELIST /namcrs/ &  !< coarse grid namelist
-   &  cn_coord0,     &  !< coordinate file
-   &  in_perio0         !< periodicity index
- 
-   NAMELIST /namfin/ &  !< fine grid namelist
-   &  cn_coord1,     &  !< coordinate file
-   &  cn_bathy1,     &  !< bathymetry file
-   &  in_perio1         !< periodicity index
- 
-   NAMELIST /namzgr/ &
-   &  dn_pp_to_be_computed, &
-   &  dn_ppsur,     &
-   &  dn_ppa0,      &
-   &  dn_ppa1,      &
-   &  dn_ppa2,      &
-   &  dn_ppkth,     &
-   &  dn_ppkth2,    &
-   &  dn_ppacr,     &
-   &  dn_ppacr2,    &
-   &  dn_ppdzmin,   &
-   &  dn_pphmax,    &
-   &  in_nlevel         !< number of vertical level
-
-   NAMELIST /namzps/ &
-   &  dn_e3zps_min, &
-   &  dn_e3zps_rat
-
-   NAMELIST /namvar/ &  !< variable namelist
-   &  cn_varinfo,    &  !< list of variable and method to apply on. (ex: 'votemper:linear','vosaline:cubic' )
-   &  cn_varfile        !< list of variable and file where find it. (ex: 'votemper:GLORYS_gridT.nc' ) 
- 
-   NAMELIST /namnst/ &  !< nesting namelist
-   &  in_rhoi,       &  !< refinement factor in i-direction
-   &  in_rhoj           !< refinement factor in j-direction
-
-   NAMELIST /nambdy/ &  !< boundary namelist
-   &  ln_north,      &  !< use north boundary
-   &  ln_south,      &  !< use south boundary
-   &  ln_east ,      &  !< use east  boundary
-   &  ln_west ,      &  !< use west  boundary
-   &  cn_north,      &  !< north boundary indices on fine grid
-   &  cn_south,      &  !< south boundary indices on fine grid
-   &  cn_east ,      &  !< east  boundary indices on fine grid
-   &  cn_west ,      &  !< west  boundary indices on fine grid
-   &  ln_oneseg         !< use only one segment for each boundary or not
-
-   NAMELIST /namout/ &  !< output namelist
-   &  cn_fileout,    &  !< fine grid boundary file basename   
-   &  dn_dayofs,     &  !< date offset in day (change only ouput file name)
-   &  ln_extrap         !< extrapolate or not
-   !-------------------------------------------------------------------
-
-   ! namelist
-   ! get namelist
-   il_narg=COMMAND_ARGUMENT_COUNT() !f03 intrinsec
-   IF( il_narg/=1 )THEN
-      PRINT *,"CREATE BOUNDARY: ERROR. need a namelist"
-      STOP
-   ELSE
-      CALL GET_COMMAND_ARGUMENT(1,cl_namelist) !f03 intrinsec
-   ENDIF
-   
-   ! read namelist
-   INQUIRE(FILE=TRIM(cl_namelist), EXIST=ll_exist)
-   IF( ll_exist )THEN
-      
-      il_fileid=fct_getunit()
-
-      OPEN( il_fileid, FILE=TRIM(cl_namelist), &
-      &                FORM='FORMATTED',       &
-      &                ACCESS='SEQUENTIAL',    &
-      &                STATUS='OLD',           &
-      &                ACTION='READ',          &
-      &                IOSTAT=il_status)
-      CALL fct_err(il_status)
-      IF( il_status /= 0 )THEN
-         PRINT *,"CREATE BOUNDARY: ERROR opening "//TRIM(cl_namelist)
-         STOP
-      ENDIF
-
-      READ( il_fileid, NML = namlog )
-      ! define log file
-      CALL logger_open(TRIM(cn_logfile),TRIM(cn_verbosity),in_maxerror)
-      CALL logger_header()
-
-      READ( il_fileid, NML = namcfg )
-      ! get variable extra information
-      CALL var_def_extra(TRIM(cn_varcfg))
-
-      READ( il_fileid, NML = namcrs )
-      READ( il_fileid, NML = namfin )
-      READ( il_fileid, NML = namzgr )
-      READ( il_fileid, NML = namvar )
-      ! add user change in extra information
-      CALL var_chg_extra(cn_varinfo)
-      ! match variable with file
-      tl_multi=multi_init(cn_varfile)
-
-      READ( il_fileid, NML = namnst )
-      READ( il_fileid, NML = nambdy )
-      READ( il_fileid, NML = namout )
-
-      CLOSE( il_fileid, IOSTAT=il_status )
-      CALL fct_err(il_status)
-      IF( il_status /= 0 )THEN
-         CALL logger_error("CREATE BOUNDARY: ERROR closing "//TRIM(cl_namelist))
-      ENDIF
-
-   ELSE
-
-      PRINT *,"CREATE BOUNDARY: ERROR. can not find "//TRIM(cl_namelist)
-      STOP
-
-   ENDIF
-
-   CALL multi_print(tl_multi)
-   IF( tl_multi%i_nvar <= 0 )THEN
-      CALL logger_fatal("CREATE BOUNDARY: no variable to be used."//&
-      &  " check namelist.")
-   ENDIF
-
-   ! open files
-   IF( TRIM(cn_coord0) /= '' )THEN
-      tl_coord0=mpp_init( file_init(TRIM(cn_coord0)), id_perio=in_perio0)
-      CALL grid_get_info(tl_coord0)
-   ELSE
-      CALL logger_fatal("CREATE BOUNDARY: can not find coarse grid "//&
-      &  "coordinate file. check namelist")
-   ENDIF
-
-   IF( TRIM(cn_coord1) /= '' )THEN
-      tl_coord1=mpp_init( file_init(TRIM(cn_coord1)), id_perio=in_perio1)
-      CALL grid_get_info(tl_coord1)
-   ELSE
-      CALL logger_fatal("CREATE BOUNDARY: can not find fine grid coordinate "//&
-      &  "file. check namelist")
-   ENDIF
-
-   IF( TRIM(cn_bathy1) /= '' )THEN
-      tl_bathy1=mpp_init( file_init(TRIM(cn_bathy1)), id_perio=in_perio1)
-      CALL grid_get_info(tl_bathy1)
-   ELSE
-      CALL logger_fatal("CREATE BOUNDARY: can not find fine grid bathymetry "//&
-      &  "file. check namelist")
-   ENDIF
-
-   ! check
-   ! check output file do not already exist
-   ! WARNING: do not work when use time to create output file name
-   DO jk=1,ip_ncard
-      cl_bdyout=boundary_set_filename( TRIM(cn_fileout), &
-      &                                TRIM(cp_card(jk)), 1 )
-      INQUIRE(FILE=TRIM(cl_bdyout), EXIST=ll_exist)
-      IF( ll_exist )THEN
-         CALL logger_fatal("CREATE BOUNDARY: output file "//TRIM(cl_bdyout)//&
-         &  " already exist.")
-      ENDIF
-
-      cl_bdyout=boundary_set_filename( TRIM(cn_fileout), &
-      &                                TRIM(cp_card(jk)) )
-      INQUIRE(FILE=TRIM(cl_bdyout), EXIST=ll_exist)
-      IF( ll_exist )THEN
-         CALL logger_fatal("CREATE BOUNDARY: output file "//TRIM(cl_bdyout)//&
-         &  " already exist.")
-      ENDIF
-   ENDDO
-
-   ! check namelist
-   ! check refinement factor
-   il_rho(:)=1
-   IF( in_rhoi < 1 .OR. in_rhoj < 1 )THEN
-      CALL logger_error("CREATE BOUNDARY: invalid refinement factor."//&
-      &  " check namelist "//TRIM(cl_namelist))
-   ELSE
-      il_rho(jp_I)=in_rhoi
-      il_rho(jp_J)=in_rhoj
-   ENDIF
-
-   !
-   ! compute coarse grid indices around fine grid
-   il_ind(:,:)=grid_get_coarse_index(tl_coord0, tl_coord1, &
-   &                                 id_rho=il_rho(:))
-
-   il_imin0=il_ind(1,1) ; il_imax0=il_ind(1,2)
-   il_jmin0=il_ind(2,1) ; il_jmax0=il_ind(2,2)
-
-   ! check domain validity
-   CALL grid_check_dom(tl_coord0, il_imin0, il_imax0, il_jmin0, il_jmax0)
-
-   ! check coordinate file
-   CALL grid_check_coincidence( tl_coord0, tl_coord1, &
-   &                            il_imin0, il_imax0, &
-   &                            il_jmin0, il_jmax0, &
-   &                            il_rho(:) )      
-
-   ! read or compute boundary
-   CALL mpp_get_contour(tl_bathy1)
-
-   CALL iom_mpp_open(tl_bathy1)
- 
-   tl_var1=iom_mpp_read_var(tl_bathy1,'Bathymetry')
- 
-   CALL iom_mpp_close(tl_bathy1)
-
-   ! get boundaries indices
-   tl_bdy(:)=boundary_init(tl_var1, ln_north, ln_south, ln_east, ln_west, &
-   &                                cn_north, cn_south, cn_east, cn_west, &
-   &                                ln_oneseg ) 
-
-   CALL var_clean(tl_var1)
-
-   ! compute level
-   ALLOCATE(tl_level(ip_npoint))
-   tl_level(:)=vgrid_get_level(tl_bathy1, cl_namelist )
-
-   ! get coordinate for each segment of each boundary
-   ALLOCATE( tl_segdom1(ip_npoint,ip_maxseg,ip_ncard) )
-   ALLOCATE( tl_seglvl1(ip_npoint,ip_maxseg,ip_ncard) )
- 
-   DO jl=1,ip_ncard
-      IF( tl_bdy(jl)%l_use )THEN
-         DO jk=1,tl_bdy(jl)%i_nseg
-
-            ! get fine grid segment domain
-            tl_segdom1(:,jk,jl)=create_boundary_get_dom( tl_bathy1, &
-            &                                            tl_bdy(jl), jk )
-
-            IF( .NOT. ln_extrap )THEN
-               ! get fine grid level
-               tl_seglvl1(:,jk,jl)= &
-                  & create_boundary_get_level( tl_level(:), &
-                  &                            tl_segdom1(:,jk,jl))
-            ENDIF
-
-            ! add extra band to fine grid domain (if possible)
-            ! to avoid dimension of one and so be able to compute offset
-            DO jj=1,ip_npoint
-               CALL dom_add_extra(tl_segdom1(jj,jk,jl), &
-               &                  il_rho(jp_I), il_rho(jp_J))
-            ENDDO
-
-         ENDDO
-      ENDIF
-   ENDDO
-
-   ! clean
-   CALL var_clean(tl_level(:))
-   DEALLOCATE(tl_level)
-
-   ! clean bathy
-   CALL mpp_clean(tl_bathy1)
-
-   ALLOCATE( tl_segvar1(tl_multi%i_nvar,ip_maxseg,ip_ncard) )
-   ! compute boundary for variable to be used (see namelist)
-   IF( .NOT. ASSOCIATED(tl_multi%t_mpp) )THEN
-      CALL logger_error("CREATE BOUNDARY: no file to work on. "//&
-      &                 "check cn_varfile in namelist.")
-   ELSE
-
-      jvar=0
-      ! for each file
-      DO ji=1,tl_multi%i_nmpp
-
-         WRITE(cl_data,'(a,i2.2)') 'data-',jvar+1
-
-         IF( .NOT. ASSOCIATED(tl_multi%t_mpp(ji)%t_proc(1)%t_var) )THEN
-
-            CALL logger_error("CREATE BOUNDARY: no variable to work on for "//&
-            &                 "mpp "//TRIM(tl_multi%t_mpp(ji)%c_name)//&
-            &                 ". check cn_varfile in namelist.")
-
-         ELSEIF( TRIM(tl_multi%t_mpp(ji)%c_name) == TRIM(cl_data) )THEN
-         !- use input matrix to fill variable
-
-            WRITE(*,'(a)') "work on data"
-            ! for each variable initialise from matrix
-            DO jj=1,tl_multi%t_mpp(ji)%t_proc(1)%i_nvar
-
-               jvar=jvar+1
-               WRITE(*,'(2x,a,a)') "work on variable "//&
-               &  TRIM(tl_multi%t_mpp(ji)%t_proc(1)%t_var(jj)%c_name)
-
-               tl_var1=var_copy(tl_multi%t_mpp(ji)%t_proc(1)%t_var(jj))
-
-               SELECT CASE(TRIM(tl_var1%c_point))
-               CASE DEFAULT !'T'
-                  jpoint=jp_T
-               CASE('U')
-                  jpoint=jp_U
-               CASE('V')
-                  jpoint=jp_V
-               CASE('F')
-                  jpoint=jp_F
-               END SELECT
-
-               WRITE(*,'(4x,a,a)') 'work on '//TRIM(tl_var1%c_name)
-               DO jl=1,ip_ncard
-                  IF( tl_bdy(jl)%l_use )THEN
-
-                     DO jk=1,tl_bdy(jl)%i_nseg
-
-                        ! fill value with matrix data
-                        tl_segvar1(jvar,jk,jl)=create_boundary_matrix( &
-                        &                          tl_var1, &
-                        &                          tl_segdom1(jpoint,jk,jl), &
-                        &                          in_nlevel )
-
-                        !del extra
-                        CALL dom_del_extra( tl_segvar1(jvar,jk,jl), &
-                        &                   tl_segdom1(jpoint,jk,jl) )
-
-                     ENDDO
-
-                  ENDIF
-               ENDDO
-               
-               ! clean
-               CALL var_clean(tl_var1)
-
-            ENDDO
-
-         !- end of use input matrix to fill variable
-         ELSE
-         !- use file to fill variable
-
-            WRITE(*,'(a)') "work on file "//TRIM(tl_multi%t_mpp(ji)%c_name)
-            ! 
-            tl_mpp=mpp_init(file_init(TRIM(tl_multi%t_mpp(ji)%t_proc(1)%c_name)))
-            CALL grid_get_info(tl_mpp)
-
-            ! check vertical dimension
-            IF( tl_mpp%t_dim(jp_K)%l_use .AND. &
-            &   tl_mpp%t_dim(jp_K)%i_len /= in_nlevel  )THEN
-               CALL logger_error("CREATE BOUNDARY: dimension in file "//&
-               &  TRIM(tl_mpp%c_name)//" not agree with namelist in_nlevel ")
-            ENDIF
-
-            ! open mpp file
-            CALL iom_mpp_open(tl_mpp)
-
-            ! get or check depth value
-            CALL create_boundary_check_depth( tl_mpp, tl_depth )
-
-            ! get or check time value
-            CALL create_boundary_check_time( tl_mpp, tl_time )
-
-            ! close mpp file
-            CALL iom_mpp_close(tl_mpp)
-
-            IF( ANY( tl_mpp%t_dim(1:2)%i_len /= &
-            &        tl_coord0%t_dim(1:2)%i_len) )THEN
-            !- extract value from fine grid
-
-               IF( ANY( tl_mpp%t_dim(1:2)%i_len <= &
-               &        tl_coord1%t_dim(1:2)%i_len) )THEN
-                  CALL logger_fatal("CREATE BOUNDARY: dimension in file "//&
-                  &  TRIM(tl_mpp%c_name)//" smaller than those in fine"//&
-                  &  " grid coordinates.")
-               ENDIF
-
-               DO jl=1,ip_ncard
-                  IF( tl_bdy(jl)%l_use )THEN
-                     
-                     WRITE(*,'(2x,a,a)') 'work on '//TRIM(tl_bdy(jl)%c_card)//&
-                        &  ' boundary'
-                     DO jk=1,tl_bdy(jl)%i_nseg
-                        ! compute domain on fine grid
-                        
-                        ! for each variable of this file
-                        DO jj=1,tl_multi%t_mpp(ji)%t_proc(1)%i_nvar
-                           
-                           cl_name=tl_multi%t_mpp(ji)%t_proc(1)%t_var(jj)%c_name
-                           WRITE(*,'(4x,a,a)') "work on (extract) variable "//&
-                              &  TRIM(cl_name)
-
-                           cl_point=tl_multi%t_mpp(ji)%t_proc(1)%t_var(jj)%c_point
-                           ! open mpp file on domain
-                           SELECT CASE(TRIM(cl_point))
-                              CASE DEFAULT !'T'
-                                 jpoint=jp_T
-                              CASE('U')
-                                 jpoint=jp_U
-                              CASE('V')
-                                 jpoint=jp_V
-                              CASE('F')
-                                 jpoint=jp_F
-                           END SELECT
-
-                           tl_dom1=dom_copy(tl_segdom1(jpoint,jk,jl))
-
-                           ! open mpp files
-                           CALL iom_dom_open(tl_mpp, tl_dom1)
-
-                           !7-5 read variable over domain
-                           tl_segvar1(jvar+jj,jk,jl)=iom_dom_read_var( &
-                           &                     tl_mpp, TRIM(cl_name), tl_dom1)
-
-                           ! del extra point
-                           CALL dom_del_extra( tl_segvar1(jvar+jj,jk,jl), &
-                           &                   tl_dom1 )
-
-                           ! clean extra point information on fine grid domain
-                           CALL dom_clean_extra( tl_dom1 )
-
-                           ! add attribute to variable
-                           tl_att=att_init('src_file', &
-                              &  TRIM(fct_basename(tl_mpp%c_name)))
-                           CALL var_move_att(tl_segvar1(jvar+jj,jk,jl), tl_att)
-
-                           tl_att=att_init('src_i_indices', &
-                              &  (/tl_dom1%i_imin, tl_dom1%i_imax/))
-                           CALL var_move_att(tl_segvar1(jvar+jj,jk,jl), tl_att)
-
-                           tl_att=att_init('src_j_indices', &
-                              &  (/tl_dom1%i_jmin, tl_dom1%i_jmax/))
-                           CALL var_move_att(tl_segvar1(jvar+jj,jk,jl), tl_att)
-
-                           ! clean structure
-                           CALL att_clean(tl_att)
-                           CALL dom_clean(tl_dom1)
-
-                           ! close mpp files
-                           CALL iom_dom_close(tl_mpp)
-
-                           ! clean
-                           CALL var_clean(tl_lvl1)
-
-                        ENDDO ! jj
-                     ENDDO ! jk
-
-                  ENDIF
-               ENDDO ! jl
-
-               ! clean
-               CALL mpp_clean(tl_mpp)
-
-               jvar=jvar+tl_multi%t_mpp(ji)%t_proc(1)%i_nvar
-
-            !- end of extract value from fine grid
-            ELSE
-            !- interpolate value from coarse grid
-
-               DO jl=1,ip_ncard
-                  IF( tl_bdy(jl)%l_use )THEN
-
-                     WRITE(*,'(2x,a,a)') 'work on '//TRIM(tl_bdy(jl)%c_card)//&
-                        &  ' boundary'
-                     DO jk=1,tl_bdy(jl)%i_nseg
-                        
-                        ! for each variable of this file
-                        DO jj=1,tl_multi%t_mpp(ji)%t_proc(1)%i_nvar
- 
-                           WRITE(*,'(4x,a,a)') "work on (interp) variable "//&
-                           &  TRIM(tl_multi%t_mpp(ji)%t_proc(1)%t_var(jj)%c_name)
-
-                           tl_var0=var_copy(tl_multi%t_mpp(ji)%t_proc(1)%t_var(jj))
-                           ! open mpp file on domain
-                           SELECT CASE(TRIM(tl_var0%c_point))
-                              CASE DEFAULT !'T'
-                                 jpoint=jp_T
-                              CASE('U')
-                                 jpoint=jp_U
-                              CASE('V')
-                                 jpoint=jp_V
-                              CASE('F')
-                                 jpoint=jp_F
-                           END SELECT
-
-                           tl_dom1=dom_copy(tl_segdom1(jpoint,jk,jl))
-
-                           CALL create_boundary_get_coord( tl_coord1, tl_dom1, &
-                           &                               tl_var0%c_point,    &
-                           &                               tl_lon1, tl_lat1 )
-
-                           ! get coarse grid indices of this segment
-                           il_ind(:,:)=grid_get_coarse_index(tl_coord0, &
-                           &                                 tl_lon1, tl_lat1, &
-                           &                                 id_rho=il_rho(:) )
-
-                           IF( ANY(il_ind(:,:)==0) )THEN
-                              CALL logger_error("CREATE BOUNDARY: error "//&
-                              &  "computing coarse grid indices")
-                           ELSE
-                              il_imin0=il_ind(1,1)
-                              il_imax0=il_ind(1,2)
-
-                              il_jmin0=il_ind(2,1)
-                              il_jmax0=il_ind(2,2)
-                           ENDIF
-
-                           il_offset(:,:)= grid_get_fine_offset( &
-                           &                    tl_coord0, &
-                           &                    il_imin0, il_jmin0,&
-                           &                    il_imax0, il_jmax0,&
-                           &                    tl_lon1%d_value(:,:,1,1),&
-                           &                    tl_lat1%d_value(:,:,1,1),&
-                           &                    il_rho(:),&
-                           &                    TRIM(tl_var0%c_point) )
-
-                           ! compute coarse grid segment domain
-                           tl_dom0=dom_init( tl_coord0,         &
-                           &                 il_imin0, il_imax0,&
-                           &                 il_jmin0, il_jmax0 )
-
-                           ! add extra band (if possible) to compute 
-                           ! interpolation
-                           CALL dom_add_extra(tl_dom0)
-
-                           ! read variables on domain 
-                           ! open mpp files
-                           CALL iom_dom_open(tl_mpp, tl_dom0)
-
-                           cl_name=tl_var0%c_name
-                           ! read variable value on domain
-                           tl_segvar1(jvar+jj,jk,jl)= &
-                           &    iom_dom_read_var(tl_mpp, TRIM(cl_name), tl_dom0)
-
-                           ! work on variable
-                           CALL create_boundary_interp( &
-                           &                 tl_segvar1(jvar+jj,jk,jl),&
-                           &                 il_rho(:), il_offset(:,:) )
-
-                           ! remove extraband added to domain
-                           CALL dom_del_extra( tl_segvar1(jvar+jj,jk,jl), &
-                           &                   tl_dom0, il_rho(:) )
-
-                           ! del extra point on fine grid
-                           CALL dom_del_extra( tl_segvar1(jvar+jj,jk,jl), &
-                           &                   tl_dom1 )
-                           ! clean extra point information on coarse grid domain
-                           CALL dom_clean_extra( tl_dom0 )
-
-                           ! add attribute to variable
-                           tl_att=att_init('src_file',&
-                           &  TRIM(fct_basename(tl_mpp%c_name)))
-                           CALL var_move_att(tl_segvar1(jvar+jj,jk,jl), &
-                           &                 tl_att)
-
-                           ! use clean extra avt creer attribut
-                           tl_att=att_init('src_i-indices',&
-                           &  (/tl_dom0%i_imin, tl_dom0%i_imax/))
-                           CALL var_move_att(tl_segvar1(jvar+jj,jk,jl), &
-                           &                 tl_att)
-
-                           tl_att=att_init('src_j-indices', &
-                           &  (/tl_dom0%i_jmin, tl_dom0%i_jmax/))
-                           CALL var_move_att(tl_segvar1(jvar+jj,jk,jl), &
-                           &                 tl_att)
-
-                           IF( ANY(il_rho(:)/=1) )THEN
-                              tl_att=att_init("refinment_factor", &
-                              &               (/il_rho(jp_I),il_rho(jp_J)/))
-                              CALL var_move_att(tl_segvar1(jvar+jj,jk,jl), &
-                              &                 tl_att)
-                           ENDIF
-
-                           ! clean structure
-                           CALL att_clean(tl_att)
-
-                           ! clean
-                           CALL dom_clean(tl_dom0)
-                           CALL dom_clean(tl_dom1)
-
-                           ! close mpp files
-                           CALL iom_dom_close(tl_mpp)
-
-                           ! clean structure
-                           CALL var_clean(tl_lon1)
-                           CALL var_clean(tl_lat1)
-                           CALL var_clean(tl_lvl1)
-
-                        ENDDO ! jj
-
-                        ! clean
-                        CALL var_clean(tl_var0)
-
-                     ENDDO ! jk
-               
-                  ENDIF
-               ENDDO ! jl
-
-               jvar=jvar+tl_multi%t_mpp(ji)%t_proc(1)%i_nvar
-
-            !- end of interpolate value from coarse grid
-            ENDIF
-
-            ! clean
-            CALL mpp_clean(tl_mpp)
-
-         !- end of use file to fill variable
-         ENDIF
-      ENDDO
-   ENDIF
-
-   IF( jvar /= tl_multi%i_nvar )THEN
-      CALL logger_error("CREATE BOUNDARY: it seems some variable "//&
-         &  "can not be read")
-   ENDIF
-
-   ! write file for each segment of each boundary
-   DO jl=1,ip_ncard
-      IF( tl_bdy(jl)%l_use )THEN
-
-         DO jk=1,tl_bdy(jl)%i_nseg
-            !- 
-            CALL create_boundary_get_coord( tl_coord1, tl_segdom1(jp_T,jk,jl),&
-            &                               'T', tl_lon1, tl_lat1 )
-
-            ! force to use nav_lon, nav_lat as variable name
-            tl_lon1%c_name='nav_lon'
-            tl_lat1%c_name='nav_lat'
-
-            ! del extra point on fine grid
-            CALL dom_del_extra( tl_lon1, tl_segdom1(jp_T,jk,jl) )
-            CALL dom_del_extra( tl_lat1, tl_segdom1(jp_T,jk,jl) )
-
-            ! clean
-            DO jpoint=1,ip_npoint
-               CALL dom_clean(tl_segdom1(jpoint,jk,jl))
-            ENDDO
-
-            ! swap array
-            CALL boundary_swap(tl_lon1, tl_bdy(jl))
-            CALL boundary_swap(tl_lat1, tl_bdy(jl))
-            DO jvar=1,tl_multi%i_nvar
-
-               ! use additional request
-               ! change unit and apply factor
-               CALL var_chg_unit(tl_segvar1(jvar,jk,jl))
-
-               ! forced min and max value
-               CALL var_limit_value(tl_segvar1(jvar,jk,jl))
-
-               ! filter
-               CALL filter_fill_value(tl_segvar1(jvar,jk,jl))
-
-               IF( .NOT. ln_extrap )THEN
-                  ! use mask
-                  SELECT CASE(TRIM(tl_segvar1(jvar,jk,jl)%c_point))
-                  CASE DEFAULT !'T'
-                     jpoint=jp_T
-                  CASE('U')
-                     jpoint=jp_U
-                  CASE('V')
-                     jpoint=jp_V
-                  CASE('F')
-                     jpoint=jp_F
-                  END SELECT
-
-                  CALL create_boundary_use_mask(tl_segvar1(jvar,jk,jl), &
-                  &                             tl_seglvl1(jpoint,jk,jl))
-               ENDIF
-
-               ! swap dimension order
-               CALL boundary_swap(tl_segvar1(jvar,jk,jl), tl_bdy(jl))
-
-            ENDDO
-
-            ! create file
-            ! create file structure
-            ! set file namearray of level variable structure
-            IF( tl_bdy(jl)%i_nseg > 1 )THEN
-               IF( ASSOCIATED(tl_time%d_value) )THEN
-                  cl_fmt="('y',i0.4,'m',i0.2,'d',i0.2)"
-                  tl_date=var_to_date(tl_time)
-                  tl_date=tl_date+dn_dayofs
-                  cl_date=date_print( tl_date, cl_fmt ) 
-
-                  cl_bdyout=boundary_set_filename( TRIM(cn_fileout), &
-                  &                                TRIM(tl_bdy(jl)%c_card), jk,&
-                  &                                cd_date=TRIM(cl_date) )
-               ELSE
-                  cl_bdyout=boundary_set_filename( TRIM(cn_fileout), &
-                  &                                TRIM(tl_bdy(jl)%c_card), jk )
-               ENDIF
-            ELSE
-               IF( ASSOCIATED(tl_time%d_value) )THEN
-                  cl_fmt="('y',i0.4,'m',i0.2,'d',i0.2)"
-                  tl_date=var_to_date(tl_time)
-                  tl_date=tl_date+dn_dayofs
-                  cl_date=date_print( tl_date, cl_fmt )
-
-                  cl_bdyout=boundary_set_filename( TRIM(cn_fileout), &
-                  &                                TRIM(tl_bdy(jl)%c_card), &
-                  &                                cd_date=TRIM(cl_date) )
-               ELSE
-                  cl_bdyout=boundary_set_filename( TRIM(cn_fileout), &
-                  &                                TRIM(tl_bdy(jl)%c_card) )
-               ENDIF
-            ENDIF
-            ! 
-            tl_fileout=file_init(TRIM(cl_bdyout),id_perio=in_perio1)
-
-            ! add dimension
-            tl_dim(:)=var_max_dim(tl_segvar1(:,jk,jl))
-
-            SELECT CASE(TRIM(tl_bdy(jl)%c_card))
-               CASE DEFAULT ! 'north','south'
-                  cl_dimorder='xyzt'
-               CASE('east','west')
-                  cl_dimorder='yxzt'
-            END SELECT
-
-            DO ji=1,ip_maxdim
-               IF( tl_dim(ji)%l_use ) CALL file_add_dim(tl_fileout, tl_dim(ji))
-            ENDDO
-
-            ! add variables
-            IF( ALL( tl_dim(1:2)%l_use ) )THEN
-               ! add longitude
-               CALL file_add_var(tl_fileout, tl_lon1)
-               CALL var_clean(tl_lon1)
-
-               ! add latitude
-               CALL file_add_var(tl_fileout, tl_lat1)
-               CALL var_clean(tl_lat1)
-            ENDIF
-            
-
-
-            IF( tl_dim(3)%l_use )THEN
-               IF( ASSOCIATED(tl_depth%d_value) )THEN
-                  ! add depth
-                  CALL file_add_var(tl_fileout, tl_depth)
-               ENDIF
-            ENDIF
-
-            IF( tl_dim(4)%l_use )THEN
-               IF( ASSOCIATED(tl_time%d_value) )THEN
-                  ! add time
-                  CALL file_add_var(tl_fileout, tl_time)
-               ENDIF
-            ENDIF
-
-            ! add other variable
-            DO jvar=tl_multi%i_nvar,1,-1
-               CALL file_add_var(tl_fileout, tl_segvar1(jvar,jk,jl))
-               CALL var_clean(tl_segvar1(jvar,jk,jl))
-            ENDDO
-
-            ! add some attribute
-            tl_att=att_init("Created_by","SIREN create_boundary")
-            CALL file_add_att(tl_fileout, tl_att)
-
-            cl_date=date_print(date_now())
-            tl_att=att_init("Creation_date",cl_date)
-            CALL file_add_att(tl_fileout, tl_att)
-
-            ! add shift on north and east boundary
-            ! boundary compute on T point but express on U or V point
-            SELECT CASE(TRIM(tl_bdy(jl)%c_card))
-            CASE DEFAULT ! 'south','west'
-               il_shift=0
-            CASE('north','east')
-               il_shift=1
-            END SELECT
-
-            ! add indice of velocity row or column
-            tl_att=att_init('bdy_ind',tl_bdy(jl)%t_seg(jk)%i_index-il_shift)
-            CALL file_move_att(tl_fileout, tl_att)
-
-            ! add width of the relaxation zone
-            tl_att=att_init('bdy_width',tl_bdy(jl)%t_seg(jk)%i_width)
-            CALL file_move_att(tl_fileout, tl_att)
-            
-            ! add indice of segment start 
-            tl_att=att_init('bdy_deb',tl_bdy(jl)%t_seg(jk)%i_first)
-            CALL file_move_att(tl_fileout, tl_att)
-            
-            ! add indice of segment end 
-            tl_att=att_init('bdy_end',tl_bdy(jl)%t_seg(jk)%i_last)
-            CALL file_move_att(tl_fileout, tl_att)
-                           
-            ! clean
-            CALL att_clean(tl_att)
-
-            ! create file
-            CALL iom_create(tl_fileout)
-
-            ! write file
-            CALL iom_write_file(tl_fileout, cl_dimorder)
-
-            ! close file
-            CALL iom_close(tl_fileout)
-            CALL file_clean(tl_fileout)
-
-         ENDDO ! jk
-
-      ENDIF
-      ! clean
-      CALL boundary_clean(tl_bdy(jl))
-   ENDDO !jl
-
-   ! clean
-   IF( ASSOCIATED(tl_depth%d_value) ) CALL var_clean(tl_depth)
-   IF( ASSOCIATED(tl_time%d_value) )   CALL var_clean(tl_time)
-   DEALLOCATE( tl_segdom1 )
-   DEALLOCATE( tl_segvar1 )
-   CALL var_clean(tl_seglvl1(:,:,:))
-   DEALLOCATE( tl_seglvl1 )
-
-
-   CALL mpp_clean(tl_coord1)
-   CALL mpp_clean(tl_coord0)
-
-   CALL multi_clean(tl_multi)
-
-   ! close log file
-   CALL logger_footer()
-   CALL logger_close()
-
-CONTAINS
-   !-------------------------------------------------------------------
-   !> @brief
-   !> This subroutine compute boundary domain for each grid point (T,U,V,F) 
-   !> 
-   !> @author J.Paul
-   !> @date November, 2013 - Initial Version
-   !> @date September, 2014
-   !> - take into account grid point to compute boundary indices
-   !>
-   !> @param[in] td_bathy1 file structure 
-   !> @param[in] td_bdy    boundary structure
-   !> @param[in] id_seg    segment indice 
-   !> @return array of domain structure 
-   !-------------------------------------------------------------------
-   FUNCTION create_boundary_get_dom( td_bathy1, td_bdy, id_seg )
-
-      IMPLICIT NONE
-
-      ! Argument
-      TYPE(TMPP) , INTENT(IN   ) :: td_bathy1
-      TYPE(TBDY) , INTENT(IN   ) :: td_bdy
-      INTEGER(i4), INTENT(IN   ) :: id_seg
-
-      ! function
-      TYPE(TDOM), DIMENSION(ip_npoint) :: create_boundary_get_dom
-
-      ! local variable
-      INTEGER(i4) :: il_imin1
-      INTEGER(i4) :: il_imax1
-      INTEGER(i4) :: il_jmin1
-      INTEGER(i4) :: il_jmax1
-
-      INTEGER(i4) :: il_imin
-      INTEGER(i4) :: il_imax
-      INTEGER(i4) :: il_jmin
-      INTEGER(i4) :: il_jmax
-
-      INTEGER(i4), DIMENSION(ip_npoint) :: il_ishift
-      INTEGER(i4), DIMENSION(ip_npoint) :: il_jshift
-
-      ! loop indices
-      INTEGER(i4) :: ji
-      INTEGER(i4) :: jk
-      !----------------------------------------------------------------
-      ! init
-      jk=id_seg
-
-      il_ishift(:)=0
-      il_jshift(:)=0
-
-      ! get boundary definition
-      SELECT CASE(TRIM(td_bdy%c_card))
-         CASE('north')
-
-            il_imin1=td_bdy%t_seg(jk)%i_first
-            il_imax1=td_bdy%t_seg(jk)%i_last 
-            il_jmin1=td_bdy%t_seg(jk)%i_index-(td_bdy%t_seg(jk)%i_width-1)
-            il_jmax1=td_bdy%t_seg(jk)%i_index
-
-            il_jshift(jp_V)=-1
-            il_jshift(jp_F)=-1
-
-         CASE('south')
-
-            il_imin1=td_bdy%t_seg(jk)%i_first
-            il_imax1=td_bdy%t_seg(jk)%i_last 
-            il_jmin1=td_bdy%t_seg(jk)%i_index
-            il_jmax1=td_bdy%t_seg(jk)%i_index+(td_bdy%t_seg(jk)%i_width-1)
-
-         CASE('east')
-
-            il_imin1=td_bdy%t_seg(jk)%i_index-(td_bdy%t_seg(jk)%i_width-1)
-            il_imax1=td_bdy%t_seg(jk)%i_index
-            il_jmin1=td_bdy%t_seg(jk)%i_first
-            il_jmax1=td_bdy%t_seg(jk)%i_last 
-
-            il_ishift(jp_U)=-1
-            il_ishift(jp_F)=-1
-
-         CASE('west')
-
-            il_imin1=td_bdy%t_seg(jk)%i_index
-            il_imax1=td_bdy%t_seg(jk)%i_index+(td_bdy%t_seg(jk)%i_width-1)
-            il_jmin1=td_bdy%t_seg(jk)%i_first
-            il_jmax1=td_bdy%t_seg(jk)%i_last 
-
-      END SELECT         
-
-      !-read fine grid domain
-      DO ji=1,ip_npoint
-
-         ! shift domain
-         il_imin=il_imin1+il_ishift(ji)
-         il_imax=il_imax1+il_ishift(ji)
-
-         il_jmin=il_jmin1+il_jshift(ji)
-         il_jmax=il_jmax1+il_jshift(ji)
-
-         ! compute domain
-         create_boundary_get_dom(ji)=dom_init( td_bathy1,       &
-         &                                     il_imin, il_imax,&
-         &                                     il_jmin, il_jmax,&
-         &                                     TRIM(td_bdy%c_card) )
-
-      ENDDO
-
-   END FUNCTION create_boundary_get_dom
-   !-------------------------------------------------------------------
-   !> @brief
-   !> This subroutine get coordinates over boundary domain
-   !> 
-   !> @author J.Paul
-   !> @date November, 2013 - Initial Version
-   !> @date September, 2014 
-   !> - take into account grid point
-   !>
-   !> @param[in] td_coord1 coordinates file structure
-   !> @param[in] td_dom1   boundary domain structure
-   !> @param[in] cd_point  grid point
-   !> @param[out] td_lon1  longitude variable structure
-   !> @param[out] td_lat1  latitude variable structure
-   !-------------------------------------------------------------------
-   SUBROUTINE create_boundary_get_coord( td_coord1, td_dom1, cd_point, &
-   &                                     td_lon1, td_lat1 )
-
-      IMPLICIT NONE
-      ! Argument
-      TYPE(TMPP)      , INTENT(IN   ) :: td_coord1
-      TYPE(TDOM)      , INTENT(IN   ) :: td_dom1
-      TYPE(TVAR)      , INTENT(  OUT) :: td_lon1
-      TYPE(TVAR)      , INTENT(  OUT) :: td_lat1 
-      CHARACTER(LEN=*), INTENT(IN   ), OPTIONAL :: cd_point
-
-      ! local variable
-      TYPE(TMPP)  :: tl_coord1
-      
-      CHARACTER(LEN=lc) :: cl_name
-      ! loop indices
-      !----------------------------------------------------------------
-      !read variables on domain (ugly way to do it, have to work on it)
-      ! init mpp structure
-      tl_coord1=mpp_copy(td_coord1)
-      
-      ! open mpp files
-      CALL iom_dom_open(tl_coord1, td_dom1)
-
-      ! read variable value on domain
-      WRITE(cl_name,*) 'longitude_'//TRIM(cd_point)
-      td_lon1=iom_dom_read_var( tl_coord1, TRIM(cl_name), td_dom1)
-      WRITE(cl_name,*) 'latitude_'//TRIM(cd_point)
-      td_lat1=iom_dom_read_var( tl_coord1, TRIM(cl_name), td_dom1)
-
-      ! close mpp files
-      CALL iom_dom_close(tl_coord1)
-
-      ! clean structure
-      CALL mpp_clean(tl_coord1)
-
-   END SUBROUTINE create_boundary_get_coord
-   !-------------------------------------------------------------------
-   !> @brief
-   !> This subroutine interpolate variable on boundary
-   !> 
-   !> @details 
-   !>
-   !> @author J.Paul
-   !> @date November, 2013 - Initial Version
-   !>
-   !> @param[inout] td_var variable structure 
-   !> @param[in] id_rho    array of refinment factor
-   !> @param[in] id_offset array of offset between fine and coarse grid
-   !> @param[in] id_iext   i-direction size of extra bands (default=im_minext)
-   !> @param[in] id_jext   j-direction size of extra bands (default=im_minext)
-   !-------------------------------------------------------------------
-   SUBROUTINE create_boundary_interp( td_var,           &
-   &                                  id_rho,           &
-   &                                  id_offset,        &
-   &                                  id_iext, id_jext )
-
-      IMPLICIT NONE
-
-      ! Argument
-      TYPE(TVAR) ,                 INTENT(INOUT) :: td_var
-      INTEGER(I4), DIMENSION(:)  , INTENT(IN   ) :: id_rho
-      INTEGER(i4), DIMENSION(:,:), INTENT(IN   ) :: id_offset
-
-      INTEGER(i4), INTENT(IN   ), OPTIONAL :: id_iext
-      INTEGER(i4), INTENT(IN   ), OPTIONAL :: id_jext
-
-
-      ! local variable
-      INTEGER(i4) :: il_iext
-      INTEGER(i4) :: il_jext
-      ! loop indices
-      !----------------------------------------------------------------
-
-      !WARNING: at least two extrabands are required for cubic interpolation
-      il_iext=2
-      IF( PRESENT(id_iext) ) il_iext=id_iext
-
-      il_jext=2
-      IF( PRESENT(id_jext) ) il_jext=id_jext
-
-      IF( il_iext < 2 .AND. td_var%c_interp(1) == 'cubic' )THEN
-         CALL logger_warn("CREATE BOUNDARY INTERP: at least extrapolation "//&
-         &  "on two points are required with cubic interpolation ")
-         il_iext=2
-      ENDIF
-
-      IF( il_jext < 2 .AND. td_var%c_interp(1) == 'cubic' )THEN
-         CALL logger_warn("CREATE BOUNDARY INTERP: at least extrapolation "//&
-         &  "on two points are required with cubic interpolation ")
-         il_jext=2
-      ENDIF
-
-      ! work on variable
-      ! add extraband
-      CALL extrap_add_extrabands(td_var, il_iext, il_jext)
-
-      ! extrapolate variable
-      CALL extrap_fill_value( td_var )
-
-      ! interpolate Bathymetry
-      CALL interp_fill_value( td_var, id_rho(:), &
-      &                       id_offset=id_offset(:,:) )
-
-      ! remove extraband
-      CALL extrap_del_extrabands(td_var, il_iext*id_rho(jp_I), &
-         &                               il_jext*id_rho(jp_J))
-
-   END SUBROUTINE create_boundary_interp
-   !-------------------------------------------------------------------
-   !> @brief
-   !> This function create variable, filled with matrix value
-   !> 
-   !> @details 
-   !> A variable is create with the same name that the input variable, 
-   !> and with dimension of the coordinate file. 
-   !> Then the variable array of value is split into equal subdomain.
-   !> Each subdomain is fill with the linked value of the matrix.
-   !>
-   !> @author J.Paul
-   !> @date November, 2013 - Initial Version
-   !>
-   !> @param[in] td_var    variable structure 
-   !> @param[in] td_dom    domain structure 
-   !> @param[in] id_nlevel number of levels 
-   !> @return variable structure 
-   !-------------------------------------------------------------------
-   FUNCTION create_boundary_matrix(td_var, td_dom, id_nlevel)
-      IMPLICIT NONE
-      ! Argument
-      TYPE(TVAR) ,               INTENT(IN) :: td_var
-      TYPE(TDOM) ,               INTENT(IN) :: td_dom
-      INTEGER(i4),               INTENT(IN) :: id_nlevel
-
-      ! function
-      TYPE(TVAR) :: create_boundary_matrix
-
-      ! local variable
-      INTEGER(i4)      , DIMENSION(3)                    :: il_dim
-      INTEGER(i4)      , DIMENSION(3)                    :: il_size
-      INTEGER(i4)      , DIMENSION(3)                    :: il_rest
-
-      INTEGER(i4)      , DIMENSION(:)      , ALLOCATABLE :: il_ishape
-      INTEGER(i4)      , DIMENSION(:)      , ALLOCATABLE :: il_jshape
-      INTEGER(i4)      , DIMENSION(:)      , ALLOCATABLE :: il_kshape
-
-      REAL(dp)         , DIMENSION(:,:,:,:), ALLOCATABLE :: dl_value
-
-      TYPE(TDIM)       , DIMENSION(ip_maxdim)            :: tl_dim
-
-      ! loop indices
-      INTEGER(i4) :: ji
-      INTEGER(i4) :: jj
-      INTEGER(i4) :: jk
-      !----------------------------------------------------------------
-
-      ! write value on grid
-      ! get matrix dimension
-      il_dim(:)=td_var%t_dim(1:3)%i_len
-
-      tl_dim(jp_I:jp_J)=dim_copy(td_dom%t_dim(jp_I:jp_J))
-      tl_dim(jp_K)%i_len=id_nlevel
-
-      ! split output domain in N subdomain depending of matrix dimension 
-      il_size(:) = tl_dim(1:3)%i_len / il_dim(:)
-      il_rest(:) = MOD(tl_dim(1:3)%i_len, il_dim(:))
-
-      ALLOCATE( il_ishape(il_dim(1)+1) )
-      il_ishape(:)=0
-      DO ji=2,il_dim(1)+1
-         il_ishape(ji)=il_ishape(ji-1)+il_size(1)
-      ENDDO
-      ! add rest to last cell
-      il_ishape(il_dim(1)+1)=il_ishape(il_dim(1)+1)+il_rest(1)
-      
-      ALLOCATE( il_jshape(il_dim(2)+1) )
-      il_jshape(:)=0
-      DO jj=2,il_dim(2)+1
-         il_jshape(jj)=il_jshape(jj-1)+il_size(2)
-      ENDDO
-      ! add rest to last cell
-      il_jshape(il_dim(2)+1)=il_jshape(il_dim(2)+1)+il_rest(2)
-
-      ALLOCATE( il_kshape(il_dim(3)+1) )
-      il_kshape(:)=0
-      DO jk=2,il_dim(3)+1
-         il_kshape(jk)=il_kshape(jk-1)+il_size(3)
-      ENDDO
-      ! add rest to last cell
-      il_kshape(il_dim(3)+1)=il_kshape(il_dim(3)+1)+il_rest(3)
-
-      ! write ouput array of value 
-      ALLOCATE(dl_value( tl_dim(1)%i_len, &
-      &                  tl_dim(2)%i_len, &
-      &                  tl_dim(3)%i_len, &
-      &                  tl_dim(4)%i_len) )
-
-      dl_value(:,:,:,:)=0
-
-      DO jk=2,il_dim(3)+1
-         DO jj=2,il_dim(2)+1
-            DO ji=2,il_dim(1)+1
-               
-               dl_value( 1+il_ishape(ji-1):il_ishape(ji), &
-               &         1+il_jshape(jj-1):il_jshape(jj), &
-               &         1+il_kshape(jk-1):il_kshape(jk), &
-               &         1 ) = td_var%d_value(ji-1,jj-1,jk-1,1)
-
-            ENDDO
-         ENDDO
-      ENDDO
-
-      ! initialise variable with value
-      create_boundary_matrix=var_init(TRIM(td_var%c_name),dl_value(:,:,:,:))
-
-      DEALLOCATE(dl_value)
-
-   END FUNCTION create_boundary_matrix
-   !-------------------------------------------------------------------
-   !> @brief
-   !> This subroutine use mask to filled land point with _FillValue
-   !> 
-   !> @details 
-   !>
-   !> @author J.Paul
-   !> @date November, 2013 - Initial Version
-   !>
-   !> @param[inout] td_var variable structure 
-   !> @param[in] td_mask   mask variable structure
-   !-------------------------------------------------------------------
-   SUBROUTINE create_boundary_use_mask( td_var, td_mask )
-
-      IMPLICIT NONE
-
-      ! Argument
-      TYPE(TVAR), INTENT(INOUT) :: td_var
-      TYPE(TVAR), INTENT(IN   ) :: td_mask
-
-      ! local variable
-      INTEGER(i4), DIMENSION(:,:), ALLOCATABLE :: il_mask
-
-      ! loop indices
-      INTEGER(i4) :: jk
-      INTEGER(i4) :: jl
-      !----------------------------------------------------------------
-
-      IF( ANY(td_var%t_dim(1:2)%i_len /= &
-      &       td_mask%t_dim(1:2)%i_len) )THEN
-         CALL logger_debug("     mask dimension ( "//&
-         &              TRIM(fct_str(td_mask%t_dim(1)%i_len))//","//&
-         &              TRIM(fct_str(td_mask%t_dim(2)%i_len))//")" )
-         CALL logger_debug(" variable dimension ( "//&
-         &              TRIM(fct_str(td_var%t_dim(1)%i_len))//","//&
-         &              TRIM(fct_str(td_var%t_dim(2)%i_len))//")" )
-         CALL logger_fatal("CREATE BOUNDARY USE MASK: mask and "//&
-         &                 "variable dimension differ."   )
-      ENDIF
-
-      ALLOCATE( il_mask(td_var%t_dim(1)%i_len, &
-      &                 td_var%t_dim(2)%i_len) )
-
-      il_mask(:,:)=INT(td_mask%d_value(:,:,1,1))
-
-      DO jl=1,td_var%t_dim(4)%i_len
-         DO jk=1,td_var%t_dim(3)%i_len
-            WHERE( il_mask(:,:) < jk ) td_var%d_value(:,:,jk,jl)=td_var%d_fill
-         ENDDO
-      ENDDO
-
-      DEALLOCATE( il_mask )
-
-   END SUBROUTINE create_boundary_use_mask
-   !-------------------------------------------------------------------
-   !> @brief
-   !> This function extract level over domain on each grid point, and return
-   !> array of variable structure
-   !>
-   !> @author J.Paul
-   !> @date November, 2013 - Initial Version
-   !>
-   !> @param[in] td_level  array of level variable structure
-   !> @param[in] td_dom    array of domain structure
-   !> @return array of variable structure
-   !-------------------------------------------------------------------
-   FUNCTION create_boundary_get_level(td_level, td_dom)
-      IMPLICIT NONE
-      ! Argument
-      TYPE(TVAR), DIMENSION(:), INTENT(IN) :: td_level
-      TYPE(TDOM), DIMENSION(:), INTENT(IN) :: td_dom
-
-      ! function
-      TYPE(TVAR), DIMENSION(ip_npoint) :: create_boundary_get_level
-
-      ! local variable
-      TYPE(TVAR), DIMENSION(ip_npoint) :: tl_var
-
-      ! loop indices
-      INTEGER(i4) :: ji
-      !----------------------------------------------------------------
-
-      IF( SIZE(td_level(:)) /= ip_npoint .OR. &
-      &   SIZE(td_dom(:)) /= ip_npoint )THEN
-         CALL logger_error("CREATE BDY GET LEVEL: invalid dimension. "//&
-         &  "check input array of level and domain.")
-      ELSE
-
-         DO ji=1,ip_npoint
-
-            tl_var(ji)=var_copy(td_level(ji))
-
-            IF( ASSOCIATED(tl_var(ji)%d_value) ) DEALLOCATE(tl_var(ji)%d_value)
-
-            tl_var(ji)%t_dim(1)%i_len=td_dom(ji)%t_dim(1)%i_len
-            tl_var(ji)%t_dim(2)%i_len=td_dom(ji)%t_dim(2)%i_len
-            ALLOCATE(tl_var(ji)%d_value(tl_var(ji)%t_dim(1)%i_len, &
-            &                           tl_var(ji)%t_dim(2)%i_len, &
-            &                           tl_var(ji)%t_dim(3)%i_len, &
-            &                           tl_var(ji)%t_dim(4)%i_len) )
-
-            tl_var(ji)%d_value(:,:,:,:) = &
-            &  td_level(ji)%d_value( td_dom(ji)%i_imin:td_dom(ji)%i_imax, &
-            &                        td_dom(ji)%i_jmin:td_dom(ji)%i_jmax, :, : )
-
-         ENDDO
-         ! save result
-         create_boundary_get_level(:)=var_copy(tl_var(:))
-
-         ! clean
-         CALL var_clean(tl_var(:))
-
-      ENDIF
-   END FUNCTION create_boundary_get_level
-   !-------------------------------------------------------------------
-   !> @brief
-   !> This subroutine get depth variable value in an open mpp structure
-   !> and check if agree with already input depth variable.
-   !> 
-   !> @details 
-   !>
-   !> @author J.Paul
-   !> @date November, 2014 - Initial Version
-   !>
-   !> @param[in] td_mpp       mpp structure
-   !> @param[inout] td_depth  depth variable structure 
-   !-------------------------------------------------------------------
-   SUBROUTINE create_boundary_check_depth( td_mpp, td_depth )
-
-      IMPLICIT NONE
-
-      ! Argument
-      TYPE(TMPP) , INTENT(IN   ) :: td_mpp
-      TYPE(TVAR) , INTENT(INOUT) :: td_depth
-
-      ! local variable
-      INTEGER(i4) :: il_varid
-      TYPE(TVAR)  :: tl_depth
-      ! loop indices
-      !----------------------------------------------------------------
-
-      ! get or check depth value
-      IF( td_mpp%t_proc(1)%i_depthid /= 0 )THEN
-
-         il_varid=td_mpp%t_proc(1)%i_depthid
-         IF( ASSOCIATED(td_depth%d_value) )THEN
-
-            tl_depth=iom_mpp_read_var(td_mpp, il_varid)
-            IF( ANY( td_depth%d_value(:,:,:,:) /= &
-            &        tl_depth%d_value(:,:,:,:) ) )THEN
-
-               CALL logger_fatal("CREATE BOUNDARY: depth value from "//&
-               &  TRIM(tl_multi%t_mpp(ji)%c_name)//" not conform "//&
-               &  " to those from former file(s).")
-
-            ENDIF
-            CALL var_clean(tl_depth)
-
-         ELSE
-            td_depth=iom_mpp_read_var(td_mpp,il_varid)
-         ENDIF
-
-      ENDIF
-      
-   END SUBROUTINE create_boundary_check_depth
-   !-------------------------------------------------------------------
-   !> @brief
-   !> This subroutine get date and time in an open mpp structure
-   !> and check if agree with date and time already read.
-   !> 
-   !> @details 
-   !>
-   !> @author J.Paul
-   !> @date November, 2014 - Initial Version
-   !>
-   !> @param[in] td_mpp      mpp structure
-   !> @param[inout] td_time  time variable structure 
-   !-------------------------------------------------------------------
-   SUBROUTINE create_boundary_check_time( td_mpp, td_time )
-
-      IMPLICIT NONE
-
-      ! Argument
-      TYPE(TMPP), INTENT(IN   ) :: td_mpp
-      TYPE(TVAR), INTENT(INOUT) :: td_time
-
-      ! local variable
-      INTEGER(i4) :: il_varid
-      TYPE(TVAR)  :: tl_time
-
-      TYPE(TDATE) :: tl_date1
-      TYPE(TDATE) :: tl_date2
-      ! loop indices
-      !----------------------------------------------------------------
-
-      ! get or check depth value
-      IF( td_mpp%t_proc(1)%i_timeid /= 0 )THEN
-
-         il_varid=td_mpp%t_proc(1)%i_timeid
-         IF( ASSOCIATED(td_time%d_value) )THEN
-
-            tl_time=iom_mpp_read_var(td_mpp, il_varid)
-
-            tl_date1=var_to_date(td_time)
-            tl_date2=var_to_date(tl_time)
-            IF( tl_date1 - tl_date2 /= 0 )THEN
-
-               CALL logger_fatal("CREATE BOUNDARY: date from "//&
-               &  TRIM(tl_multi%t_mpp(ji)%c_name)//" not conform "//&
-               &  " to those from former file(s).")
-
-            ENDIF
-            CALL var_clean(tl_time)
-
-         ELSE
-            td_time=iom_mpp_read_var(td_mpp,il_varid)
-         ENDIF
-
-      ENDIF
-      
-   END SUBROUTINE create_boundary_check_time
-END PROGRAM create_boundary
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/create_coord.f90
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/create_coord.f90	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/create_coord.f90	(revision 6392)
@@ -9,5 +9,5 @@
 !> @file
 !> @brief 
-!> This program create fine grid coordinate file.
+!> This program creates fine grid coordinate file.
 !>
 !> @details
@@ -27,5 +27,5 @@
 !>    you could find a template of the namelist in templates directory.
 !>
-!>    create_coord.nam comprise 6 namelists:<br/>
+!>    create_coord.nam contains 6 namelists:<br/>
 !>       - logger namelist (namlog)
 !>       - config namelist (namcfg)
@@ -35,8 +35,4 @@
 !>       - output namelist (namout)
 !>    
-!>    @note 
-!>       All namelists have to be in file create_coord.nam, 
-!>       however variables of those namelists are all optional.
-!>
 !>    * _logger namelist (namlog)_:<br/>
 !>       - cn_logfile   : log filename
@@ -48,4 +44,6 @@
 !>       - cn_varcfg : variable configuration file 
 !> (see ./SIREN/cfg/variable.cfg)
+!>       - cn_dumcfg : useless (dummy) configuration file, for useless 
+!> dimension or variable (see ./SIREN/cfg/dummy.cfg).
 !>
 !>    * _coarse grid namelist (namcrs)_:<br/>
@@ -64,5 +62,4 @@
 !>             - int = interpolation method
 !>             - ext = extrapolation method
-!>             - flt = filter method
 !> 
 !>                requests must be separated by ';' .<br/>
@@ -72,6 +69,6 @@
 !>          @ref extrap and @ref filter modules.<br/>
 !>
-!>          Example: 'votemper: int=linear; flt=hann(2,3); ext=dist_weight', 
-!>          'vosaline: int=cubic'<br/>
+!>          Example: 'glamt: int=linear; ext=dist_weight', 
+!>          'e1t: int=cubic/rhoi'<br/>
 !>          @note 
 !>             If you do not specify a method which is required, 
@@ -103,4 +100,6 @@
 !> - compute offset considering grid point
 !> - add global attributes in output file
+!> @date September, 2015
+!> - manage useless (dummy) variable, attributes, and dimension
 !>
 !> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -167,5 +166,6 @@
 
    ! namcfg
-   CHARACTER(LEN=lc) :: cn_varcfg = '../cfg/variable.cfg' 
+   CHARACTER(LEN=lc) :: cn_varcfg = './cfg/variable.cfg' 
+   CHARACTER(LEN=lc) :: cn_dumcfg = './cfg/dummy.cfg'
 
    ! namcrs
@@ -194,5 +194,6 @@
 
    NAMELIST /namcfg/ &  !  config namelist
-   &  cn_varcfg         !< variable configuration file
+   &  cn_varcfg, &       !< variable configuration file
+   &  cn_dumcfg          !< dummy configuration file
 
    NAMELIST /namcrs/ &  !  coarse grid namelist
@@ -254,4 +255,11 @@
       CALL var_def_extra(TRIM(cn_varcfg))
 
+      ! get dummy variable
+      CALL var_get_dummy(TRIM(cn_dumcfg))
+      ! get dummy dimension
+      CALL dim_get_dummy(TRIM(cn_dumcfg))
+      ! get dummy attribute
+      CALL att_get_dummy(TRIM(cn_dumcfg))
+
       READ( il_fileid, NML = namcrs )
       READ( il_fileid, NML = namvar )
@@ -354,4 +362,7 @@
    ENDDO
 
+   ! clean
+   CALL dom_clean_extra( tl_dom )
+
    ! close mpp files
    CALL iom_dom_close(tl_coord0)
@@ -388,7 +399,7 @@
    CALL file_add_att(tl_fileout, tl_att)   
 
-   tl_att=att_init("src_i_indices",(/in_imin0,in_imax0/))
+   tl_att=att_init("src_i_indices",(/tl_dom%i_imin,tl_dom%i_imax/))
    CALL file_add_att(tl_fileout, tl_att)   
-   tl_att=att_init("src_j_indices",(/in_jmin0,in_jmax0/))
+   tl_att=att_init("src_j_indices",(/tl_dom%i_jmin,tl_dom%i_jmax/))
    CALL file_add_att(tl_fileout, tl_att)
    IF( .NOT. ALL(il_rho(:)==1) )THEN
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/create_restart.f90
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/create_restart.f90	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/create_restart.f90	(revision 6392)
@@ -9,11 +9,11 @@
 !> @file
 !> @brief 
-!> This program create restart file.
+!> This program creates restart file.
 !>
 !> @details
 !> @section sec1 method
 !> Variables could be extracted from fine grid file, interpolated from coarse
-!> grid file or restart file, or manually written.<br/> 
-!> Then they are split over new decomposition. 
+!> grid file or restart file. Variables could also be manually written.<br/> 
+!> Then they are split over new layout. 
 !> @note 
 !>    method could be different for each variable.
@@ -28,5 +28,5 @@
 !>    you could find a template of the namelist in templates directory.
 !>
-!>    create_restart.nam comprise 9 namelists:<br/>
+!>    create_restart.nam contains 9 namelists:<br/>
 !>       - logger namelist (namlog)
 !>       - config namelist (namcfg)
@@ -39,8 +39,4 @@
 !>       - output namelist (namout)
 !>    
-!>    @note 
-!>       All namelists have to be in file create_restart.nam 
-!>       however variables of those namelists are all optional.
-!>
 !>    * _logger namelist (namlog)_:<br/>
 !>       - cn_logfile   : log filename
@@ -52,4 +48,6 @@
 !>       - cn_varcfg : variable configuration file
 !> (see ./SIREN/cfg/variable.cfg)
+!>       - cn_dumcfg : useless (dummy) configuration file, for useless 
+!> dimension or variable (see ./SIREN/cfg/dummy.cfg).
 !>
 !>    * _coarse grid namelist (namcrs):<br/>
@@ -82,29 +80,5 @@
 !>
 !>    * _variable namelist (namvar)_:<br/>
-!>       - cn_varinfo : list of variable and extra information about request(s) 
-!>       to be used.<br/>
-!>          each elements of *cn_varinfo* is a string character
-!>          (separated by ',').<br/>
-!>          it is composed of the variable name follow by ':', 
-!>          then request(s) to be used on this variable.<br/> 
-!>          request could be:
-!>             - int = interpolation method
-!>             - ext = extrapolation method
-!>             - flt = filter method
-!>             - min = minimum value
-!>             - max = maximum value
-!>             - unt = new units
-!>             - unf = unit scale factor (linked to new units)
-!>
-!>             requests must be separated by ';'.<br/>
-!>             order of requests does not matter.<br/>
-!>
-!>          informations about available method could be find in @ref interp,
-!>          @ref extrap and @ref filter.<br/>
-!>          Example: 'votemper: int=linear; flt=hann; ext=dist_weight','vosaline: int=cubic'
-!>          @note 
-!>             If you do not specify a method which is required, 
-!>             default one is apply.
-!>       - cn_varfile : list of variable, and corresponding file<br/> 
+!>       - cn_varfile : list of variable, and associated file<br/> 
 !>          *cn_varfile* is the path and filename of the file where find
 !>          variable.<br/>
@@ -131,9 +105,35 @@
 !>             - 'all:restart.dimg'
 !>
+!>       - cn_varinfo : list of variable and extra information about request(s) 
+!>       to be used.<br/>
+!>          each elements of *cn_varinfo* is a string character
+!>          (separated by ',').<br/>
+!>          it is composed of the variable name follow by ':', 
+!>          then request(s) to be used on this variable.<br/> 
+!>          request could be:
+!>             - int = interpolation method
+!>             - ext = extrapolation method
+!>             - flt = filter method
+!>             - min = minimum value
+!>             - max = maximum value
+!>             - unt = new units
+!>             - unf = unit scale factor (linked to new units)
+!>
+!>             requests must be separated by ';'.<br/>
+!>             order of requests does not matter.<br/>
+!>
+!>          informations about available method could be find in @ref interp,
+!>          @ref extrap and @ref filter.<br/>
+!>          Example: 'votemper: int=linear; flt=hann; ext=dist_weight',
+!>                   'vosaline: int=cubic'
+!>          @note 
+!>             If you do not specify a method which is required, 
+!>             default one is apply.
+!>
 !>    * _nesting namelist (namnst)_:<br/>
 !>       - in_rhoi  : refinement factor in i-direction
 !>       - in_rhoj  : refinement factor in j-direction
 !>       @note 
-!>          coarse grid indices will be deduced from fine grid
+!>          coarse grid indices will be computed from fine grid
 !>          coordinate file.
 !>
@@ -141,6 +141,6 @@
 !>       - cn_fileout : output file
 !>       - ln_extrap : extrapolate land point or not
-!>       - in_niproc : i-direction number of processor
-!>       - in_njproc : j-direction numebr of processor
+!>       - in_niproc : number of processor in i-direction
+!>       - in_njproc : number of processor in j-direction
 !>       - in_nproc  : total number of processor to be used
 !>       - cn_type   : output format ('dimg', 'cdf')
@@ -156,4 +156,6 @@
 !> - extrapolate all land points, and add ln_extrap in namelist.
 !> - allow to change unit.
+!> @date September, 2015
+!> - manage useless (dummy) variable, attributes, and dimension
 !>
 !> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -173,5 +175,5 @@
    USE iom                             ! I/O manager
    USE grid                            ! grid manager
-   USE vgrid                            ! vertical grid manager
+   USE vgrid                           ! vertical grid manager
    USE extrap                          ! extrapolation manager
    USE interp                          ! interpolation manager
@@ -183,5 +185,4 @@
 
    IMPLICIT NONE
-
 
    ! local variable
@@ -212,4 +213,5 @@
 
    LOGICAL                                            :: ll_exist
+   LOGICAL                                            :: ll_sameGrid
 
    TYPE(TDOM)                                         :: tl_dom1
@@ -242,53 +244,54 @@
    ! namelist variable
    ! namlog
-   CHARACTER(LEN=lc) :: cn_logfile = 'create_restart.log' 
-   CHARACTER(LEN=lc) :: cn_verbosity = 'warning' 
-   INTEGER(i4)       :: in_maxerror = 5
+   CHARACTER(LEN=lc)                       :: cn_logfile = 'create_restart.log' 
+   CHARACTER(LEN=lc)                       :: cn_verbosity = 'warning' 
+   INTEGER(i4)                             :: in_maxerror = 5
 
    ! namcfg
-   CHARACTER(LEN=lc) :: cn_varcfg = 'variable.cfg' 
+   CHARACTER(LEN=lc)                       :: cn_varcfg = 'variable.cfg' 
+   CHARACTER(LEN=lc)                       :: cn_dumcfg = 'dummy.cfg'
 
    ! namcrs
-   CHARACTER(LEN=lc) :: cn_coord0 = '' 
-   INTEGER(i4)       :: in_perio0 = -1
+   CHARACTER(LEN=lc)                       :: cn_coord0 = '' 
+   INTEGER(i4)                             :: in_perio0 = -1
 
    ! namfin
-   CHARACTER(LEN=lc) :: cn_coord1 = ''
-   CHARACTER(LEN=lc) :: cn_bathy1 = ''
-   INTEGER(i4)       :: in_perio1 = -1
+   CHARACTER(LEN=lc)                       :: cn_coord1 = ''
+   CHARACTER(LEN=lc)                       :: cn_bathy1 = ''
+   INTEGER(i4)                             :: in_perio1 = -1
 
    !namzgr
-   REAL(dp)          :: dn_pp_to_be_computed = 0._dp
-   REAL(dp)          :: dn_ppsur     = -3958.951371276829_dp
-   REAL(dp)          :: dn_ppa0      =   103.9530096000000_dp
-   REAL(dp)          :: dn_ppa1      =     2.4159512690000_dp
-   REAL(dp)          :: dn_ppa2      =   100.7609285000000_dp
-   REAL(dp)          :: dn_ppkth     =    15.3510137000000_dp
-   REAL(dp)          :: dn_ppkth2    =    48.0298937200000_dp
-   REAL(dp)          :: dn_ppacr     =     7.0000000000000_dp
-   REAL(dp)          :: dn_ppacr2    =    13.000000000000_dp
-   REAL(dp)          :: dn_ppdzmin   = 6._dp
-   REAL(dp)          :: dn_pphmax    = 5750._dp
-   INTEGER(i4)       :: in_nlevel    = 75
+   REAL(dp)                                :: dn_pp_to_be_computed = 0._dp
+   REAL(dp)                                :: dn_ppsur   = -3958.951371276829_dp
+   REAL(dp)                                :: dn_ppa0    =   103.953009600000_dp
+   REAL(dp)                                :: dn_ppa1    =     2.415951269000_dp
+   REAL(dp)                                :: dn_ppa2    =   100.760928500000_dp
+   REAL(dp)                                :: dn_ppkth   =    15.351013700000_dp
+   REAL(dp)                                :: dn_ppkth2  =    48.029893720000_dp
+   REAL(dp)                                :: dn_ppacr   =     7.000000000000_dp
+   REAL(dp)                                :: dn_ppacr2  =    13.000000000000_dp
+   REAL(dp)                                :: dn_ppdzmin = 6._dp
+   REAL(dp)                                :: dn_pphmax  = 5750._dp
+   INTEGER(i4)                             :: in_nlevel  = 75
 
    !namzps
-   REAL(dp)          :: dn_e3zps_min = 25._dp
-   REAL(dp)          :: dn_e3zps_rat = 0.2_dp
+   REAL(dp)                                :: dn_e3zps_min = 25._dp
+   REAL(dp)                                :: dn_e3zps_rat = 0.2_dp
 
    ! namvar
+   CHARACTER(LEN=lc), DIMENSION(ip_maxvar) :: cn_varfile = ''
    CHARACTER(LEN=lc), DIMENSION(ip_maxvar) :: cn_varinfo = ''
-   CHARACTER(LEN=lc), DIMENSION(ip_maxvar) :: cn_varfile = ''
 
    ! namnst
-   INTEGER(i4)       :: in_rhoi = 0
-   INTEGER(i4)       :: in_rhoj = 0
+   INTEGER(i4)                             :: in_rhoi = 0
+   INTEGER(i4)                             :: in_rhoj = 0
 
    ! namout
-   CHARACTER(LEN=lc) :: cn_fileout = 'restart.nc' 
-   LOGICAL           :: ln_extrap  = .FALSE.
-   INTEGER(i4)       :: in_nproc   = 0
-   INTEGER(i4)       :: in_niproc  = 0
-   INTEGER(i4)       :: in_njproc  = 0
-   CHARACTER(LEN=lc) :: cn_type    = ''
+   CHARACTER(LEN=lc)                       :: cn_fileout = 'restart.nc' 
+   LOGICAL                                 :: ln_extrap  = .FALSE.
+   INTEGER(i4)                             :: in_nproc   = 0
+   INTEGER(i4)                             :: in_niproc  = 0
+   INTEGER(i4)                             :: in_njproc  = 0
+   CHARACTER(LEN=lc)                       :: cn_type    = ''
 
    !-------------------------------------------------------------------
@@ -300,5 +303,6 @@
 
    NAMELIST /namcfg/ &  !< configuration namelist
-   &  cn_varcfg         !< variable configuration file
+   &  cn_varcfg, &      !< variable configuration file
+   &  cn_dumcfg         !< dummy configuration file
 
    NAMELIST /namcrs/ &  !< coarse grid namelist
@@ -330,6 +334,6 @@
 
    NAMELIST /namvar/ &  !< variable namelist
-   &  cn_varinfo, &     !< list of variable and interpolation method to be used.
-   &  cn_varfile        !< list of variable file
+   &  cn_varfile, &     !< list of variable file
+   &  cn_varinfo        !< list of variable and interpolation method to be used.
    
    NAMELIST /namnst/ &  !< nesting namelist
@@ -382,4 +386,11 @@
       ! get variable extra information
       CALL var_def_extra(TRIM(cn_varcfg))
+
+      ! get dummy variable
+      CALL var_get_dummy(TRIM(cn_dumcfg))
+      ! get dummy dimension
+      CALL dim_get_dummy(TRIM(cn_dumcfg))
+      ! get dummy attribute
+      CALL att_get_dummy(TRIM(cn_dumcfg))
 
       READ( il_fileid, NML = namcrs )
@@ -509,5 +520,5 @@
 
                jvar=jvar+1
-               
+
                WRITE(*,'(2x,a,a)') "work on variable "//&
                &  TRIM(tl_multi%t_mpp(ji)%t_proc(1)%t_var(jj)%c_name)
@@ -541,5 +552,4 @@
             CALL iom_mpp_open(tl_mpp)
 
-
             ! get or check depth value
             CALL create_restart_check_depth( tl_mpp, tl_depth )
@@ -551,17 +561,29 @@
             CALL iom_mpp_close(tl_mpp)
 
-            IF( ANY( tl_mpp%t_dim(1:2)%i_len /= &
-            &        tl_coord0%t_dim(1:2)%i_len) )THEN
+            IF( ANY(tl_mpp%t_dim(1:2)%i_len /= tl_coord0%t_dim(1:2)%i_len) .OR.&
+            &   ALL(il_rho(:)==1) )THEN
             !!! extract value from fine grid 
 
-               IF( ANY( tl_mpp%t_dim(1:2)%i_len <= &
+               IF( ANY( tl_mpp%t_dim(1:2)%i_len < &
                &        tl_coord1%t_dim(1:2)%i_len) )THEN
-                  CALL logger_fatal("CREATE RESTART: dimension in file "//&
+                  CALL logger_fatal("CREATE RESTART: dimensions in file "//&
                   &  TRIM(tl_mpp%c_name)//" smaller than those in fine"//&
                   &  " grid coordinates.")
                ENDIF
 
+               ! use coord0 instead of mpp for restart file case 
+               !  (without lon,lat)
+               ll_sameGrid=.FALSE.
+               IF( ALL(tl_mpp%t_dim(1:2)%i_len /= tl_coord0%t_dim(1:2)%i_len) &
+               &   )THEN
+                  ll_sameGrid=.TRUE. 
+               ENDIF
+
                ! compute domain on fine grid
-               il_ind(:,:)=grid_get_coarse_index(tl_mpp, tl_coord1 )
+               IF( ll_sameGrid )THEN
+                  il_ind(:,:)=grid_get_coarse_index(tl_mpp, tl_coord1 )
+               ELSE
+                  il_ind(:,:)=grid_get_coarse_index(tl_coord0, tl_coord1 )
+               ENDIF
 
                il_imin1=il_ind(1,1) ; il_imax1=il_ind(1,2)
@@ -569,8 +591,15 @@
 
                !- check grid coincidence
-               CALL grid_check_coincidence( tl_mpp, tl_coord1, &
-               &                            il_imin1, il_imax1, &
-               &                            il_jmin1, il_jmax1, &
-               &                            il_rho(:) )
+               IF( ll_sameGrid )THEN
+                  CALL grid_check_coincidence( tl_mpp, tl_coord1, &
+                  &                            il_imin1, il_imax1, &
+                  &                            il_jmin1, il_jmax1, &
+                  &                            il_rho(:) )
+               ELSE
+                  CALL grid_check_coincidence( tl_coord0, tl_coord1, &
+                  &                            il_imin1, il_imax1, &
+                  &                            il_jmin1, il_jmax1, &
+                  &                            il_rho(:) )
+               ENDIF
 
                ! compute domain
@@ -754,4 +783,5 @@
 
    DO ji=1,ip_maxdim
+
       IF( tl_dim(ji)%l_use )THEN
          CALL mpp_move_dim(tl_mppout, tl_dim(ji))
@@ -763,4 +793,5 @@
          END SELECT 
       ENDIF
+
    ENDDO
 
@@ -879,5 +910,5 @@
    !> and with dimension of the coordinate file.<br/> 
    !> Then the variable array of value is split into equal subdomain.
-   !> Each subdomain is filled with the corresponding value of the matrix.
+   !> Each subdomain is filled with the associated value of the matrix.
    !>
    !> @author J.Paul
@@ -1169,6 +1200,6 @@
             &        tl_depth%d_value(:,:,:,:) ) )THEN
 
-               CALL logger_fatal("CREATE BOUNDARY: depth value from "//&
-               &  TRIM(tl_multi%t_mpp(ji)%c_name)//" not conform "//&
+               CALL logger_warn("CREATE BOUNDARY: depth value from "//&
+               &  TRIM(td_mpp%c_name)//" not conform "//&
                &  " to those from former file(s).")
 
@@ -1226,6 +1257,6 @@
             IF( tl_date1 - tl_date2 /= 0 )THEN
 
-               CALL logger_fatal("CREATE BOUNDARY: date from "//&
-               &  TRIM(tl_multi%t_mpp(ji)%c_name)//" not conform "//&
+               CALL logger_warn("CREATE BOUNDARY: date from "//&
+               &  TRIM(td_mpp%c_name)//" not conform "//&
                &  " to those from former file(s).")
 
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/dimension.f90
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/dimension.f90	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/dimension.f90	(revision 6392)
@@ -154,4 +154,6 @@
 ! REVISION HISTORY:
 !> @date November, 2013 - Initial Version
+!> @date Spetember, 2015
+!> - manage useless (dummy) dimension
 !>
 !> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -167,4 +169,6 @@
    ! type and variable
    PUBLIC :: TDIM              !< dimension structure
+
+   PRIVATE :: cm_dumdim        !< dummy dimension array
 
    ! function and subroutine
@@ -182,4 +186,6 @@
    PUBLIC :: dim_get_index     !< get dimension index in array of dimension structure
    PUBLIC :: dim_get_id        !< get dimension id in array of dimension structure
+   PUBLIC :: dim_get_dummy     !< fill dummy dimension array
+   PUBLIC :: dim_is_dummy      !< check if dimension is defined as dummy dimension
 
    PRIVATE :: dim__reshape_2xyzt_dp ! reshape real(8) 4D array to ('x','y','z','t')
@@ -209,4 +215,6 @@
    END TYPE
 
+   CHARACTER(LEN=lc), DIMENSION(ip_maxdum), SAVE :: cm_dumdim !< dummy dimension
+
    INTERFACE dim_print
       MODULE PROCEDURE dim__print_unit ! print information on one dimension
@@ -518,8 +526,8 @@
    !> @param[in] ld_uld    dimension unlimited
    !> @param[in] cd_sname  dimension short name
-   !> @param[in] ld_uld    dimension use or not
+   !> @param[in] ld_use    dimension use or not
    !> @return dimension structure
    !-------------------------------------------------------------------
-   TYPE(TDIM) FUNCTION dim_init( cd_name, id_len, ld_uld, cd_sname, ld_use)
+   TYPE(TDIM) FUNCTION dim_init( cd_name, id_len, ld_uld, cd_sname, ld_use )
       IMPLICIT NONE
 
@@ -1401,4 +1409,96 @@
 
    END SUBROUTINE dim__clean_arr
+   !-------------------------------------------------------------------
+   !> @brief This subroutine fill dummy dimension array
+   !
+   !> @author J.Paul
+   !> @date September, 2015 - Initial Version
+   !
+   !> @param[in] cd_dummy dummy configuration file
+   !-------------------------------------------------------------------
+   SUBROUTINE dim_get_dummy( cd_dummy )
+      IMPLICIT NONE
+      ! Argument
+      CHARACTER(LEN=*), INTENT(IN) :: cd_dummy
+
+      ! local variable
+      INTEGER(i4)   :: il_fileid
+      INTEGER(i4)   :: il_status
+
+      LOGICAL       :: ll_exist
+
+      ! loop indices
+      ! namelist
+      CHARACTER(LEN=lc), DIMENSION(ip_maxdum) :: cn_dumvar
+      CHARACTER(LEN=lc), DIMENSION(ip_maxdum) :: cn_dumdim
+      CHARACTER(LEN=lc), DIMENSION(ip_maxdum) :: cn_dumatt
+
+      !----------------------------------------------------------------
+      NAMELIST /namdum/ &   !< dummy namelist
+      &  cn_dumvar, &       !< variable  name
+      &  cn_dumdim, &       !< dimension name
+      &  cn_dumatt          !< attribute name
+      !----------------------------------------------------------------
+
+      ! init
+      cm_dumdim(:)=''
+
+      ! read namelist
+      INQUIRE(FILE=TRIM(cd_dummy), EXIST=ll_exist)
+      IF( ll_exist )THEN
+
+         il_fileid=fct_getunit()
+
+         OPEN( il_fileid, FILE=TRIM(cd_dummy), &
+         &                FORM='FORMATTED',       &
+         &                ACCESS='SEQUENTIAL',    &
+         &                STATUS='OLD',           &
+         &                ACTION='READ',          &
+         &                IOSTAT=il_status)
+         CALL fct_err(il_status)
+         IF( il_status /= 0 )THEN
+            CALL logger_fatal("DIM GET DUMMY: opening "//TRIM(cd_dummy))
+         ENDIF
+
+         READ( il_fileid, NML = namdum )
+         cm_dumdim(:)=cn_dumdim(:)
+
+         CLOSE( il_fileid )
+
+      ENDIF
+
+   END SUBROUTINE dim_get_dummy
+   !-------------------------------------------------------------------
+   !> @brief This function check if dimension is defined as dummy dimension
+   !> in configuraton file
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - Initial Version
+   !
+   !> @param[in] td_dim dimension structure
+   !> @return true if dimension is dummy dimension 
+   !-------------------------------------------------------------------
+   FUNCTION dim_is_dummy(td_dim)
+      IMPLICIT NONE
+
+      ! Argument      
+      TYPE(TDIM), INTENT(IN) :: td_dim
+      
+      ! function
+      LOGICAL :: dim_is_dummy
+      
+      ! loop indices
+      INTEGER(i4) :: ji
+      !----------------------------------------------------------------
+
+      dim_is_dummy=.FALSE.
+      DO ji=1,ip_maxdum
+         IF( fct_lower(td_dim%c_name) == fct_lower(cm_dumdim(ji)) )THEN
+            dim_is_dummy=.TRUE.
+            EXIT
+         ENDIF
+      ENDDO
+
+   END FUNCTION dim_is_dummy
 END MODULE dim
 
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/docsrc/1_install.md
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/docsrc/1_install.md	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/docsrc/1_install.md	(revision 6392)
@@ -1,25 +1,27 @@
-# How to Install
+# Download
 
-# Install NEMO
-to install SIREN, you should first install NEMO.
-see [here](http://www.nemo-ocean.eu/Using-NEMO/User-Guides/Basics/NEMO-Quick-Start-Guide)
+# Download NEMO #
+to install SIREN, you should first download NEMO.
+see [NEMO quick start guide](http://www.nemo-ocean.eu/Using-NEMO/User-Guides/Basics/NEMO-Quick-Start-Guide)
 
-# Compile SIREN
+# Compile SIREN #
 when NEMO is installed, you just have to compile SIREN codes:
-1. go to ./NEMOGCM/TOOLS
-2. use maketools <br/>
-   to get help: maketools -h 
+   1. go to ./NEMOGCM/TOOLS
+   2. run maketools (ex: ./maketools -n SIREN -m ifort_mpi_beaufix)
 
-# Fortran Compiler
-   SIREN codes were succesfully tested with :
-   - ifort (version 15.0.1)
-   - gfortran (version 4.8.2 20140120) 
-<!--   - pgf95 (version 13.9-0) -->
+      @note to get help on maketools: ./maketools -h
 
- <HR>
-   <b>
-   - @ref index
-   - @ref md_docsrc_3_codingRules
-   - @ref md_docsrc_4_changeLog
-   - @ref todo
-   </b>
+# Fortran Compiler #
+SIREN codes were succesfully tested with :
+  - ifort (version 15.0.1)
+  - gfortran (version 4.8.2 20140120) 
+
+<HR>
+  <b>
+  - @ref index
+  - @ref md_docsrc_2_quickstart
+  - @ref md_docsrc_3_support_bug
+  - @ref md_docsrc_4_codingRules
+  - @ref md_docsrc_5_changeLog
+  - @ref todo
+  </b>
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/docsrc/2_quickstart.md
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/docsrc/2_quickstart.md	(revision 6392)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/docsrc/2_quickstart.md	(revision 6392)
@@ -0,0 +1,600 @@
+# How To Use (Quick Start)
+
+@tableofcontents
+
+SIREN is a software to set up regional configuration with
+ [NEMO](http://www.nemo-ocean.eu).<br/> 
+Actually SIREN creates all the input files you need to run a NEMO regional configuration.<br/>
+ 
+SIREN is composed of a set of 5 Fortran programs :
+<ul>
+ <li>create_coord.f90 to create regional grid coordinates.</li>
+ <li>create_bathy.f90 to create regional grid bathymetry.</li>
+ <li>merge_bathy.f90 to merge regional grid bathymetry with wider grid bathymetry
+ at boundaries. 
+ @note the goal of this step is to avoid break in Bathymetry.
+ This break may cause inconsistency between forcing fields  at boundary and regional fields.
+ </li>
+ <li>create_restart.f90 to create initial state file from coarse grid restart
+ or standard outputs.
+ @note this program could also be used to refined other input fields from a wider
+ configuations (as runoff, chlorophyll etc...)
+ </li>
+ <li>create_boundary.F90 to create boundaries conditions from wider configurations
+ output fields.
+ </li>
+</ul>
+
+@warning SIREN can not:
+<ul>
+<li>create global configuration.</li>
+<li>create configuarion around or close to North pole.</li>
+<li>change number of vertical level.</li>
+</ul>
+
+Here after we briefly describe how to use each programs,
+and so how to create your own regional configuration.
+@note A set of GLORYS files (global reanalysis on *ORCA025*
+grid), as well as examples of namelists are available in dods repository.<br/>
+You could create and forced a first release of your own regional configuration,
+with those files. 
+<!-- ######################################################################  -->
+# Create coordinates file # {#coord}
+
+To create your own configuration, you first have to create a coordinates file on your domain of study.<br/>
+SIREN allows you to create this coordinates file from a wider coordinates file.<br/>
+The coordinates file created could simply be an extraction, or a refinment of
+the wide grid.<br/>
+
+To create this new cooridnates file, you have to run :
+~~~~~~~~~~~~~~~~~~
+./SIREN/create_coord.exe create_coord.nam
+~~~~~~~~~~~~~~~~~~
+
+Here after is an example of namelist for *create_coord.exe*.<br/>
+In this example, you create a coordinates file named *coord_fine.nc*.<br/>
+This new coordinates file is refined from an extraction of *coordinates_ORCA025.nc*. 
+~~~~~~~~~~~
+&namlog
+/
+
+&namcfg
+   cn_varcfg = "PATH/NEMOGCM/TOOLS/SIREN/cfg/variable.cfg"
+/
+
+&namcrs
+   cn_coord0 = "PATH/coordinates_ORCA025.nc"
+   in_perio0 = 4
+/
+
+&namvar
+/
+
+&namnst
+   in_imin0 = 1070
+   in_imax0 = 1072
+   in_jmin0 = 607
+   in_jmax0 = 609
+
+   in_rhoi = 2
+   in_rhoj = 3
+/
+
+&namout
+   cn_fileout = "PATH/coord_fine.nc"
+/
+~~~~~~~~~~~
+
+Let's get describe this namelist.<br/>
+First we have the **namlog** sub-namelist. This sub-namelist set parameters of the log
+file.<br/>
+All the parameters of this sub-namelist have default value, so you could let it
+empty, as done here.<br/> This will create a log file named *create_coord.log*
+
+The **namcfg** sub-namelist defines where found SIREN configuration file.<br/>
+This configuration file defines standard name, default interpolation method,
+axis,... to be used for some known variables.<br/>
+Obviously, you could add other variables to those already list, in this file.
+
+@note You could find the generic version of *variable.cfg* in the directory *NEMOGCM/TOOLS/SIREN/cfg*.
+
+The **namcrs** sub-namelist set parameters of the wide
+coordinates file,<br/> as path to find it, and NEMO periodicity of the wide grid.<br/>
+
+@note the NEMO periodicity could be choose between 0 to 6:
+<dl>
+<dt>in_perio=0</dt>
+<dd>standard regional model</dd>
+<dt>in_perio=1</dt>
+<dd>east-west cyclic model</dd>
+<dt>in_perio=2</dt>
+<dd>model with symmetric boundary condition across the equator</dd>
+<dt>in_perio=3</dt>
+<dd>regional model with North fold boundary and T-point pivot</dd>
+<dt>in_perio=4</dt>
+<dd>global model with a T-point pivot.<br/>
+example: ORCA2, ORCA025, ORCA12</dd>
+<dt>in_perio=5</dt>
+<dd>regional model with North fold boundary and F-point pivot</dd>
+<dt>in_perio=6</dt>
+<dd>global model with a F-point pivot<br/>
+example: ORCA05</dd>
+</dl>
+@sa For more information see @ref md_docsrc_6_perio
+</dd>
+</dl>
+
+The **namvar** sub-namelist lists variables to be used.<br/>
+By default all the variables of the wider coordinates file are used to create
+the new coordinates file.<br/> 
+The interpolation methods to be used are defined in the configuration variables file (see
+below). So you do not need to fill this sub-namelist too.
+
+The **namnst** sub-namelist defines the subdomain to be used as well as refinment factor.<br/>
+@note Subdomain is defined by indices of the coarse/wide grid.<br/>
+
+<ul>
+<li>you can select area quite every where (excepted too close from the North
+pole), and use the refinment factor you want.</li>
+
+~~~~~~~~~~~
+&namvar
+   in_imin0 = 1070
+   in_imax0 = 1072
+   in_jmin0 = 607
+   in_jmax0 = 609
+
+   in_rhoi = 2
+   in_rhoj = 3
+/
+~~~~~~~~~~~
+@image html grid_zoom_60.png
+@image latex grid_zoom_40.png
+<!-- @note ghost cells all around the grid are not shown here. -->
+
+<li>you can select area crossing the east-west overlap of the global ORCA grid.</li>
+
+~~~~~~~~~~~
+&namvar          
+   in_imin0 = 1402 
+   in_imax0 = 62
+   in_jmin0 = 490 
+   in_jmax0 = 570 
+
+   in_rhoi = 5
+   in_rhoj = 5 
+/                
+~~~~~~~~~~~
+@image html grid_glob_over_30.png
+@image latex grid_glob_over_20.png
+<!-- @note in blue, the east-west overlap band of ORCA grid. -->
+
+<li>you can select east-west cyclic area.</li>
+
+~~~~~~~~~~~
+&namvar
+   in_imin0 = 0
+   in_imax0 = 0
+   in_jmin0 = 390
+   in_jmax0 = 450
+
+   in_rhoi = 1
+   in_rhoj = 1
+/
+~~~~~~~~~~~
+@image html grid_glob_band_30.png
+@image latex grid_glob_band_20.png
+
+</ul>
+
+Finally the **namout** sub-namelist defines the output file.<br/>
+
+@note All the output files created by SIREN include information about NEMO
+periodicity, as well as source file, indices and refinment used.
+
+@sa For more information about how to create coordinates, see create_coord.f90
+
+<!-- ######################################################################  -->
+# Create bathymetry file # {#bathy}
+
+Then you need a Bathymetry file.<br/>
+SIREN allows you to create a Bathymetry extracted or refined from a wider
+Bathymetry grid.<br/>
+
+To create this new bathymetry, you have to run :
+~~~~~~~~~~~~~~~~~~
+./SIREN/create_bathy.exe create_bathy.nam
+~~~~~~~~~~~~~~~~~~
+
+Here after is an example of namelist for *create_bathy.exe*.<br/>
+In this example, you create a bathymetry file named *bathy_fine.nc*.<br/>
+This new bathymetry file is refined from an extraction of *bathy_meter_ORCA025.nc*.<br/>
+Moreover a minimum value of 5m is imposed to the output Bathymetry.
+~~~~~~~~~~~~~~~~~~
+&namlog
+/
+
+&namcfg
+   cn_varcfg = "PATH/NEMOGCM/TOOLS/SIREN/cfg/variable.cfg"
+/
+
+&namcrs
+   cn_coord0 = "PATH/coordinates_ORCA025.nc"
+   in_perio0 = 4
+/
+
+&namfin
+   cn_coord1 = "PATH/coord_fine.nc"
+/
+
+&namvar
+   cn_varfile = "Bathymetry:PATH/bathy_meter_ORCA025.nc"
+   cn_varinfo = "Bathymetry: min=5"
+/
+
+&namnst
+   in_rhoi = 2
+   in_rhoj = 3
+/
+
+&namout
+   cn_fileout = "PATH/bathy_fine.nc"      
+/
+~~~~~~~~~~~~~~~~~~
+
+Let's get describe this namelist.<br/>
+
+First as previously, we have the **namlog** and **namcfg** sub-namelist (see above for more
+explanation).<br/>
+
+Then the **namcrs** sub-namelist set parameters of the wide
+coordinates file.<br/>
+@note in all SIREN namelist: <br/>
+0 referred to the coarse/wide grid.<br/>
+1 referred to the fine grid.
+
+In the same way, the **namfin** sub-namelist  set parameters of the fine
+coordinates file.<br/>
+@note in this namelist example, there is no need to set the variable *in_perio1* to define the NEMO
+periodicity of the fine grid.<br/> Indeed, if this variable is not inform, SIREN tries to read it in the attributes of the file.<br/> 
+So if you created the fine coordinates with SIREN, you do not have to
+fill it. In other case, you should add it to the namelist.
+
+The **namvar** sub-namelist lists variables to be used:
+<dl>
+   <dt>cn_varfile</dt>
+      <dd> defines the variable name ("Bathymetry" here) and the input file associated with.
+            @warning The domain of the input Bathymetry have to be larger than the output domain.
+         @note 
+         <ul>
+            <li>if the input file is at coarse grid resolution (same than *cn_coord0*), the ouptut Bathymetry will be refined on fine grid.</li>
+            <li>if the input file is a wider bathymetry (already at fine grid resolution), the output Bathymetry will be extracted from this one.</li>
+         </ul>
+      </dd>
+   <dt>cn_varinfo</dt>
+      <dd> defines user's requests for a variable.
+         @note Default interpolation method for the Bathymetry, is *cubic* interpolation.<br/>
+         So you may want to specify a minimum value to avoid negative value, or to change interpolation method.<br/>
+         example: <ul><li>cn_varinfo="Bathymetry: min=1"'</li>
+                      <li>cn_varinfo="Bathymetry: int=linear"</li></ul>
+      </dd>
+</dl>
+
+The **namnst** sub-namelist defines the subdomain refinment factor.<br/>
+Of course those refinment factors have to be convenient with refinment
+from coarse grid *cn_coord0* to fine grid *cn_coord1*.
+@note subdomain indices are automatically deduced from fine and coarse grid
+coordinates.
+
+Finally, this **namout** sub-namelist defines the output file.<br/>
+
+@note All the output files create by SIREN include information about 
+source file, indices, refinment and interpolation method used.
+
+@sa For more information about how to create bathymetry, see
+create_bathy.f90
+
+<!-- ######################################################################  -->
+# Merge bathymetry file # {#merge}
+
+The Bathymetry you build differs from the wider one.<br/>
+To avoid issue with boundaries forcing fields, you should merge fine and coarse Bathymetry on boundaries.<br/>
+SIREN allows you to do this.<br/>
+
+To create this merged bathymetry, you have to run :
+~~~~~~~~~~~~~~~~~~
+./SIREN/merge_bathy.exe merge_bathy.nam
+~~~~~~~~~~~~~~~~~~
+
+Here after is an example of namelist for *merge_bathy.exe*.<br/>
+~~~~~~~~~~~~~~~~~~
+&namlog
+/
+
+&namcfg
+   cn_varcfg = "PATH/NEMOGCM/TOOLS/SIREN/cfg/variable.cfg"
+/
+
+&namcrs
+   cn_bathy0 = "PATH/bathy_meter_ORCA025.nc"
+   in_perio0 = 4
+/
+
+&namfin
+   cn_bathy1 = "PATH/bathy_fine.nc"
+/
+
+&namnst
+   in_rhoi = 3
+   in_rhoj = 3
+/
+
+&nambdy
+/
+
+&namout
+   cn_fileout = "PATH/bathy_merged.nc"      
+/
+~~~~~~~~~~~~~~~~~~
+In this namelist, you find again the **namlog**, **namcfg** describe above.
+
+Then the **namcrs** sub-namelist sets parameters of the wider grid.
+However this time, this is the coarse/wide grid Bathymetry wich have to be informed.
+
+The **namfin** sub-namelist defines parameters of the fine grid Bathymetry.
+@note here again you could add the *in_perio1* parameter if need be i.e. if your
+fine grid Bathymetry was not created by SIREN.
+
+The **namnst** sub-namelist defines the subdomain refinment factor.
+
+
+The **nambdy** sub-namelist defines the subdomain boundaries.<br/>
+By default SIREN tries to create boundaries for each side. Boundary exist if there is at least one sea point on the second row of each side.<br/>
+So you could let this namelist empty.
+
+@sa For more information about boundaries, see @ref boundary
+
+Finally, this **namout** sub-namelist defines the output file.<br/>
+
+@sa For more information about how to merge bathymetry, see
+merge_bathy.f90
+
+<!-- ######################################################################  -->
+# Create initial state # {#restart}
+
+To run your configuration you need an inital state of the ocean.<br/>
+You could start from a restart file (with all NEMO variables fields at one
+time step). Or you could start from "partial" information about ocean state (Temperature and Salinity for example).
+
+Siren allows you to create both of those initial state.<br/>
+To create the initial state, you have to run:<br/>
+~~~~~~~~~~~~~~~~~~
+./SIREN/create_restart.exe create_restart.nam
+~~~~~~~~~~~~~~~~~~
+
+Here after is an example of namelist for *create_restart.exe*.<br/>
+In this example, you create an initial state split on 81 "processors", and named restar_out.nc.<br/>
+The initial state is composed of temperature and salinity refined from an extraction of GLORYS fields.
+~~~~~~~~~~~~~~~~~~
+&namlog
+/
+
+&namcfg
+   cn_varcfg = "PATH/NEMOGCM/TOOLS/SIREN/cfg/variable.cfg"
+/
+
+&namcrs
+   cn_coord0 = "PATH/coordinates_ORCA025.nc"
+   in_perio0 = 4
+/
+
+&namfin
+   cn_coord1 = "PATH/coord_fine.nc"
+   cn_bathy1 = "PATH/bathy_merged.nc"
+/
+
+&namzgr
+/
+
+&namzps
+/
+
+&namvar
+   cn_varfile = "votemper:GLORYS_gridT.nc",
+                "vosaline:GLORYS_gridS.nc"
+/
+
+&namnst
+   in_rhoi = 3
+   in_rhoj = 3
+/
+
+&namout
+   cn_fileout = "PATH/restart_out.nc"      
+   in_nproc = 81
+/
+~~~~~~~~~~~~~~~~~~
+Let's get describe this namelist more accurately.<br/>
+
+As previously, we have the **namlog** and **namcfg** sub-namelists, as well as 
+the **namcrs** sub-namelist to set parameters of the wide coordinates file (see above for more
+explanation).<br/>
+
+Then the **namfin** sub-namelist set parameters of the fine
+grid coordinates and bathymetry.<br/>
+
+The **namzgr** and **namzps** sub-namelists define respectively parameters for vertical grid
+and partial step.<br>
+By default, those parameters are defined the same way than in GLORYS (i.e. 75 vertical levels).<br/>
+So you could let it empty.
+@note If you use forcing fields other than GLORYS, you have to be sure it uses the same vertical grid. In other case, you need to get information about the parametrisation use, and to put it in those sub-namelist (see create_restart.f90).
+
+the **namvar** sub-namelist lists variables to be used.<br/>
+Here we use *votemper* (temperature) get from *GLORYS_gridT.nc* file, and *vosaline*
+(salinity) get from *GLORYS_gridS.nc* file.
+@note To get all variables of a restart file. You have to use:
+~~~~~~~~~~~~~~~~~~
+cn_varfile = "all:PATH/restart.dimg"
+~~~~~~~~~~~~~~~~~~
+
+The **namnst** sub-namelist defines the subdomain refinment factor, as seen previously.<br/>
+
+Finally, this **namout** sub-namelist defines the output files.<br/>
+Here we ask for output on 81 processors, with *restart_out.nc* as file "basename".<br/>
+So SIREN computes the optimal layout for 81 porcessors
+available,<br/>
+and split restart on output files named *restart_out_num.nc*, where *num* is the porc number.
+
+@note SIREN could also create the other fields you may need for
+your configuration.<br/>
+To do so, you just have to run *create_restart.exe* with other variable(s) from other input file(s).<br/>
+For example, to get runoff fields, you could use:
+~~~~~~~~~~~~~~~~~~
+cn_varfile = "sorunoff:PATH/runoff_GLORYS.nc"
+...
+cn_fileout = "PATH/runoff_out.nc"
+~~~~~~~~~~~~~~~~~~
+
+@sa For more information about how to create initial state or other fields, see
+create_restart.f90
+
+<!-- ######################################################################  -->
+# Create boundaries conditions # {#boundary}
+
+Finally to force your configuration, you may need boundaries conditions.<br/>
+NEMO read physical boundaries conditions from temperature, salinity, currents, and sea
+surface height.
+
+To create the boundaries condition with SIREN, you have to run:<br/>
+~~~~~~~~~~~~~~~~~~
+./SIREN/create_boundary.exe create_boundary.nam
+~~~~~~~~~~~~~~~~~~
+
+Here after is an example of namelist for *create_boundary.exe*.<br/>
+In this example, you create boundaries conditions named *boundary_out.nc* on
+each side of the domain.<br/>
+The boundaries contain information about temperature, salinity, currents and sea surface height refined from an extraction of GLORYS fields.
+~~~~~~~~~~~~~~~~~~
+&namlog
+/
+
+&namcfg
+   cn_varcfg = "PATH/NEMOGCM/TOOLS/SIREN/cfg/variable.cfg"
+/
+
+&namcrs
+   cn_coord0 = "PATH/coordinates_ORCA025.nc"
+   in_perio0 = 4
+/
+
+&namfin
+   cn_coord1 = "PATH/coord_fine.nc"
+   cn_bathy1 = "PATH/bathy_fine.nc"
+/
+
+&namzgr
+/
+
+&namzps
+/
+
+&namvar
+   cn_varfile="votemper:GLORYS_gridT.nc",
+              "vosaline:GLORYS_gridS.nc",
+              "vozocrtx:GLORYS_gridU.nc",
+              "vomecrty:GLORYS_gridV.nc",
+              "sossheig:GLORYS_grid2D.nc"
+/
+
+&namnst
+   in_rhoi = 3
+   in_rhoj = 3
+/
+
+&nambdy
+/
+
+&namout
+   cn_fileout = "PATH/boundary_out.nc"      
+/
+~~~~~~~~~~~~~~~~~~
+
+Let's get describe this namelist more accurately.<br/>
+
+As previously, we have the **namlog** and **namcfg** sub-namelists, as well as 
+the **namcrs** sub-namelist to set parameters of the wide coordinates file (see above for more
+explanation).<br/>
+
+Then the **namfin** sub-namelist set parameters of the fine
+grid coordinates and bathymetry.<br/>
+
+The **namzgr** and **namzps** sub-namelists define respectively parameters for vertical grid
+and partial step.<br>
+By default, those parameters are defined the same way than in GLORYS (i.e. 75 vertical levels).<br/>
+So you could let it empty.
+@note If you use forcing fields other than GLORYS, you have to be sure it uses the same vertical grid. In other case, you need to get information about the parametrisation use, and to put it in those sub-namelist (see create_boundary.F90).
+
+the **namvar** sub-namelist lists variables to be used.<br/>
+Here we get *votemper* (temperature) from *GLORYS_gridT.nc* file, *vosaline*
+(salinity) from *GLORYS_gridS.nc* file, *vozocrtx* (zonal velocity) from
+*GLORYS_gridU.nc*, *vomecrty* (meridional velocity) from *GLORYS_gridV.nc*, and sossheig (sea surface
+height) from *GLORYS_grid2D.nc*.
+
+The **namnst** sub-namelist defines the subdomain refinment factor.<br/>
+
+The **nambdy** sub-namelist defines the subdomain boundaries.<br/>
+By default SIREN tries to create boundaries for each side (Boundary is created if sea point exist on the second row of each side).<br/>
+So you could let this namelist empty.
+
+@note SIREN allows you to place boundaries away from the side of the domain.
+To do so you have to define your boundary.<br/>
+That means you have to give on fine
+grid the index of the boundary (how far from the border your boundary is),
+the width of your boundary, and finally first and last point of your boundary (the length of your boundary).<br/>
+So to define a north boundary, you have to add in the sub-namelist *nambdy*, the parameter:
+~~~~~~~~~~~~~~~~~~
+cn_north="index,first:last(width)"
+~~~~~~~~~~~~~~~~~~
+
+Finally, this **namout** sub-namelist defines the output files.<br/>
+Here we ask for output with *boundary_out.nc* as file "basename".<br/>
+So SIREN creates output files named *boundary_out_west.nc*,
+*boundary_out_east.nc*, *boundary_out_north.nc*, and *boundary_out_south.nc*
+depending if boundary exist or not.
+
+@sa For more information about how to create boundaries condition, see
+create_boundary.F90
+
+# Create and run NEMO configuration # {#NEMOconf}
+
+So now you created all the input files you need for your physical configuration, you have to create the "NEMO configuration".<br/>
+To do so, go to the directory *NEMOGCM/CONFIG/*, and run:
+~~~~~~~~~~~~~~~~~~
+./makenemo -n MY_CONFIG -d "OPA_SRC"
+~~~~~~~~~~~~~~~~~~
+This creates your configuration "MY_CONFIG" in the directory *NEMOGCM/CONFIG*.<br/>
+you could check the cpp_keys used in file *cpp_MY_CONFIG.fcm*, and re-run *makenemo*
+if need be.
+
+Once *makenemo* has run successfully, the *opa* executable is available in
+directory *NEMOGCM/CONFIG/MY_CONFIG/EXP00*.<br/>
+Then you just have to put all your input files in this directory, fill the namelist *namelist_cfg*, and run:
+~~~~~~~~~~~~~~~~~~
+mpirun ./opa
+~~~~~~~~~~~~~~~~~~
+
+@note no surface forcing here.
+weighted function needed to do interpolation on the fly, could be created by WEIGHT tools already inside NEMO.
+
+@sa For more information about how to create NEMO configuration see [NEMO Quick Start Guide](http://www.nemo-ocean.eu/Using-NEMO/User-Guides/Basics/NEMO-Quick-Start-Guide).
+
+ <HR>
+   <b>
+   - @ref index
+   - @ref md_docsrc_1_install
+   - @ref md_docsrc_2_quickstart
+   - @ref md_docsrc_3_support_bug
+   - @ref md_docsrc_4_codingRules
+   - @ref md_docsrc_5_changeLog
+   - @ref todo
+   </b>
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/docsrc/3_codingRules.md
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/docsrc/3_codingRules.md	(revision 6384)
+++ 	(revision )
@@ -1,98 +1,0 @@
-# Coding Rules
-
-The conventions used in SIREN coding are based on the NEMO coding rules
-(see [NEMO coding
-conventions](http://www.nemo-ocean.eu/content/download/15483/73221/file/NEMO_coding.conv_v3.pdf)).<br/>
-However some modifications were added to improve readibility of the code.<br/>
-Some of the NEMO coding rules are reminded here, and extensions are described.
-
-@tableofcontents
-
-# Fortran Standard {#std}
-
-SIREN software adhere to strict __FORTRAN 95__ standard.<br/>
-There is only one exception. The use of functions _COMMAND_ARGUMENT_COUNT_ and
-_GET_COMMAND_ARGUMENT_.<br/>
-There exist no equivalent for those Fortran 03 intrinsec functions in Fortran
-95.<br/> At least none convenient for compilers tested (see @ref md_docsrc_1_install). 
-
-#  Free Form Source {#free}
-Free Form Source will be used, however a self imposed limit of 80 should
-enhance readibility.
-
-#  Indentation {#indent}
-Code as well as comments lines will be indented 3 characters for readibility.<br/>
-__Indentation should be write without hard tabs__.
-
-Example for vi  :
-~~~~~~~~~~~~~~~~~~~~~
-:set expandtab tabstop=3 shiftwidth=3
-~~~~~~~~~~~~~~~~~~~~~
-
-#  Naming conventions : variable {#namvar}
-All variables should be named as explicitly as possible.<br/>
-The naming conventions concerns prefix letters of these name, in order to
-identify the variable type and status.<br/> It must be composed of two
-letters defining type and status follow by an underscore.<br/>
-table below list the starting letters to be used for variable naming,
-depending on their type and status.
-
- | Type / Status     | byte (integer(1)) <br/> __b__ | short (integer(2)) <br/> __s__ | integer(4) <br/> __i__  | integer(8) <br/> __k__ | real(4) <br/> __r__ | real(8) <br/> __d__ | logical <br/> __l__ | character <br/> __c__ | complex <br/> __y__ | structure <br/> __t__  |
- | :----:            | :----: | :----: | :----: | :----: | :----: | :----: | :----: | :----: | :----: | :----: |
- |global <br/> __g__           | bg_  | sg_  | ig_  | kg_  | rg_  | dg_  | lg_  | cg_  | yg_  | tg_  |
- |global parameter <br/> __p__ | bp_  | sp_  | ip_  | kp_  | rp_  | dp_  | lp_  | cp_  | yp_  | tp_  |
- |module <br/> __m__           | bm_  | sm_  | im_  | km_  | rm_  | dm_  | lm_  | cm_  | ym_  | tm_  |
- |namelist <br/> __n__         | bn_  | sn_  | in_  | kn_  | rn_  | dn_  | ln_  | cn_  | yn_  | tn_  |
- |dummy argument <br/> __d__   | bd_  | sd_  | id_  | kd_  | rd_  | dd_  | ld_  | cd_  | yd_  | td_  |
- |local <br/> __l__            | bl_  | sl_  | il_  | kl_  | rl_  | dl_  | ll_  | cl_  | yl_  | tl_  |
- |loop control       |      |      | j?   |      |      |      |      |      |      |      |
-
-# Naming conventions : structure {#namstr}
-The structure name should be written in capital letter, and start with
-__T__<br/> Example: TTRACER <br/>
-Variables inside the structure should be named as explicitly as possible.<br/>
-For those variables, the prefix naming conventions only concern the type of variable.<br/>
-It must be composed of one letter defining type follows by an
-underscore.<br/>
-see table of variable conventions.<br/>
-
-Example: __tl\_type\%i\_year__<br/> _year_ is an integer(4) variable in a local strucure
-named _type_. <br/>
-
-# Naming conventions : function-subroutine {#namsub}
-Functions or Subroutines are defined in a module.<br/>
-Their name should start with the module name then with their "functional" name. So it will be
-easy to find it.<br/>
-Example:<br/> a function to realise addition written in a module
-__math__ should be called __math\_add__.<br/>
-
-__PUBLIC__  function or subroutine should used one undescrore: _math_add_<br/>
-__PRIVATE__ function or subroutine should used two undescrores: _math__add_<br/>
-
-# Precision {#precision}
-__All variables should make use of kinds__.<br/>
-Numerical constant need to have a suffix of __kindvalue__
-
-# Declaration for global variable and constants {#global}
-All global data must be accompanied with a comment field on the same
-line.<br/>
-_Note that using doxygen (see [header](#header)), we will use symbol !< instead of !: as separator_
-
-# Implicit none {#implicit}
-All subroutines and functions will include an IMPLICIT NONE statement.
-
-# Header {#header}
-
-SIREN use __doxigen auto documentation__ tool.<br/>
-Information could be find on
-[doxygen](http://www.stack.nl/~dimitri/doxygen/index.html) web page.<br/>
-Some basic tag are described
-[here](http://www.msg.chem.iastate.edu/gamess/DoxygenRules.oct10.pdf).
-
- <HR>
-   <b>
-   - @ref index
-   - @ref md_docsrc_1_install
-   - @ref md_docsrc_4_changeLog
-   - @ref todo
-   </b>
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/docsrc/3_support_bug.md
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/docsrc/3_support_bug.md	(revision 6392)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/docsrc/3_support_bug.md	(revision 6392)
@@ -0,0 +1,28 @@
+# Support
+
+# How to get support
+  If you have questions regarding the use of SIREN, please have a look at the [NEMO configuration manager forum](https://forge.ipsl.jussieu.fr/nemo/discussion/forum/2).<br/>
+  If you don't find an answer in the archives, feel free to register and post your question.
+
+# How to Help
+   The development of SIREN highly depends on your input!<br/>
+   If you are trying SIREN let me know what you think of it (do you miss certain features?). Even if you decide not to use it, please let me know why.
+
+# How to report a bug
+   If you believe you have found a new bug, please report it.<br/>
+   Before submitting a new bug, first search through the database if the same bug has already been submitted by others
+
+   If you send only a (vague) description of a bug, you are usually not very
+   helpful and it will cost much more time to figure out what you mean. In
+   the worst-case your bug report may even be completely ignored.
+
+ <HR>
+   <b>
+   - @ref index
+   - @ref md_docsrc_1_install
+   - @ref md_docsrc_2_quickstart
+   - @ref md_docsrc_3_support_bug
+   - @ref md_docsrc_4_codingRules
+   - @ref md_docsrc_5_changeLog
+   - @ref todo
+   </b>
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/docsrc/4_changeLog.md
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/docsrc/4_changeLog.md	(revision 6384)
+++ 	(revision )
@@ -1,18 +1,0 @@
-# Change log
-
-@tableofcontents
-
-# Release 3.6
-Initial release (release date )
-
-## Changes
-## New Features
-## Bug fixes
-
- <HR>
-   <b>
-   - @ref index
-   - @ref md_docsrc_1_install
-   - @ref md_docsrc_3_codingRules
-   - @ref todo
-   </b>
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/docsrc/4_codingRules.md
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/docsrc/4_codingRules.md	(revision 6392)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/docsrc/4_codingRules.md	(revision 6392)
@@ -0,0 +1,100 @@
+# Coding Rules
+
+The conventions used in SIREN coding are based on the NEMO coding rules
+(see [NEMO coding
+conventions](http://www.nemo-ocean.eu/content/download/15483/73221/file/NEMO_coding.conv_v3.pdf)).<br/>
+However some modifications were added to improve readibility of the code.<br/>
+Some of the NEMO coding rules are reminded here, and extensions are described.
+
+@tableofcontents
+
+# Fortran Standard {#std}
+
+SIREN software adhere to strict __FORTRAN 95__ standard.<br/>
+There is only one exception. The use of functions _COMMAND_ARGUMENT_COUNT_ and
+_GET_COMMAND_ARGUMENT_.<br/>
+There exist no equivalent for those Fortran 03 intrinsec functions in Fortran
+95.<br/> At least none convenient for compilers tested (see @ref md_docsrc_1_install). 
+
+#  Free Form Source {#free}
+Free Form Source will be used, however a self imposed limit of 80 should
+enhance readibility.
+
+#  Indentation {#indent}
+Code as well as comments lines will be indented 3 characters for readibility.<br/>
+__Indentation should be write without hard tabs__.
+
+Example for vi  :
+~~~~~~~~~~~~~~~~~~~~~
+:set expandtab tabstop=3 shiftwidth=3
+~~~~~~~~~~~~~~~~~~~~~
+
+#  Naming conventions : variable {#namvar}
+All variables should be named as explicitly as possible.<br/>
+The naming conventions concerns prefix letters of these name, in order to
+identify the variable type and status.<br/> It must be composed of two
+letters defining type and status follow by an underscore.<br/>
+table below list the starting letters to be used for variable naming,
+depending on their type and status.
+
+ | Type / Status     | byte (integer(1)) <br/> __b__ | short (integer(2)) <br/> __s__ | integer(4) <br/> __i__  | integer(8) <br/> __k__ | real(4) <br/> __r__ | real(8) <br/> __d__ | logical <br/> __l__ | character <br/> __c__ | complex <br/> __y__ | structure <br/> __t__  |
+ | :----:            | :----: | :----: | :----: | :----: | :----: | :----: | :----: | :----: | :----: | :----: |
+ |global <br/> __g__           | bg_  | sg_  | ig_  | kg_  | rg_  | dg_  | lg_  | cg_  | yg_  | tg_  |
+ |global parameter <br/> __p__ | bp_  | sp_  | ip_  | kp_  | rp_  | dp_  | lp_  | cp_  | yp_  | tp_  |
+ |module <br/> __m__           | bm_  | sm_  | im_  | km_  | rm_  | dm_  | lm_  | cm_  | ym_  | tm_  |
+ |namelist <br/> __n__         | bn_  | sn_  | in_  | kn_  | rn_  | dn_  | ln_  | cn_  | yn_  | tn_  |
+ |dummy argument <br/> __d__   | bd_  | sd_  | id_  | kd_  | rd_  | dd_  | ld_  | cd_  | yd_  | td_  |
+ |local <br/> __l__            | bl_  | sl_  | il_  | kl_  | rl_  | dl_  | ll_  | cl_  | yl_  | tl_  |
+ |loop control       |      |      | j?   |      |      |      |      |      |      |      |
+
+# Naming conventions : structure {#namstr}
+The structure name should be written in capital letter, and start with
+__T__<br/> Example: TTRACER <br/>
+Variables inside the structure should be named as explicitly as possible.<br/>
+For those variables, the prefix naming conventions only concern the type of variable.<br/>
+It must be composed of one letter defining type follows by an
+underscore.<br/>
+see table of variable conventions.<br/>
+
+Example: __tl\_type\%i\_year__<br/> _year_ is an integer(4) variable in a local strucure
+named _type_. <br/>
+
+# Naming conventions : function-subroutine {#namsub}
+Functions or Subroutines are defined in a module.<br/>
+Their name should start with the module name then with their "functional" name. So it will be
+easy to find it.<br/>
+Example:<br/> a function to realise addition written in a module
+__math__ should be called __math\_add__.<br/>
+
+__PUBLIC__  function or subroutine should used one undescrore: _math_add_<br/>
+__PRIVATE__ function or subroutine should used two undescrores: _math__add_<br/>
+
+# Precision {#precision}
+__All variables should make use of kinds__.<br/>
+Numerical constant need to have a suffix of __kindvalue__
+
+# Declaration for global variable and constants {#global}
+All global data must be accompanied with a comment field on the same
+line.<br/>
+_Note that using doxygen (see [header](#header)), we will use symbol !< instead of !: as separator_
+
+# Implicit none {#implicit}
+All subroutines and functions will include an IMPLICIT NONE statement.
+
+# Header {#header}
+
+SIREN use __doxigen auto documentation__ tool.<br/>
+Information could be find on
+[doxygen](http://www.stack.nl/~dimitri/doxygen/index.html) web page.<br/>
+Some basic tag are described
+[here](http://www.msg.chem.iastate.edu/gamess/DoxygenRules.oct10.pdf).
+
+ <HR>
+   <b>
+   - @ref index
+   - @ref md_docsrc_1_install
+   - @ref md_docsrc_2_quickstart
+   - @ref md_docsrc_3_support_bug
+   - @ref md_docsrc_5_changeLog
+   - @ref todo
+   </b>
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/docsrc/5_changeLog.md
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/docsrc/5_changeLog.md	(revision 6392)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/docsrc/5_changeLog.md	(revision 6392)
@@ -0,0 +1,20 @@
+# Change log
+
+@tableofcontents
+
+# Release $Revision$
+Initial release (2016-03-17)
+
+## Changes
+## New Features
+## Bug fixes
+
+ <HR>
+   <b>
+   - @ref index
+   - @ref md_docsrc_1_install
+   - @ref md_docsrc_2_quickstart
+   - @ref md_docsrc_3_support_bug
+   - @ref md_docsrc_4_codingRules
+   - @ref todo
+   </b>
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/docsrc/6_perio.md
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/docsrc/6_perio.md	(revision 6392)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/docsrc/6_perio.md	(revision 6392)
@@ -0,0 +1,34 @@
+# NEMO periodicity
+
+NEMO periodicity is defined as follow :<br/> 
+<dl>
+<dt>closed boundary (in_perio=0)</dt>
+<dd>ghost cells (solid walls) are imposed at all model boundaries.</dd> 
+@image html perio0_20.png 
+@image latex perio0_20.png
+<dt>cyclic east-west boundary (in_perio=1)</dt>
+<dd>first and last rows are closed, whilst the first column is set to the value of the last-but-one column and the last column to the value of the second one.</dd>  
+@image html perio1_20.png 
+@image latex perio1_20.png
+<dt>symmetric boundary condition across the equator. (in_perio=2)</dt>
+<dd>last row, and first and last columns are closed. </dd> 
+@image html perio2_20.png 
+@image latex perio2_20.png
+<dt>North fold boundary with a T -point pivot (in_perio=3)</dt>
+<dd>first row, and first and last columns are closed. </dd> 
+@image html perio3_20.png 
+@image latex perio3_20.png
+<dt>North fold boundary with a T -point pivot and cyclic east-west boundary (in_perio=4)</dt>
+<dd>first row is closed. The first column is set to the value of the last-but-one column and the last column to the value of the second one. </dd> 
+@image html perio4_20.png 
+@image latex perio4_20.png
+<dt>North fold boundary with a F -point pivot (in_perio=5)</dt>
+<dd>first row, and first and last columns are closed. </dd> 
+@image html perio5_20.png 
+@image latex perio5_20.png
+<dt>North fold boundary with a F -point pivot and cyclic east-west boundary (in_perio=6)</dt>
+<dd>first row is closed. The first column is set to the value of the last-but-one column and the last column to the value of the second one.</dd> 
+@image html perio6_20.png 
+@image latex perio6_20.png
+</dl>
+@sa For more information about NEMO periodicity, see _Model Boundary Condition_ chapter in [NEMO documentation](http://www.nemo-ocean.eu/About-NEMO/Reference-manuals))
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/docsrc/main.dox
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/docsrc/main.dox	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/docsrc/main.dox	(revision 6392)
@@ -1,41 +1,32 @@
 /*!
- @mainpage Main Page
- @section descr Generic Description
- SIREN is a software to create regional configuration with
- [NEMO](http://www.nemo-ocean.eu).<br/> 
+ @mainpage About 
+
+ SIREN is a software to create regional configuration with [NEMO](http://www.nemo-ocean.eu).<br/> 
  Actually SIREN create input files needed for a basic NEMO configuration.<br/>
+
+ SIREN allows you to create your own regional configuration embedded in a wider one.<br/>
+ In order to help you, a set of GLORYS files (global reanalysis on ORCA025 grid), as well as examples
+ of namelists are available in dods repository.
+
+ @note This software was created, and is maintain by the Configuration Manager Working Group, composed
+ of NEMO system team members.
  
- SIREN is composed of a set of 5 Fortran programs :
-   - create_coord.f90 to create fine grid coordinate file from coarse grid coordinate file.
-   - create_bathy.f90 to create fine grid bathymetry file over domain.
-   - merge_bathy.f90 to merge fine grid bathymetry with coarse grid bathymetry at boundaries.
-   - create_restart.f90 to create initial state file from coarse grid restart or standard outputs.
-   - create_boundary.f90 to create boundary condition from coarse grid standard outputs.
+ To know how to install SIREN see @ref md_docsrc_1_install.
 
-To install those programs see @ref md_docsrc_1_install.
-
- @note SIREN can not:
- - create global configuration
- - create configuarion around or close to north pole
- - change number of vertical level
- - change grid (horizontal or vertical)
-
- @section howto How to use
-   @subsection howto_coord to create fine grid coordinate file
-   see create_coord.f90
-   @subsection howto_bathy to create fine grid bathymetry
-   see create_bathy.f90
-   @subsection howto_merge to merge fine grid bathymetry
-   see merge_bathy.f90
-   @subsection howto_restart to create initial state file
-   see create_restart.f90
-   @subsection howto_boundary to create boundary condition
-   see create_boundary.f90
+ You could find a tutorial for a quick start with SIREN in @ref md_docsrc_2_quickstart.<br/>
+ For more information about how to use each component of SIREN
+ - see create_coord.f90 to create fine grid coordinate file
+ - see create_bathy.f90 to create fine grid bathymetry
+ - see merge_bathy.f90 to merge fine grid bathymetry
+ - see create_restart.f90 to create initial state file, or other fields.
+ - see create_boundary.F90 to create boundary condition
 
 <HR>
    <b>
    - @ref md_docsrc_1_install
-   - @ref md_docsrc_3_codingRules
-   - @ref md_docsrc_4_changeLog
+   - @ref md_docsrc_2_quickstart
+   - @ref md_docsrc_3_support_bug
+   - @ref md_docsrc_4_codingRules
+   - @ref md_docsrc_5_changeLog
    - @ref todo
    </b>
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/domain.f90
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/domain.f90	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/domain.f90	(revision 6392)
@@ -1297,4 +1297,6 @@
    !> @date September, 2014
    !> - take into account number of ghost cell
+   !> @date February, 2016
+   !> - number of extra point is the MAX (not the MIN) of zero and asess value. 
    !
    !> @param[inout] td_dom domain strcuture
@@ -1344,5 +1346,5 @@
                   td_dom%i_imin      = td_dom%i_imin - td_dom%i_iextra(1)
                ELSE ! td_dom%i_imin - il_iext <= td_dom%i_ghost0(jp_I,1)*ip_ghost
-                  td_dom%i_iextra(1) = MIN(0, &
+                  td_dom%i_iextra(1) = MAX(0, &
                   &                         td_dom%i_imin - &
                   &                         td_dom%i_ghost0(jp_I,1)*ip_ghost -1)
@@ -1356,5 +1358,5 @@
                ELSE ! td_dom%i_imax + il_iext >= &
                     !  td_dom%t_dim0(1)%i_len - td_dom%i_ghost0(jp_I,2)*ip_ghost
-                  td_dom%i_iextra(2) = MIN(0, &
+                  td_dom%i_iextra(2) = MAX( 0, &
                   &                         td_dom%t_dim0(1)%i_len - &
                   &                         td_dom%i_ghost0(jp_I,2)*ip_ghost - &
@@ -1364,4 +1366,5 @@
 
             ELSE ! td_dom%i_ew0 >= 0
+
                ! EW cyclic
                IF( td_dom%i_imin - il_iext > 0 )THEN
@@ -1391,9 +1394,10 @@
             ! nothing to be done
          ELSE
+
             IF( td_dom%i_jmin - il_jext > td_dom%i_ghost0(jp_J,1)*ip_ghost )THEN
                td_dom%i_jextra(1) = il_jext
                td_dom%i_jmin      = td_dom%i_jmin - td_dom%i_jextra(1)
             ELSE ! td_dom%i_jmin - il_jext <= td_dom%i_ghost0(jp_J,1)*ip_ghost
-               td_dom%i_jextra(1) = MIN(0, &
+               td_dom%i_jextra(1) = MAX( 0, &
                &                         td_dom%i_jmin - &
                &                         td_dom%i_ghost0(jp_J,1)*ip_ghost - 1)
@@ -1407,5 +1411,5 @@
             ELSE ! td_dom%i_jmax + il_jext >= &
                  !  td_dom%t_dim0(2)%i_len - td_dom%i_ghost0(jp_J,2)*ip_ghost
-               td_dom%i_jextra(2) = MIN(0, &
+               td_dom%i_jextra(2) = MAX( 0, &
                &                         td_dom%t_dim0(2)%i_len - &
                &                         td_dom%i_ghost0(jp_J,2)*ip_ghost - &
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/file.f90
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/file.f90	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/file.f90	(revision 6392)
@@ -694,6 +694,8 @@
    !> @date November, 2013 - Initial Version
    !> @date September, 2014
-   !> - add dimension to file if need be
+   !> - add dimension in file if need be
    !> - do not reorder dimension from variable, before put in file
+   !> @date September, 2015
+   !> - check variable dimension expected
    !
    !> @param[inout] td_file   file structure
@@ -705,5 +707,5 @@
       ! Argument      
       TYPE(TFILE), INTENT(INOUT) :: td_file
-      TYPE(TVAR) , INTENT(IN   ) :: td_var
+      TYPE(TVAR) , INTENT(INOUT) :: td_var
 
       ! local variable
@@ -761,4 +763,7 @@
                IF( file_check_var_dim(td_file, td_var) )THEN
 
+                  ! check variable dimension expected
+                  CALL var_check_dim(td_var)
+
                   ! update dimension if need be
                   DO ji=1,ip_maxdim
@@ -1050,5 +1055,4 @@
                   ! new number of variable in file
                   td_file%i_nvar=td_file%i_nvar-1
-
                   SELECT CASE(td_var%i_ndim)
                      CASE(0)
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/function.f90
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/function.f90	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/function.f90	(revision 6392)
@@ -363,5 +363,5 @@
       IF( id_status /= 0 )THEN
          !CALL ERRSNS() ! not F95 standard
-         PRINT *, "FORTRAN ERROR"
+         PRINT *, "FORTRAN ERROR ",id_status
          !STOP
       ENDIF
@@ -740,5 +740,5 @@
    !
    !> @param[in] cd_var character
-   !> @return character is numeric
+   !> @return character is real number
    !-------------------------------------------------------------------
    PURE LOGICAL FUNCTION fct_is_real(cd_var)
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/global.f90
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/global.f90	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/global.f90	(revision 6392)
@@ -12,4 +12,6 @@
 ! REVISION HISTORY:
 !> @date November, 2013 - Initial Version
+!> @date September, 2015
+!> - define fill value for each variable type
 !
 !> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -95,5 +97,9 @@
    &     'gauss      '/)
 
-   REAL(dp)                                , PARAMETER :: dp_fill=NF90_FILL_DOUBLE !< default fill value
+   REAL(dp)                                , PARAMETER :: dp_fill_i1=NF90_FILL_BYTE   !< byte fill value
+   REAL(dp)                                , PARAMETER :: dp_fill_i2=NF90_FILL_SHORT  !< short fill value
+   REAL(dp)                                , PARAMETER :: dp_fill_i4=NF90_FILL_INT    !< INT fill value
+   REAL(dp)                                , PARAMETER :: dp_fill_sp=NF90_FILL_FLOAT  !< real fill value
+   REAL(dp)                                , PARAMETER :: dp_fill=NF90_FILL_DOUBLE !< double fill value
 
    INTEGER(i4)                             , PARAMETER :: ip_npoint=4
@@ -125,5 +131,5 @@
    INTEGER(i4), PARAMETER :: jp_west =4
 
-
+   INTEGER(i4)                             , PARAMETER :: ip_maxdum = 10 !< maximum dummy variable, dimension, attribute
 
 END MODULE global
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/grid.f90
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/grid.f90	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/grid.f90	(revision 6392)
@@ -80,5 +80,6 @@
 !> point:<br/>
 !> @code
-!>    il_index(:)=grid_get_closest(dd_lon0(:,:), dd_lat0(:,:), dd_lon1, dd_lat1)
+!>    il_index(:)=grid_get_closest(dd_lon0(:,:), dd_lat0(:,:), dd_lon1, dd_lat1
+!>                                 [,dd_fill] [,cd_pos])
 !> @endcode
 !>       - il_index(:) is  coarse grid indices (/ i0, j0 /)
@@ -87,4 +88,6 @@
 !>       - dd_lon1 is fine grid longitude value (real(8))
 !>       - dd_lat1 is fine grid latitude  value (real(8))
+!>       - dd_fill
+!>       - cd_pos
 !>
 !>    to compute distance between a point A and grid points:<br/>
@@ -215,4 +218,7 @@
 !> @date February, 2015
 !> - add function grid_fill_small_msk to fill small domain inside bigger one
+!> @February, 2016
+!> - improve way to check coincidence (bug fix)
+!> - manage grid cases for T,U,V or F point, with even or odd refinment (bug fix)
 !
 !> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -664,5 +670,5 @@
             
             ! no pivot point found
-            CALL logger_error("GRID GET PIVOT: something wrong "//&
+            CALL logger_warn("GRID GET PIVOT: something wrong "//&
             &  "when computing pivot point with variable "//&
             &  TRIM(td_var%c_name))
@@ -685,5 +691,5 @@
 
                IF( grid__get_pivot_var /= -1 )THEN
-                  CALL logger_warn("GRID GET PIVOT: variable "//&
+                  CALL logger_info("GRID GET PIVOT: variable "//&
                   &  TRIM(td_var%c_name)//" seems to be on grid point "//&
                   &  TRIM(cp_grid_point(jj)) )
@@ -1335,7 +1341,7 @@
          il_dim(:)=td_var%t_dim(:)%i_len
 
-         CALL logger_info("GRID GET PERIO: use varibale "//TRIM(td_var%c_name))
-         CALL logger_info("GRID GET PERIO: fill value "//TRIM(fct_str(td_var%d_fill)))
-         CALL logger_info("GRID GET PERIO: fill value "//TRIM(fct_str(td_var%d_value(1,1,1,1))))
+         CALL logger_debug("GRID GET PERIO: use varibale "//TRIM(td_var%c_name))
+         CALL logger_debug("GRID GET PERIO: fill value "//TRIM(fct_str(td_var%d_fill)))
+         CALL logger_debug("GRID GET PERIO: first value "//TRIM(fct_str(td_var%d_value(1,1,1,1))))
 
          IF(ALL(td_var%d_value(    1    ,    :    ,1,1)/=td_var%d_fill).AND.&
@@ -1344,7 +1350,18 @@
          &  ALL(td_var%d_value(    :    ,il_dim(2),1,1)/=td_var%d_fill))THEN
          ! no boundary closed
-            CALL logger_warn("GRID GET PERIO: can't determined periodicity. "//&
+            CALL logger_error("GRID GET PERIO: can't determined periodicity. "//&
             &             "there is no boundary closed for variable "//&
             &              TRIM(td_var%c_name) )
+            ! check pivot
+            SELECT CASE(id_pivot)
+               CASE(0)
+                  ! F pivot
+                  CALL logger_warn("GRID GET PERIO: assume domain is global")
+                  grid__get_perio_var=6
+               CASE(1)
+                  ! T pivot
+                  CALL logger_warn("GRID GET PERIO: assume domain is global")
+                  grid__get_perio_var=4
+            END SELECT
          ELSE
             ! check periodicity
@@ -2287,5 +2304,4 @@
          &                                                    il_rho(:), cl_point )
 
-         
          CALL var_clean(tl_lon1)
          CALL var_clean(tl_lat1)         
@@ -2463,4 +2479,7 @@
    !> - check grid point
    !> - take into account EW overlap
+   !> @date February, 2016
+   !> - use delta (lon or lat)
+   !> - manage cases for T,U,V or F point, with even or odd refinment
    !>
    !> @param[in] td_lon0   coarse grid longitude
@@ -2490,54 +2509,49 @@
 
       ! local variable
-      REAL(dp)    :: dl_lon1_ll
-      REAL(dp)    :: dl_lon1_ul
-      REAL(dp)    :: dl_lon1_lr
-      REAL(dp)    :: dl_lon1_ur
-
-      REAL(dp)    :: dl_lat1_ll
-      REAL(dp)    :: dl_lat1_ul
-      REAL(dp)    :: dl_lat1_lr
-      REAL(dp)    :: dl_lat1_ur
+      CHARACTER(LEN= 1)                      :: cl_point0
+      CHARACTER(LEN= 1)                      :: cl_point1
+
+      LOGICAL    , DIMENSION(2)              :: ll_even
+
+      REAL(dp)                               :: dl_lon1
+      REAL(dp)                               :: dl_dlon
+      REAL(dp)                               :: dl_lat1
+      REAL(dp)                               :: dl_dlat
+
+      INTEGER(i4)                            :: il_ew0 
+      INTEGER(i4)                            :: il_imin0
+      INTEGER(i4)                            :: il_imax0
+      INTEGER(i4)                            :: il_jmin0
+      INTEGER(i4)                            :: il_jmax0
+
+      INTEGER(i4)                            :: il_ew1 
+      INTEGER(i4)                            :: il_imin1
+      INTEGER(i4)                            :: il_imax1
+      INTEGER(i4)                            :: il_jmin1
+      INTEGER(i4)                            :: il_jmax1
+
+      INTEGER(i4)                            :: il_imin
+      INTEGER(i4)                            :: il_imax
+      INTEGER(i4)                            :: il_jmin
+      INTEGER(i4)                            :: il_jmax      
 
       INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_rho
 
-      INTEGER(i4), DIMENSION(2) :: il_ill
-      INTEGER(i4), DIMENSION(2) :: il_ilr
-      INTEGER(i4), DIMENSION(2) :: il_iul
-      INTEGER(i4), DIMENSION(2) :: il_iur
-
-      INTEGER(i4) :: il_ew0 
-      INTEGER(i4) :: il_imin0
-      INTEGER(i4) :: il_imax0
-      INTEGER(i4) :: il_jmin0
-      INTEGER(i4) :: il_jmax0
-
-      INTEGER(i4) :: il_ew1 
-      INTEGER(i4) :: il_imin1
-      INTEGER(i4) :: il_imax1
-      INTEGER(i4) :: il_jmin1
-      INTEGER(i4) :: il_jmax1
-
-      INTEGER(i4) :: il_imin
-      INTEGER(i4) :: il_imax
-      INTEGER(i4) :: il_jmin
-      INTEGER(i4) :: il_jmax      
-
-      INTEGER(i4), DIMENSION(2,2) :: il_xghost0
-      INTEGER(i4), DIMENSION(2,2) :: il_yghost0
-      INTEGER(i4), DIMENSION(2,2) :: il_xghost1
-      INTEGER(i4), DIMENSION(2,2) :: il_yghost1
-
-      TYPE(TVAR) :: tl_lon0
-      TYPE(TVAR) :: tl_lat0
-      TYPE(TVAR) :: tl_lon1
-      TYPE(TVAR) :: tl_lat1
-
-      CHARACTER(LEN= 1) :: cl_point0
-      CHARACTER(LEN= 1) :: cl_point1
-      
+      INTEGER(i4), DIMENSION(2)              :: il_ill
+      INTEGER(i4), DIMENSION(2)              :: il_ilr
+      INTEGER(i4), DIMENSION(2)              :: il_iul
+      INTEGER(i4), DIMENSION(2)              :: il_iur
+
+      INTEGER(i4), DIMENSION(2,2)            :: il_xghost0
+      INTEGER(i4), DIMENSION(2,2)            :: il_yghost0
+      INTEGER(i4), DIMENSION(2,2)            :: il_xghost1
+      INTEGER(i4), DIMENSION(2,2)            :: il_yghost1
+
+      TYPE(TVAR)                             :: tl_lon0
+      TYPE(TVAR)                             :: tl_lat0
+      TYPE(TVAR)                             :: tl_lon1
+      TYPE(TVAR)                             :: tl_lat1
+
       ! loop indices
-      INTEGER(i4) :: ji
-      INTEGER(i4) :: jj
       !----------------------------------------------------------------
       ! init
@@ -2547,4 +2561,6 @@
       il_rho(:)=1
       IF( PRESENT(id_rho) ) il_rho(:)=id_rho(:)
+
+      ll_even(:)=(/ (MOD(id_rho(jp_I),2)==0), (MOD(id_rho(jp_J),2)==0) /)
 
       cl_point0='T'
@@ -2645,19 +2661,53 @@
             ! get indices for each corner
             !1- search lower left corner indices
-            dl_lon1_ll=tl_lon1%d_value( il_imin1, il_jmin1, 1, 1 )
-            dl_lat1_ll=tl_lat1%d_value( il_imin1, il_jmin1, 1, 1 )
-
-            IF( dl_lon1_ll == tl_lon1%d_fill .OR. &
-            &   dl_lat1_ll == tl_lat1%d_fill )THEN
-               CALL logger_debug("GRID GET COARSE INDEX: lon "//&
-               &  TRIM(fct_str(dl_lon1_ll))//" "//&
-               &  TRIM(fct_str(tl_lon1%d_fill)) )
-               CALL logger_debug("GRID GET COARSE INDEX: lat "//&
-               &  TRIM(fct_str(dl_lat1_ll))//" "//&
-               &  TRIM(fct_str(tl_lat1%d_fill)) )
+            dl_lon1=tl_lon1%d_value( il_imin1, il_jmin1, 1, 1 )
+            dl_lat1=tl_lat1%d_value( il_imin1, il_jmin1, 1, 1 )
+
+            IF( dl_lon1 == tl_lon1%d_fill .OR. &
+            &   dl_lat1 == tl_lat1%d_fill )THEN
                CALL logger_error("GRID GET COARSE INDEX: lower left corner "//&
                &                 "point is FillValue. remove ghost cell "//&
                &                 "before running grid_get_coarse_index.")
             ENDIF
+
+            !!!!! i-direction !!!!!
+            IF( ll_even(jp_I) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point1))
+                  CASE('F','U')
+                     dl_dlon= ( tl_lon1%d_value(il_imin1+1,il_jmin1,1,1) -   &
+                        &       tl_lon1%d_value(il_imin1  ,il_jmin1,1,1) ) / &
+                        &     2.
+                  CASE DEFAULT
+                     dl_dlon=0
+               END SELECT
+            ELSE
+               ! odd
+               dl_dlon= ( tl_lon1%d_value(il_imin1+1,il_jmin1,1,1) -   &
+                  &       tl_lon1%d_value(il_imin1  ,il_jmin1,1,1) ) / &
+                  &     2.
+            ENDIF
+
+            !!!!! j-direction !!!!!
+            IF( ll_even(jp_J) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point1))
+                  CASE('F','V')
+                     dl_dlat= ( tl_lat1%d_value(il_imin1,il_jmin1+1,1,1) -   &
+                        &       tl_lat1%d_value(il_imin1,il_jmin1  ,1,1) ) / &
+                        &     2.
+                  CASE DEFAULT
+                     dl_dlat=0
+               END SELECT
+            ELSE
+               ! odd
+               dl_dlat= ( tl_lat1%d_value(il_imin1,il_jmin1+1,1,1) -   &
+                  &       tl_lat1%d_value(il_imin1,il_jmin1  ,1,1) ) / &
+                  &     2.
+            ENDIF
+
+            dl_lon1 = dl_lon1 + dl_dlon
+            dl_lat1 = dl_lat1 + dl_dlat
+
             ! look for closest point on coarse grid
             il_ill(:)= grid_get_closest(tl_lon0%d_value(il_imin0:il_imax0, &
@@ -2667,45 +2717,57 @@
             &                                           il_jmin0:il_jmax0, &
             &                                           1,1), &
-            &                           dl_lon1_ll, dl_lat1_ll   )
-
-            ! coarse grid point should be south west of fine grid domain
-            ji = il_ill(1)
-            jj = il_ill(2)
-
-            IF( ABS(tl_lon0%d_value(ji,jj,1,1)-dl_lon1_ll) > dp_delta )THEN
-               IF(tl_lon0%d_value(ji,jj,1,1) > dl_lon1_ll )THEN
-                  il_ill(1)=il_ill(1)-1
-                  IF( il_ill(1) <= 0 )THEN
-                     IF( tl_lon0%i_ew >= 0 )THEN
-                        il_ill(1)=tl_lon0%t_dim(jp_I)%i_len-tl_lon0%i_ew
-                     ELSE
-                        CALL logger_error("GRID GET COARSE INDEX: error "//&
-                        &                 "computing lower left corner "//&
-                        &                 "index for longitude")
-                     ENDIF
-                  ENDIF
-               ENDIF
-            ENDIF
-            IF( ABS(tl_lat0%d_value(ji,jj,1,1)-dl_lat1_ll) > dp_delta )THEN
-               IF(tl_lat0%d_value(ji,jj,1,1) > dl_lat1_ll )THEN
-                  il_ill(2)=il_ill(2)-1
-                  IF( il_ill(2)-1 <= 0 )THEN
-                     CALL logger_error("GRID GET COARSE INDEX: error "//&
-                     &                 "computing lower left corner "//&
-                     &                 "index for latitude")
-                  ENDIF
-               ENDIF
-            ENDIF
+            &                           dl_lon1, dl_lat1, 'll'   )
+
 
             !2- search upper left corner indices
-            dl_lon1_ul=tl_lon1%d_value( il_imin1, il_jmax1, 1, 1 )
-            dl_lat1_ul=tl_lat1%d_value( il_imin1, il_jmax1, 1, 1 )
-
-            IF( dl_lon1_ul == tl_lon1%d_fill .OR. &
-            &   dl_lat1_ul == tl_lat1%d_fill )THEN
+            dl_lon1=tl_lon1%d_value( il_imin1, il_jmax1, 1, 1 )
+            dl_lat1=tl_lat1%d_value( il_imin1, il_jmax1, 1, 1 )
+
+            IF( dl_lon1 == tl_lon1%d_fill .OR. &
+            &   dl_lat1 == tl_lat1%d_fill )THEN
                CALL logger_error("GRID GET COARSE INDEX: upper left corner "//&
                &                 "point is FillValue. remove ghost cell "//&
                &                 "running grid_get_coarse_index.")
             ENDIF            
+
+            !!!!! i-direction !!!!!
+            IF( ll_even(jp_I) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point1))
+                  CASE('F','U')
+                     dl_dlon= ( tl_lon1%d_value(il_imin1+1,il_jmax1,1,1) -   &
+                        &       tl_lon1%d_value(il_imin1  ,il_jmax1,1,1) ) / &
+                        &     2.
+                  CASE DEFAULT
+                     dl_dlon=0
+               END SELECT
+            ELSE
+               ! odd
+               dl_dlon= ( tl_lon1%d_value(il_imin1+1,il_jmax1,1,1) -   &
+                  &       tl_lon1%d_value(il_imin1  ,il_jmax1,1,1) ) / &
+                  &     2.
+            ENDIF
+
+            !!!!! j-direction !!!!!
+            IF( ll_even(jp_J) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point1))
+                  CASE('F','V')
+                     dl_dlat= ( tl_lat1%d_value(il_imin1,il_jmax1  ,1,1) -   &
+                        &       tl_lat1%d_value(il_imin1,il_jmax1-1,1,1) ) / &
+                        &     2.
+                  CASE DEFAULT
+                     dl_dlat=0
+               END SELECT
+            ELSE
+               ! odd
+               dl_dlat= ( tl_lat1%d_value(il_imin1,il_jmax1  ,1,1) -   &
+                  &       tl_lat1%d_value(il_imin1,il_jmax1-1,1,1) ) / &
+                  &     2.
+            ENDIF
+
+            dl_lon1 = dl_lon1 + dl_dlon
+            dl_lat1 = dl_lat1 - dl_dlat
+
             ! look for closest point on coarse grid
             il_iul(:)= grid_get_closest(tl_lon0%d_value(il_imin0:il_imax0, &
@@ -2715,44 +2777,56 @@
             &                                           il_jmin0:il_jmax0, &
             &                                           1,1), &
-            &                           dl_lon1_ul, dl_lat1_ul   )
-
-            ! coarse grid point should be north west of fine grid domain
-            ji = il_iul(1)
-            jj = il_iul(2)
-            IF( ABS(tl_lon0%d_value(ji,jj,1,1)-dl_lon1_ul) > dp_delta )THEN
-               IF(tl_lon0%d_value(ji,jj,1,1) > dl_lon1_ul )THEN
-                  il_iul(1)=il_iul(1)-1
-                  IF( il_iul(1) <= 0 )THEN
-                     IF( tl_lon0%i_ew >= 0 )THEN
-                        il_iul(1)=tl_lon0%t_dim(jp_I)%i_len-tl_lon0%i_ew
-                     ELSE
-                        CALL logger_error("GRID GET COARSE INDEX: error "//&
-                        &                 "computing upper left corner "//&
-                        &                 "index for longitude")
-                     ENDIF
-                  ENDIF
-               ENDIF
-            ENDIF
-            IF( ABS(tl_lat0%d_value(ji,jj,1,1)-dl_lat1_ul) > dp_delta )THEN
-               IF(tl_lat0%d_value(ji,jj,1,1) < dl_lat1_ul )THEN
-                  il_iul(2)=il_iul(2)+1
-                  IF( il_ill(2) > tl_lat0%t_dim(jp_J)%i_len )THEN
-                     CALL logger_error("GRID GET COARSE INDEX: error "//&
-                     &                 "computing upper left corner "//&
-                     &                 "index for latitude")
-                  ENDIF
-               ENDIF
-            ENDIF
+            &                           dl_lon1, dl_lat1, 'ul' )
 
             !3- search lower right corner indices
-            dl_lon1_lr=tl_lon1%d_value( il_imax1, il_jmin1, 1, 1 )
-            dl_lat1_lr=tl_lat1%d_value( il_imax1, il_jmin1, 1, 1 )
-
-            IF( dl_lon1_lr == tl_lon1%d_fill .OR. &
-            &   dl_lat1_lr == tl_lat1%d_fill )THEN
+            dl_lon1=tl_lon1%d_value( il_imax1, il_jmin1, 1, 1 )
+            dl_lat1=tl_lat1%d_value( il_imax1, il_jmin1, 1, 1 )
+
+            IF( dl_lon1 == tl_lon1%d_fill .OR. &
+            &   dl_lat1 == tl_lat1%d_fill )THEN
                CALL logger_error("GRID GET COARSE INDEX: lower right corner "//&
                &                 "point is FillValue. remove ghost cell "//&
                &                 "running grid_get_coarse_index.")
             ENDIF            
+
+            !!!!! i-direction !!!!!
+            IF( ll_even(jp_I) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point1))
+                  CASE('F','U')
+                     dl_dlon= ( tl_lon1%d_value(il_imax1  ,il_jmin1,1,1) -   &
+                        &       tl_lon1%d_value(il_imax1-1,il_jmin1,1,1) ) / &
+                        &     2.
+                  CASE DEFAULT
+                     dl_dlon=0
+               END SELECT
+            ELSE
+               ! odd
+               dl_dlon= ( tl_lon1%d_value(il_imax1  ,il_jmin1,1,1) -   &
+                  &       tl_lon1%d_value(il_imax1-1,il_jmin1,1,1) ) / &
+                  &     2.
+            ENDIF
+
+            !!!!! j-direction !!!!!
+            IF( ll_even(jp_J) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point1))
+                  CASE('F','V')
+                     dl_dlat= ( tl_lat1%d_value(il_imax1,il_jmin1+1,1,1) -   &
+                        &       tl_lat1%d_value(il_imax1,il_jmin1  ,1,1) ) / &
+                        &     2.
+                  CASE DEFAULT
+                     dl_dlat=0
+               END SELECT
+            ELSE
+               ! odd
+               dl_dlat= ( tl_lat1%d_value(il_imax1,il_jmin1+1,1,1) -   &
+                  &       tl_lat1%d_value(il_imax1,il_jmin1  ,1,1) ) / &
+                  &     2.
+            ENDIF
+
+            dl_lon1 = dl_lon1 - dl_dlon
+            dl_lat1 = dl_lat1 + dl_dlat
+
             ! look for closest point on coarse grid
             il_ilr(:)= grid_get_closest(tl_lon0%d_value(il_imin0:il_imax0, &
@@ -2762,44 +2836,56 @@
             &                                           il_jmin0:il_jmax0, &
             &                                           1,1), &
-            &                           dl_lon1_lr, dl_lat1_lr   )
-
-            ! coarse grid point should be south east of fine grid domain
-            ji = il_ilr(1)
-            jj = il_ilr(2)
-            IF( ABS(tl_lon0%d_value(ji,jj,1,1)-dl_lon1_lr) > dp_delta )THEN
-               IF( tl_lon0%d_value(ji,jj,1,1) < dl_lon1_lr )THEN
-                  il_ilr(1)=il_ilr(1)+1
-                  IF( il_ilr(1) > tl_lon0%t_dim(jp_I)%i_len )THEN
-                     IF( tl_lon0%i_ew >= 0 )THEN
-                        il_ilr(1)=tl_lon0%i_ew+1
-                     ELSE
-                        CALL logger_error("GRID GET COARSE INDEX: error "//&
-                        &                 "computing lower right corner "//&
-                        &                 "index for longitude")
-                     ENDIF
-                  ENDIF
-               ENDIF
-            ENDIF
-            IF( ABS(tl_lat0%d_value(ji,jj,1,1)-dl_lat1_lr) > dp_delta )THEN
-               IF( tl_lat0%d_value(ji,jj,1,1) > dl_lat1_lr )THEN
-                  il_ilr(2)=il_ilr(2)-1
-                  IF( il_ilr(2) <= 0 )THEN
-                     CALL logger_error("GRID GET COARSE INDEX: error "//&
-                     &                 "computing lower right corner "//&
-                     &                 "index for latitude")
-                  ENDIF
-               ENDIF
-            ENDIF
+            &                           dl_lon1, dl_lat1, 'lr' )
 
             !4- search upper right corner indices
-            dl_lon1_ur=tl_lon1%d_value( il_imax1, il_jmax1, 1, 1 )
-            dl_lat1_ur=tl_lat1%d_value( il_imax1, il_jmax1, 1, 1 )
-
-            IF( dl_lon1_ur == tl_lon1%d_fill .OR. &
-            &   dl_lat1_ur == tl_lat1%d_fill )THEN
+            dl_lon1=tl_lon1%d_value( il_imax1, il_jmax1, 1, 1 )
+            dl_lat1=tl_lat1%d_value( il_imax1, il_jmax1, 1, 1 )
+
+            IF( dl_lon1 == tl_lon1%d_fill .OR. &
+            &   dl_lat1 == tl_lat1%d_fill )THEN
                CALL logger_error("GRID GET COARSE INDEX: upper right corner "//&
                &                 "point is FillValue. remove ghost cell "//&
-               &                 "running grid_get_coarse_index.")
+               &                 "before running grid_get_coarse_index.")
             ENDIF            
+
+            !!!!! i-direction !!!!!
+            IF( ll_even(jp_I) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point1))
+                  CASE('F','U')
+                     dl_dlon= ( tl_lon1%d_value(il_imax1  ,il_jmax1,1,1) -   &
+                        &       tl_lon1%d_value(il_imax1-1,il_jmax1,1,1) ) / &
+                        &     2.
+                  CASE DEFAULT
+                     dl_dlon=0
+               END SELECT
+            ELSE
+               ! odd
+               dl_dlon= ( tl_lon1%d_value(il_imax1  ,il_jmax1,1,1) -   &
+                  &       tl_lon1%d_value(il_imax1-1,il_jmax1,1,1) ) / &
+                  &     2.
+            ENDIF
+
+            !!!!! j-direction !!!!!
+            IF( ll_even(jp_J) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point1))
+                  CASE('F','V')
+                     dl_dlat= ( tl_lat1%d_value(il_imax1,il_jmax1  ,1,1) -   &
+                        &       tl_lat1%d_value(il_imax1,il_jmax1-1,1,1) ) / &
+                        &     2.
+                  CASE DEFAULT
+                     dl_dlat=0
+               END SELECT
+            ELSE
+               ! odd
+               dl_dlat= ( tl_lat1%d_value(il_imax1,il_jmax1  ,1,1) -   &
+                  &       tl_lat1%d_value(il_imax1,il_jmax1-1,1,1) ) / &
+                  &     2.
+            ENDIF
+
+            dl_lon1 = dl_lon1 - dl_dlon
+            dl_lat1 = dl_lat1 - dl_dlat
+
             ! look for closest point on coarse grid
             il_iur(:)= grid_get_closest(tl_lon0%d_value(il_imin0:il_imax0, &
@@ -2809,33 +2895,5 @@
             &                                           il_jmin0:il_jmax0, &
             &                                           1,1), &
-            &                           dl_lon1_ur, dl_lat1_ur   )
-
-            ! coarse grid point should be north east fine grid domain
-            ji = il_iur(1)
-            jj = il_iur(2)
-            IF( ABS(tl_lon0%d_value(ji,jj,1,1)-dl_lon1_ur) > dp_delta )THEN
-               IF( tl_lon0%d_value(ji,jj,1,1) < dl_lon1_ur )THEN
-                  il_iur(1)=il_iur(1)+1
-                  IF( il_iur(1) > tl_lon0%t_dim(jp_I)%i_len )THEN
-                     IF( tl_lon0%i_ew >= 0 )THEN
-                        il_iur(1)=tl_lon0%i_ew+1
-                     ELSE
-                        CALL logger_error("GRID GET COARSE INDEX: error "//&
-                        &                 "computing upper right corner "//&
-                        &                 "index for longitude")
-                     ENDIF
-                  ENDIF
-               ENDIF
-            ENDIF
-            IF( ABS(tl_lat0%d_value(ji,jj,1,1)-dl_lat1_ur) > dp_delta )THEN
-               IF( tl_lat0%d_value(ji,jj,1,1) < dl_lat1_ur )THEN
-                  il_iur(2)=il_iur(2)+1
-                  IF( il_iur(2) > tl_lat0%t_dim(jp_J)%i_len )THEN
-                     CALL logger_error("GRID GET COARSE INDEX: error "//&
-                     &                 "computing upper right corner "//&
-                     &                 "index for latitude")
-                  ENDIF
-               ENDIF
-            ENDIF
+            &                           dl_lon1, dl_lat1, 'ur' )
 
             ! coarse grid indices
@@ -2943,6 +3001,6 @@
    END FUNCTION grid_is_global
    !-------------------------------------------------------------------
-   !> @brief This function return coarse grid indices of the closest point
-   !> from fine grid point (lon1,lat1) 
+   !> @brief This function return grid indices of the closest point
+   !> from point (lon1,lat1) 
    !> 
    !> @details
@@ -2951,7 +3009,20 @@
    !> of longitude and latitude, before running this function
    !>
+   !> if you add cd_pos argument, you could choice to return closest point at
+   !> - lower left  (ll) of the point
+   !> - lower right (lr) of the point
+   !> - upper left  (ul) of the point
+   !> - upper right (ur) of the point
+   !> - lower       (lo) of the point
+   !> - upper       (up) of the point
+   !> -       left  (le) of the point
+   !> -       right (ri) of the point
+   !>
    !> @author J.Paul
    !> @date November, 2013 - Initial Version
-   !> @date February, 2015 - change dichotomy method to manage ORCA grid
+   !> @date February, 2015
+   !> - change dichotomy method to manage ORCA grid
+   !> @date February, 2016
+   !> - add optional use of relative position
    !
    !> @param[in] dd_lon0   coarse grid array of longitude
@@ -2959,8 +3030,9 @@
    !> @param[in] dd_lon1   fine   grid longitude
    !> @param[in] dd_lat1   fine   grid latitude
+   !> @param[in] cd_pos    relative position of grid point from point 
    !> @param[in] dd_fill   fill value
    !> @return coarse grid indices of closest point of fine grid point
    !-------------------------------------------------------------------
-   FUNCTION grid_get_closest( dd_lon0, dd_lat0, dd_lon1, dd_lat1, dd_fill )
+   FUNCTION grid_get_closest( dd_lon0, dd_lat0, dd_lon1, dd_lat1, cd_pos, dd_fill )
       IMPLICIT NONE
       ! Argument
@@ -2969,4 +3041,5 @@
       REAL(dp),                 INTENT(IN) :: dd_lon1
       REAL(dp),                 INTENT(IN) :: dd_lat1
+      CHARACTER(LEN=*),         INTENT(IN), OPTIONAL :: cd_pos
       REAL(dp),                 INTENT(IN), OPTIONAL :: dd_fill
 
@@ -3147,4 +3220,45 @@
       &                          dl_lon1, dd_lat1 )
 
+      IF( PRESENT(cd_pos) )THEN
+         ! 
+         SELECT CASE(TRIM(cd_pos))
+            CASE('le')
+               WHERE( dd_lat0(il_iinf:il_isup,il_jinf:il_jsup) > dd_lat1 )
+                  dl_dist(:,:)=NF90_FILL_DOUBLE
+               END WHERE
+            CASE('ri')
+               WHERE( dd_lat0(il_iinf:il_isup,il_jinf:il_jsup) < dd_lat1 )
+                  dl_dist(:,:)=NF90_FILL_DOUBLE
+               END WHERE
+            CASE('up')
+               WHERE( dl_lon0(il_iinf:il_isup,il_jinf:il_jsup) < dl_lon1 )
+                  dl_dist(:,:)=NF90_FILL_DOUBLE
+               END WHERE
+            CASE('lo')
+               WHERE( dl_lon0(il_iinf:il_isup,il_jinf:il_jsup) > dl_lon1 )
+                  dl_dist(:,:)=NF90_FILL_DOUBLE
+               END WHERE
+            CASE('ll')
+               WHERE( dl_lon0(il_iinf:il_isup,il_jinf:il_jsup) > dl_lon1 .OR. &
+                    & dd_lat0(il_iinf:il_isup,il_jinf:il_jsup) > dd_lat1 )
+                  dl_dist(:,:)=NF90_FILL_DOUBLE
+               END WHERE
+            CASE('lr')
+               WHERE( dl_lon0(il_iinf:il_isup,il_jinf:il_jsup) < dl_lon1 .OR. &
+                    & dd_lat0(il_iinf:il_isup,il_jinf:il_jsup) > dd_lat1 )
+                  dl_dist(:,:)=NF90_FILL_DOUBLE
+               END WHERE               
+            CASE('ul')
+               WHERE( dl_lon0(il_iinf:il_isup,il_jinf:il_jsup) > dl_lon1 .OR. &
+                    & dd_lat0(il_iinf:il_isup,il_jinf:il_jsup) < dd_lat1 )
+                  dl_dist(:,:)=NF90_FILL_DOUBLE
+               END WHERE               
+            CASE('ur')
+               WHERE( dl_lon0(il_iinf:il_isup,il_jinf:il_jsup) < dl_lon1 .OR. &
+                    & dd_lat0(il_iinf:il_isup,il_jinf:il_jsup) < dd_lat1 )
+                  dl_dist(:,:)=NF90_FILL_DOUBLE
+               END WHERE
+         END SELECT
+      ENDIF
       grid_get_closest(:)=MINLOC(dl_dist(:,:),dl_dist(:,:)/=NF90_FILL_DOUBLE)
 
@@ -3443,5 +3557,5 @@
          &                                         il_imax0, il_jmax0, &
          &                                         dl_lon1(:,:), dl_lat1(:,:),&
-         &                                         id_rho(:) )
+         &                                         id_rho(:), cl_point )
  
          DEALLOCATE(dl_lon0, dl_lat0)
@@ -3588,5 +3702,5 @@
          &                                         id_imax0, id_jmax0, &
          &                                         dl_lon1(:,:), dl_lat1(:,:),&
-         &                                         id_rho(:) )
+         &                                         id_rho(:), cl_point )
          
          DEALLOCATE(dl_lon1, dl_lat1)
@@ -3668,5 +3782,4 @@
       ! init
       grid__get_fine_offset_fc(:,:)=-1
-
       ALLOCATE(il_rho(ip_maxdim))
       il_rho(:)=1
@@ -3690,5 +3803,5 @@
          CALL iom_mpp_open(tl_coord0)
 
-         ! read coarse longitue and latitude
+         ! read coarse longitude and latitude
          WRITE(cl_name,*) 'longitude_'//TRIM(cl_point)
          il_ind=var_get_id(tl_coord0%t_proc(1)%t_var(:), cl_name)
@@ -3710,5 +3823,5 @@
          ENDIF
          tl_lat0=iom_mpp_read_var(tl_coord0, TRIM(cl_name))
-         
+ 
          ! close mpp files
          CALL iom_mpp_close(tl_coord0)
@@ -3716,4 +3829,5 @@
          CALL grid_del_ghost(tl_lon0, il_xghost0(:,:))
          CALL grid_del_ghost(tl_lat0, il_xghost0(:,:))
+
 
          ALLOCATE(dl_lon0(tl_lon0%t_dim(jp_I)%i_len, &
@@ -3738,5 +3852,4 @@
          il_jmax0=id_jmax0-il_xghost0(jp_J,1)
 
-      
          !3- compute
          grid__get_fine_offset_fc(:,:)=grid_get_fine_offset(&
@@ -3745,5 +3858,5 @@
          &                                         il_imax0, il_jmax0, &
          &                                         dd_lon1(:,:), dd_lat1(:,:),&
-         &                                         id_rho(:) )
+         &                                         id_rho(:), cl_point )
          
          DEALLOCATE(dl_lon0, dl_lat0)
@@ -3767,4 +3880,14 @@
    !> @date May, 2015 
    !> - improve way to find offset
+   !> @date July, 2015
+   !> - manage case close to greenwich meridian
+   !> @date February, 2016
+   !> - use grid_get_closest to assess offset
+   !> - use delta (lon or lat)
+   !> - manage cases for T,U,V or F point, with even or odd refinment
+   !> - check lower left(upper right) fine grid point inside lower left(upper
+   !> right) coarse grid cell.
+   !> 
+   !> @todo check case close from North fold.
    !>
    !> @param[in] dd_lon0   coarse grid longitude array 
@@ -3777,22 +3900,24 @@
    !> @param[in] dd_lat1   fine   grid latitude  array
    !> @param[in] id_rho    array of refinement factor
+   !> @param[in] cd_point  Arakawa grid point
    !> @return offset array (/ (/i_offset_left,i_offset_right/),(/j_offset_lower,j_offset_upper/) /)
    !-------------------------------------------------------------------
    FUNCTION grid__get_fine_offset_cc( dd_lon0, dd_lat0, &
    &                                  id_imin0, id_jmin0, id_imax0, id_jmax0, &
-   &                                  dd_lon1, dd_lat1, id_rho )
+   &                                  dd_lon1, dd_lat1, id_rho, cd_point )
       IMPLICIT NONE
       ! Argument
-      REAL(dp)   , DIMENSION(:,:), INTENT(IN) :: dd_lon0
-      REAL(dp)   , DIMENSION(:,:), INTENT(IN) :: dd_lat0
-      REAL(dp)   , DIMENSION(:,:), INTENT(IN) :: dd_lon1
-      REAL(dp)   , DIMENSION(:,:), INTENT(IN) :: dd_lat1
-
-      INTEGER(i4),                 INTENT(IN) :: id_imin0
-      INTEGER(i4),                 INTENT(IN) :: id_jmin0
-      INTEGER(i4),                 INTENT(IN) :: id_imax0
-      INTEGER(i4),                 INTENT(IN) :: id_jmax0
-
-      INTEGER(i4), DIMENSION(:)  , INTENT(IN) :: id_rho
+      REAL(dp)        , DIMENSION(:,:), INTENT(IN) :: dd_lon0
+      REAL(dp)        , DIMENSION(:,:), INTENT(IN) :: dd_lat0
+      REAL(dp)        , DIMENSION(:,:), INTENT(IN) :: dd_lon1
+      REAL(dp)        , DIMENSION(:,:), INTENT(IN) :: dd_lat1
+
+      INTEGER(i4)     ,                 INTENT(IN) :: id_imin0
+      INTEGER(i4)     ,                 INTENT(IN) :: id_jmin0
+      INTEGER(i4)     ,                 INTENT(IN) :: id_imax0
+      INTEGER(i4)     ,                 INTENT(IN) :: id_jmax0
+
+      INTEGER(i4)     , DIMENSION(:)  , INTENT(IN) :: id_rho
+      CHARACTER(LEN=*)                , INTENT(IN), OPTIONAL :: cd_point
 
       ! function
@@ -3800,17 +3925,33 @@
 
       ! local variable
+      CHARACTER(LEN= 1)                        :: cl_point
+
+      INTEGER(i4)                              :: i1
+      INTEGER(i4)                              :: i2
+      INTEGER(i4)                              :: j1
+      INTEGER(i4)                              :: j2
+
       INTEGER(i4), DIMENSION(2)                :: il_shape0
       INTEGER(i4), DIMENSION(2)                :: il_shape1
 
+      INTEGER(i4), DIMENSION(2)                :: il_ind
+
       REAL(dp)   , DIMENSION(:,:), ALLOCATABLE :: dl_lon0
       REAL(dp)   , DIMENSION(:,:), ALLOCATABLE :: dl_lon1
 
-      LOGICAL                                  :: ll_ii
-      LOGICAL                                  :: ll_ij
+      REAL(dp)                                 :: dl_lonmax0
+      REAL(dp)                                 :: dl_latmax0
+      REAL(dp)                                 :: dl_lonmin0
+      REAL(dp)                                 :: dl_latmin0
+
+      REAL(dp)                                 :: dl_lon0F
+      REAL(dp)                                 :: dl_lat0F
+      REAL(dp)                                 :: dl_dlon
+      REAL(dp)                                 :: dl_dlat
+
+      LOGICAL    , DIMENSION(2)                :: ll_even
+      LOGICAL                                  :: ll_greenwich
       
       ! loop indices
-      INTEGER(i4) :: ji
-      INTEGER(i4) :: jj
-
       INTEGER(i4) :: ii
       INTEGER(i4) :: ij
@@ -3824,50 +3965,196 @@
          CALL logger_fatal("GRID GET FINE OFFSET: dimension of fine "//&
          &              "longitude and latitude differ")
-      ENDIF      
+      ENDIF
+
+      ll_even(:)=(/ (MOD(id_rho(jp_I),2)==0), (MOD(id_rho(jp_J),2)==0) /)
+
+      cl_point='T'
+      IF( PRESENT(cd_point) ) cl_point=TRIM(fct_upper(cd_point))
 
       il_shape0(:)=SHAPE(dd_lon0(:,:))
       ALLOCATE( dl_lon0(il_shape0(1),il_shape0(2)) )
 
+      il_shape1(:)=SHAPE(dd_lon1(:,:))
+      ALLOCATE( dl_lon1(il_shape1(1),il_shape1(2)) )
+
       dl_lon0(:,:)=dd_lon0(:,:)
       WHERE( dd_lon0(:,:) < 0 ) dl_lon0(:,:)=dd_lon0(:,:)+360.
 
-      il_shape1(:)=SHAPE(dd_lon1(:,:))
-      ALLOCATE( dl_lon1(il_shape1(1),il_shape1(2)) )
-
       dl_lon1(:,:)=dd_lon1(:,:)
-      WHERE( dd_lon1(:,:) < 0 ) dl_lon1(:,:)=dd_lon1(:,:)+360.         
+      WHERE( dd_lon1(:,:) < 0 ) dl_lon1(:,:)=dd_lon1(:,:)+360.
 
       ! init
       grid__get_fine_offset_cc(:,:)=-1
+      ll_greenwich=.FALSE.
 
       IF( il_shape1(jp_J) == 1 )THEN
-          
+ 
          grid__get_fine_offset_cc(jp_J,:)=((id_rho(jp_J)-1)/2)
 
-         ! work on i-direction
-         ! look for i-direction left offset
-         IF( dl_lon1(1,1) < dl_lon0(id_imin0+1,id_jmin0) )THEN
-            DO ji=1,id_rho(jp_I)+2
-               IF( dl_lon1(ji,1) > dl_lon0(id_imin0+1,id_jmin0) - dp_delta )THEN
-                  grid__get_fine_offset_cc(jp_I,1)=(id_rho(jp_I)+1)-ji
-                  EXIT
-               ENDIF
-            ENDDO
+         !!! work on i-direction
+         !!! look for i-direction left offset
+         i1=1 ; i2=MIN((id_rho(jp_I)+2),il_shape1(jp_I))
+         j1=1 ; j2=1
+
+         ! check if cross greenwich meridien
+         IF( minval(dl_lon0(id_imin0:id_imin0+1,id_jmin0))<5. .OR. &
+           & maxval(dl_lon0(id_imin0:id_imin0+1,id_jmin0))>355. )THEN
+            ! close to greenwich meridien
+            ll_greenwich=.TRUE.
+            ! 0:360 => -180:180
+            WHERE( dl_lon0(id_imin0:id_imin0+1,id_jmin0) > 180. )
+               dl_lon0(id_imin0:id_imin0+1,id_jmin0) = &
+                  & dl_lon0(id_imin0:id_imin0+1,id_jmin0)-360.
+            END WHERE
+
+            WHERE( dl_lon1(i1:i2,j1:j2) > 180. )
+               dl_lon1(i1:i2,j1:j2)=dl_lon1(i1:i2,j1:j2)-360.
+            END WHERE
+         ENDIF
+
+         ! max lognitude of the left cell
+         dl_lonmax0=dl_lon0(id_imin0+1,id_jmin0)
+         IF( dl_lon1(1,1) < dl_lonmax0 )THEN
+
+            !!!!! i-direction !!!!!
+            IF( ll_even(jp_I) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point))
+                  CASE('F','U')
+                     dl_dlon= ( dl_lon0(id_imin0+1,id_jmin0) -   &
+                        &       dl_lon0(id_imin0  ,id_jmin0) ) / &
+                        &     ( 2.*id_rho(jp_I) )
+                  CASE DEFAULT
+                     dl_dlon=0
+               END SELECT
+            ELSE
+               ! odd
+               dl_dlon= ( dl_lon0(id_imin0+1,id_jmin0) -   &
+                  &       dl_lon0(id_imin0  ,id_jmin0) ) / &
+                  &     ( 2.*id_rho(jp_I) )
+            ENDIF
+
+            dl_lon0F= dl_lon0(id_imin0+1,id_jmin0) + dl_dlon
+            dl_lat0F= dd_lat0(id_imin0+1,id_jmin0)
+
+            il_ind(:)=grid_get_closest( dl_lon1(i1:i2,j1:j2), dd_lat1(i1:i2,j1:j2), &
+            &                           dl_lon0F, dl_lat0F, 'le' )
+      
+            ii=il_ind(1)
+
+            !!!!! i-direction !!!!!
+            IF( ll_even(jp_I) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point))
+                  CASE('T','V')
+                     grid__get_fine_offset_cc(jp_I,1)=id_rho(jp_I)-ii
+                  CASE DEFAULT !'F','U' 
+                     grid__get_fine_offset_cc(jp_I,1)=(id_rho(jp_I)+1)-ii
+               END SELECT
+            ELSE
+               ! odd
+               grid__get_fine_offset_cc(jp_I,1)=(id_rho(jp_I)+1)-ii
+            ENDIF
+
          ELSE
             CALL logger_error("GRID GET FINE OFFSET: coarse grid indices do "//&
-            &                 " not match fine grid lower left corner.")
-         ENDIF
-         ! look for i-direction right offset
-         IF( dl_lon1(il_shape1(jp_I),1) > dl_lon0(id_imax0-1,id_jmin0) )THEN
-            DO ji=1,id_rho(jp_I)+2
-               ii=il_shape1(jp_I)-ji+1
-               IF( dl_lon1(ii,1) < dl_lon0(id_imax0-1,id_jmin0) + dp_delta )THEN
-                  grid__get_fine_offset_cc(jp_I,2)=(id_rho(jp_I)+1)-ji
-                  EXIT
-               ENDIF
-            ENDDO
+            &                 " not match fine grid left corner.")
+         ENDIF
+
+         IF( ll_greenwich )THEN
+            ! close to greenwich meridien
+            ll_greenwich=.FALSE.
+            ! -180:180 => 0:360
+            WHERE( dl_lon0(id_imin0:id_imin0+1,id_jmin0) < 0. )
+               dl_lon0(id_imin0:id_imin0+1,id_jmin0) = &
+                  & dl_lon0(id_imin0:id_imin0+1,id_jmin0)+360.
+            END WHERE
+
+            WHERE( dl_lon1(i1:i2,j1:j2) < 0. )
+               dl_lon1(i1:i2,j1:j2)=dl_lon1(i1:i2,j1:j2)+360.
+            END WHERE
+         ENDIF
+
+         !!!!!! look for i-direction right offset !!!!!!
+         i1=MAX(1,il_shape1(jp_I)-(id_rho(jp_I)+2)+1) ; i2=il_shape1(jp_I)
+         j1=1                                         ; j2=1
+
+         ! check if cross greenwich meridien
+         IF( minval(dl_lon0(id_imax0-1:id_imax0,id_jmin0))<5. .OR. &
+           & maxval(dl_lon0(id_imax0-1:id_imax0,id_jmin0))>355. )THEN
+            ! close to greenwich meridien
+            ll_greenwich=.TRUE.
+            ! 0:360 => -180:180
+            WHERE( dl_lon0(id_imax0-1:id_imax0,id_jmin0) > 180. )
+               dl_lon0(id_imax0-1:id_imax0,id_jmin0) = &
+                  & dl_lon0(id_imax0-1:id_imax0,id_jmin0)-360.
+            END WHERE
+
+            WHERE( dl_lon1(i1:i2,j1:j2) > 180. )
+               dl_lon1(i1:i2,j1:j2)=dl_lon1(i1:i2,j1:j2)-360.
+            END WHERE
+         ENDIF
+
+         ! min lognitude of the right cell
+         dl_lonmin0=dl_lon0(id_imax0-1,id_jmin0)
+         IF( dl_lon1(il_shape1(jp_I),il_shape1(jp_J)) > dl_lonmin0 )THEN
+
+            !!!!! i-direction !!!!!
+            IF( ll_even(jp_I) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point))
+                  CASE('F','U')
+                     dl_dlon= ( dl_lon0(id_imax0  ,id_jmin0) -   &
+                        &       dl_lon0(id_imax0-1,id_jmin0) ) / &
+                        &     ( 2.*id_rho(jp_I) )
+                  CASE DEFAULT
+                     dl_dlon=0
+               END SELECT
+            ELSE
+               ! odd
+               dl_dlon= ( dl_lon0(id_imax0  ,id_jmin0) -   &
+                  &       dl_lon0(id_imax0-1,id_jmin0) ) / &
+                  &     ( 2.*id_rho(jp_I) )
+            ENDIF
+
+            dl_lon0F= dl_lon0(id_imax0-1,id_jmin0) - dl_dlon
+            dl_lat0F= dd_lat0(id_imax0-1,id_jmin0)
+
+            il_ind(:)=grid_get_closest( dl_lon1(i1:i2,j1:j2), dd_lat1(i1:i2,j1:j2), &
+            &                           dl_lon0F, dl_lat0F, 'ri' )
+
+            ii=(MIN(il_shape1(jp_I),(id_rho(jp_I)+2))-il_ind(1)+1)
+
+            !!!!! i-direction !!!!!
+            IF( ll_even(jp_I) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point))
+                  CASE('T','V')
+                     grid__get_fine_offset_cc(jp_I,2)=id_rho(jp_I)-ii
+                  CASE DEFAULT !'F','U' 
+                     grid__get_fine_offset_cc(jp_I,2)=(id_rho(jp_I)+1)-ii
+               END SELECT
+            ELSE
+               ! odd
+               grid__get_fine_offset_cc(jp_I,2)=(id_rho(jp_I)+1)-ii
+            ENDIF
+
          ELSE
             CALL logger_error("GRID GET FINE OFFSET: coarse grid indices do "//&
-            &                 " not match fine grid lower right corner.")
+            &                 " not match fine grid right corner.")
+         ENDIF
+
+         IF( ll_greenwich )THEN
+            ! close to greenwich meridien
+            ll_greenwich=.FALSE.
+            ! -180:180 => 0:360
+            WHERE( dl_lon0(id_imax0-1:id_imax0,id_jmin0) < 0. )
+               dl_lon0(id_imax0-1:id_imax0,id_jmin0) = &
+                  & dl_lon0(id_imax0-1:id_imax0,id_jmin0)+360.
+            END WHERE
+
+            WHERE( dl_lon1(i1:i2,j1:j2) < 0. )
+               dl_lon1(i1:i2,j1:j2)=dl_lon1(i1:i2,j1:j2)+360.
+            END WHERE
          ENDIF
 
@@ -3876,106 +4163,348 @@
          grid__get_fine_offset_cc(jp_I,:)=((id_rho(jp_I)-1)/2)
          
-         ! work on j-direction
-
-         ! look for j-direction lower offset 
-         IF( dd_lat1(1,1) < dd_lat0(id_imin0,id_jmin0+1) )THEN
-            DO jj=1,id_rho(jp_J)+2
-               IF( dd_lat1(1,jj) > dd_lat0(id_imin0,id_jmin0+1) - dp_delta )THEN
-                  grid__get_fine_offset_cc(jp_J,1)=(id_rho(jp_J)+1)-jj
-                  EXIT
-               ENDIF
-            ENDDO
+         !!! work on j-direction
+         !!! look for j-direction lower offset 
+         i1=1 ; i2=1
+         j1=1 ; j2=MIN((id_rho(jp_J)+2),il_shape1(jp_J))
+
+
+         ! max latitude of the lower cell
+         dl_latmax0=dd_lat0(id_imin0,id_jmin0+1)
+         IF( dd_lat1(1,1) < dl_latmax0 )THEN
+
+            IF( ll_even(jp_J) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point))
+                  CASE('F','V')
+                     dl_dlat= ( dd_lat0(id_imin0,id_jmin0+1) -   &
+                        &       dd_lat0(id_imin0,id_jmin0  ) ) / &
+                        &     ( 2.*id_rho(jp_J) )
+                  CASE DEFAULT
+                     dl_dlat=0
+               END SELECT
+            ELSE
+               ! odd
+               dl_dlat= ( dd_lat0(id_imin0,id_jmin0+1) -   &
+                  &       dd_lat0(id_imin0,id_jmin0  ) ) / &
+                  &     ( 2.*id_rho(jp_J) )
+            ENDIF
+
+            dl_lon0F= dl_lon0(id_imin0,id_jmin0+1)
+            dl_lat0F= dd_lat0(id_imin0,id_jmin0+1) + dl_dlat 
+            
+            il_ind(:)=grid_get_closest( dl_lon1(i1:i2,j1:j2), dd_lat1(i1:i2,j1:j2), &
+            &                           dl_lon0F, dl_lat0F, 'lo' )
+
+            ij=il_ind(2)
+
+            !!!!! i-direction !!!!!
+            IF( ll_even(jp_I) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point))
+                  CASE('T','V')
+                     grid__get_fine_offset_cc(jp_I,1)=id_rho(jp_I)-ii
+                  CASE DEFAULT !'F','U' 
+                     grid__get_fine_offset_cc(jp_I,1)=(id_rho(jp_I)+1)-ii
+               END SELECT
+            ELSE
+               ! odd
+               grid__get_fine_offset_cc(jp_I,1)=(id_rho(jp_I)+1)-ii
+            ENDIF
+
          ELSE
             CALL logger_error("GRID GET FINE OFFSET: coarse grid indices do "//&
-            &                 " not match fine grid upper left corner.")
-         ENDIF
-
-         ! look for j-direction upper offset 
-         IF( dd_lat1(1,il_shape1(jp_J)) > dd_lat0(id_imin0,id_jmax0-1) )THEN
-            DO jj=1,id_rho(jp_J)+2
-               ij=il_shape1(jp_J)-jj+1
-               IF( dd_lat1(1,ij) < dd_lat0(id_imin0,id_jmax0-1) + dp_delta )THEN
-                  grid__get_fine_offset_cc(jp_J,2)=(id_rho(jp_J)+1)-jj
-                  EXIT
-               ENDIF
-            ENDDO
+            &                 " not match fine grid lower corner.")
+         ENDIF
+
+         !!! look for j-direction upper offset 
+         i1=1                                         ; i2=1
+         j1=MAX(1,il_shape1(jp_J)-(id_rho(jp_J)+2)+1) ; j2=il_shape1(jp_J)
+
+         ! min latitude of the upper cell
+         dl_latmin0=dd_lat0(id_imin0,id_jmax0-1)
+         IF( dd_lat1(il_shape1(jp_I),il_shape1(jp_J)) > dl_latmin0 )THEN
+
+            IF( ll_even(jp_J) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point))
+                  CASE('F','V')
+                     dl_dlat= ( dd_lat0(id_imin0,id_jmax0  ) -   &
+                        &       dd_lat0(id_imin0,id_jmax0-1) ) / &
+                        &     ( 2.*id_rho(jp_J) )
+                  CASE DEFAULT
+                     dl_dlat=0
+               END SELECT
+            ELSE
+               ! odd
+               dl_dlat= ( dd_lat0(id_imin0,id_jmax0  ) -   &
+                  &       dd_lat0(id_imin0,id_jmax0-1) ) / &
+                  &     ( 2*id_rho(jp_J) )
+            ENDIF
+
+            dl_lon0F= dl_lon0(id_imin0,id_jmax0-1) 
+            dl_lat0F= dd_lat0(id_imin0,id_jmax0-1) - dl_dlat
+            
+            il_ind(:)=grid_get_closest( dl_lon1(i1:i2,j1:j2), dd_lat1(i1:i2,j1:j2), &
+            &                           dl_lon0F, dl_lat0F, 'up' )
+
+            ij=(MIN(il_shape1(jp_J),(id_rho(jp_J)+2))-il_ind(2)+1)
+
+            !!!!! j-direction !!!!!
+            IF( ll_even(jp_J) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point))
+                  CASE('T','U')
+                     grid__get_fine_offset_cc(jp_J,2)=id_rho(jp_J)-ij
+                  CASE DEFAULT !'F','V'
+                     grid__get_fine_offset_cc(jp_J,2)=(id_rho(jp_J)+1)-ij
+               END SELECT
+            ELSE
+               ! odd
+               grid__get_fine_offset_cc(jp_J,2)=(id_rho(jp_J)+1)-ij
+            ENDIF
+
          ELSE
             CALL logger_error("GRID GET FINE OFFSET: coarse grid indices do "//&
+            &                 " not match fine grid upper corner.")
+         ENDIF
+
+      ELSE ! il_shape1(1) > 1 .AND. il_shape1(2) > 1 
+
+         !!!!!! look for lower left offset !!!!!!
+         i1=1 ; i2=MIN((id_rho(jp_I)+2),il_shape1(jp_I))
+         j1=1 ; j2=MIN((id_rho(jp_J)+2),il_shape1(jp_J))
+
+         ! check if cross greenwich meridien
+         IF( minval(dl_lon0(id_imin0:id_imin0+1,id_jmin0:id_jmin0+1))<5. .OR. &
+           & maxval(dl_lon0(id_imin0:id_imin0+1,id_jmin0:id_jmin0+1))>355. )THEN
+            ! close to greenwich meridien
+            ll_greenwich=.TRUE.
+            ! 0:360 => -180:180
+            WHERE( dl_lon0(id_imin0:id_imin0+1,id_jmin0:id_jmin0+1) > 180. )
+               dl_lon0(id_imin0:id_imin0+1,id_jmin0:id_jmin0+1) = &
+                  & dl_lon0(id_imin0:id_imin0+1,id_jmin0:id_jmin0+1)-360.
+            END WHERE
+
+            WHERE( dl_lon1(i1:i2,j1:j2) > 180. )
+               dl_lon1(i1:i2,j1:j2)=dl_lon1(i1:i2,j1:j2)-360.
+            END WHERE
+         ENDIF
+
+         ! max longitude of the lower left cell
+         dl_lonmax0=MAX(dl_lon0(id_imin0+1,id_jmin0),dl_lon0(id_imin0+1,id_jmin0+1))
+         ! max latitude of the lower left cell
+         dl_latmax0=MAX(dd_lat0(id_imin0,id_jmin0+1),dd_lat0(id_imin0+1,id_jmin0+1))
+         IF( dl_lon1(1,1) < dl_lonmax0 .AND. &
+           & dd_lat1(1,1) < dl_latmax0 )THEN
+
+            !!!!! i-direction !!!!!
+            IF( ll_even(jp_I) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point))
+                  CASE('F','U')
+                     dl_dlon= ( dl_lon0(id_imin0+1,id_jmin0+1) -   &
+                        &       dl_lon0(id_imin0  ,id_jmin0+1) ) / &
+                        &     ( 2.*id_rho(jp_I) )
+                  CASE DEFAULT
+                     dl_dlon=0
+               END SELECT
+            ELSE
+               ! odd
+               dl_dlon= ( dl_lon0(id_imin0+1,id_jmin0+1) -   &
+                  &       dl_lon0(id_imin0  ,id_jmin0+1) ) / &
+                  &     ( 2.*id_rho(jp_I) )
+            ENDIF
+
+            !!!!! j-direction !!!!!
+            IF( ll_even(jp_J) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point))
+                  CASE('F','V')
+                     dl_dlat= ( dd_lat0(id_imin0+1,id_jmin0+1) -   &
+                        &       dd_lat0(id_imin0+1,id_jmin0  ) ) / &
+                        &     ( 2.*id_rho(jp_J) )
+                  CASE DEFAULT
+                     dl_dlat=0
+               END SELECT
+            ELSE
+               ! odd
+               dl_dlat= ( dd_lat0(id_imin0+1,id_jmin0+1) -   &
+                  &       dd_lat0(id_imin0+1,id_jmin0  ) ) / &
+                  &     ( 2.*id_rho(jp_J) )
+            ENDIF
+
+            dl_lon0F= dl_lon0(id_imin0+1,id_jmin0+1) + dl_dlon
+            dl_lat0F= dd_lat0(id_imin0+1,id_jmin0+1) + dl_dlat
+
+            il_ind(:)=grid_get_closest( dl_lon1(i1:i2,j1:j2), dd_lat1(i1:i2,j1:j2), &
+            &                           dl_lon0F, dl_lat0F, 'll' )
+
+            ii=il_ind(1)
+            ij=il_ind(2)
+
+            !!!!! i-direction !!!!!
+            IF( ll_even(jp_I) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point))
+                  CASE('T','V')
+                     grid__get_fine_offset_cc(jp_I,1)=id_rho(jp_I)-ii
+                  CASE DEFAULT !'F','U' 
+                     grid__get_fine_offset_cc(jp_I,1)=(id_rho(jp_I)+1)-ii
+               END SELECT
+            ELSE
+               ! odd
+               grid__get_fine_offset_cc(jp_I,1)=(id_rho(jp_I)+1)-ii
+            ENDIF
+
+            !!!!! j-direction !!!!!
+            IF( ll_even(jp_J) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point))
+                  CASE('T','U')
+                     grid__get_fine_offset_cc(jp_J,1)=id_rho(jp_J)-ij
+                  CASE DEFAULT !'F','V'
+                     grid__get_fine_offset_cc(jp_J,1)=(id_rho(jp_J)+1)-ij
+               END SELECT
+            ELSE
+               ! odd
+               grid__get_fine_offset_cc(jp_J,1)=(id_rho(jp_J)+1)-ij
+            ENDIF
+
+         ELSE
+            CALL logger_error("GRID GET FINE OFFSET: coarse grid indices do"//&
+            &                 " not match fine grid lower left corner.")
+         ENDIF
+
+         IF( ll_greenwich )THEN
+            ! close to greenwich meridien
+            ll_greenwich=.FALSE.
+            ! -180:180 => 0:360 
+            WHERE( dl_lon0(id_imin0:id_imin0+1,id_jmin0:id_jmin0+1) < 0. )
+               dl_lon0(id_imin0:id_imin0+1,id_jmin0:id_jmin0+1) = &
+                  & dl_lon0(id_imin0:id_imin0+1,id_jmin0:id_jmin0+1)+360.
+            END WHERE
+
+            WHERE( dl_lon1(i1:i2,j1:j2) < 0. )
+               dl_lon1(i1:i2,j1:j2)=dl_lon1(i1:i2,j1:j2)+360.
+            END WHERE
+         ENDIF
+
+         !!!!!! look for upper right offset !!!!!!
+         i1=MAX(1,il_shape1(jp_I)-(id_rho(jp_I)+2)+1) ; i2=il_shape1(jp_I)
+         j1=MAX(1,il_shape1(jp_J)-(id_rho(jp_J)+2)+1) ; j2=il_shape1(jp_J)
+
+         ! check if cross greenwich meridien
+         IF( minval(dl_lon0(id_imax0-1:id_imax0,id_jmax0-1:id_jmax0))<5. .OR. &
+           & maxval(dl_lon0(id_imax0-1:id_imax0,id_jmax0-1:id_jmax0))>355. )THEN
+            ! close to greenwich meridien
+            ll_greenwich=.TRUE.
+            ! 0:360 => -180:180
+            WHERE( dl_lon0(id_imax0-1:id_imax0,id_jmax0-1:id_jmax0) > 180. )
+               dl_lon0(id_imax0-1:id_imax0,id_jmax0-1:id_jmax0) = &
+                  & dl_lon0(id_imax0-1:id_imax0,id_jmax0-1:id_jmax0)-360.
+            END WHERE
+
+            WHERE( dl_lon1(i1:i2,j1:j2) > 180. )
+               dl_lon1(i1:i2,j1:j2)=dl_lon1(i1:i2,j1:j2)-360.
+            END WHERE
+         ENDIF
+
+         ! min latitude of the upper right cell
+         dl_lonmin0=MIN(dl_lon0(id_imax0-1,id_jmax0-1),dl_lon0(id_imax0-1,id_jmax0))
+         ! min latitude of the upper right cell
+         dl_latmin0=MIN(dd_lat0(id_imax0-1,id_jmax0-1),dd_lat0(id_imax0,id_jmax0-1))
+         IF( dl_lon1(il_shape1(jp_I),il_shape1(jp_J)) > dl_lonmin0 .AND. &
+           & dd_lat1(il_shape1(jp_I),il_shape1(jp_J)) > dl_latmin0 )THEN
+
+            !!!!! i-direction !!!!!
+            IF( ll_even(jp_I) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point))
+                  CASE('F','U')
+                     dl_dlon= ( dl_lon0(id_imax0  ,id_jmax0-1) -   &
+                        &       dl_lon0(id_imax0-1,id_jmax0-1) ) / &
+                        &     ( 2.*id_rho(jp_I) )
+                  CASE DEFAULT
+                     dl_dlon=0
+               END SELECT               
+            ELSE
+               ! odd
+               dl_dlon= ( dl_lon0(id_imax0  ,id_jmax0-1) -   &
+                  &       dl_lon0(id_imax0-1,id_jmax0-1) ) / &
+                  &     ( 2*id_rho(jp_I) )
+            ENDIF
+
+            !!!!! j-direction !!!!!
+            IF( ll_even(jp_J) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point))
+                  CASE('F','V')
+                     dl_dlat= ( dd_lat0(id_imax0-1,id_jmax0  ) -   &
+                        &       dd_lat0(id_imax0-1,id_jmax0-1) ) / &
+                        &     ( 2.*id_rho(jp_J) )
+                  CASE DEFAULT
+                     dl_dlat=0
+               END SELECT
+            ELSE
+               ! odd
+               dl_dlat= ( dd_lat0(id_imax0-1,id_jmax0  ) -   &
+                  &       dd_lat0(id_imax0-1,id_jmax0-1) ) / &
+                  &     ( 2*id_rho(jp_J) )
+            ENDIF
+
+            dl_lon0F= dl_lon0(id_imax0-1,id_jmax0-1) - dl_dlon
+            dl_lat0F= dd_lat0(id_imax0-1,id_jmax0-1) - dl_dlat
+
+            il_ind(:)=grid_get_closest( dl_lon1(i1:i2,j1:j2), dd_lat1(i1:i2,j1:j2), &
+            &                           dl_lon0F, dl_lat0F, 'ur' )
+
+            ii=(MIN(il_shape1(jp_I),(id_rho(jp_I)+2))-il_ind(1)+1)
+            ij=(MIN(il_shape1(jp_J),(id_rho(jp_J)+2))-il_ind(2)+1)
+
+            !!!!! i-direction !!!!!
+            IF( ll_even(jp_I) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point))
+                  CASE('T','V')
+                     grid__get_fine_offset_cc(jp_I,2)=id_rho(jp_I)-ii
+                  CASE DEFAULT !'F','U' 
+                     grid__get_fine_offset_cc(jp_I,2)=(id_rho(jp_I)+1)-ii
+               END SELECT
+            ELSE
+               ! odd
+               grid__get_fine_offset_cc(jp_I,2)=(id_rho(jp_I)+1)-ii
+            ENDIF
+
+            !!!!! j-direction !!!!!
+            IF( ll_even(jp_J) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point))
+                  CASE('T','U')
+                     grid__get_fine_offset_cc(jp_J,2)=id_rho(jp_J)-ij
+                  CASE DEFAULT !'F','V'
+                     grid__get_fine_offset_cc(jp_J,2)=(id_rho(jp_J)+1)-ij
+               END SELECT
+            ELSE
+               ! odd
+               grid__get_fine_offset_cc(jp_J,2)=(id_rho(jp_J)+1)-ij
+            ENDIF
+
+         ELSE
+            CALL logger_error("GRID GET FINE OFFSET: coarse grid indices do"//&
             &                 " not match fine grid upper right corner.")
-         ENDIF         
-
-      ELSE ! il_shape1(1) > 1 .AND. il_shape1(2) > 1 
-
-         ! look for lower left offset
-         IF( dl_lon1(1,1) < dl_lon0(id_imin0+1,id_jmin0+1) )THEN
-
-            ii=1
-            ij=1
-            DO ji=1,(id_rho(jp_I)+2)*(id_rho(jp_J)+2)
-
-               ll_ii=.FALSE.
-               ll_ij=.FALSE.
-
-               IF( dl_lon1(ii,ij) >= dl_lon0(id_imin0+1,id_jmin0+1)-dp_delta .AND. &
-               &   dd_lat1(ii,ij) >= dd_lat0(id_imin0+1,id_jmin0+1)-dp_delta )THEN
-                  grid__get_fine_offset_cc(jp_I,1)=(id_rho(jp_I)+1)-ii
-                  grid__get_fine_offset_cc(jp_J,1)=(id_rho(jp_J)+1)-ij
-                  EXIT
-               ENDIF
-
-               IF( dl_lon1(ii+1,ij) <= dl_lon0(id_imin0+1,id_jmin0+1)+dp_delta .AND. &
-               &   dd_lat1(ii+1,ij) <= dd_lat0(id_imin0+1,id_jmin0+1)+dp_delta )THEN
-                  ll_ii=.TRUE.
-               ENDIF
-               IF( dl_lon1(ii,ij+1) <= dl_lon0(id_imin0+1,id_jmin0+1)+dp_delta .AND. &
-               &   dd_lat1(ii,ij+1) <= dd_lat0(id_imin0+1,id_jmin0+1)+dp_delta )THEN
-                  ll_ij=.TRUE.
-               ENDIF
-
-               IF( ll_ii ) ii=ii+1
-               IF( ll_ij ) ij=ij+1
-
-            ENDDO
-
-         ELSE
-            CALL logger_error("GRID GET FINE OFFSET: coarse grid indices do "//&
-            &                 " not match fine grid lower left corner.")
-         ENDIF
-
-         ! look for upper right offset
-         IF( dl_lon1(il_shape1(jp_I),il_shape1(jp_J)) > &
-            & dl_lon0(id_imax0-1,id_jmax0-1) )THEN
-
-            ii=il_shape1(jp_I)
-            ij=il_shape1(jp_J)
-            DO ji=1,(id_rho(jp_I)+2)*(id_rho(jp_J)+2)
-
-               ll_ii=.FALSE.
-               ll_ij=.FALSE.
-
-               IF( dl_lon1(ii,ij) <= dl_lon0(id_imax0-1,id_jmax0-1)+dp_delta .AND. &
-               &   dd_lat1(ii,ij) <= dd_lat0(id_imax0-1,id_jmax0-1)+dp_delta )THEN
-                  grid__get_fine_offset_cc(jp_I,2)=(id_rho(jp_I)+1)-(il_shape1(jp_I)+1-ii)
-                  grid__get_fine_offset_cc(jp_J,2)=(id_rho(jp_J)+1)-(il_shape1(jp_J)+1-ij)
-                  EXIT
-               ENDIF
-
-               IF( dl_lon1(ii-1,ij) >= dl_lon0(id_imax0-1,id_jmax0-1)-dp_delta .AND. &
-               &   dd_lat1(ii-1,ij) >= dd_lat0(id_imax0-1,id_jmax0-1)-dp_delta )THEN
-                  ll_ii=.TRUE.
-               ENDIF
-               IF( dl_lon1(ii,ij-1) >= dl_lon0(id_imax0-1,id_jmax0-1)-dp_delta .AND. &
-               &   dd_lat1(ii,ij-1) >= dd_lat0(id_imax0-1,id_jmax0-1)-dp_delta )THEN
-                  ll_ij=.TRUE.
-               ENDIF
-
-               IF( ll_ii ) ii=ii-1
-               IF( ll_ij ) ij=ij-1
-
-            ENDDO
-
-         ELSE
-            CALL logger_error("GRID GET FINE OFFSET: coarse grid indices do "//&
-            &                 " not match fine grid upper right corner.")
+         ENDIF
+
+         IF( ll_greenwich )THEN
+            ! close to greenwich meridien
+            ll_greenwich=.FALSE.
+            ! -180:180 => 0:360
+            WHERE( dl_lon0(id_imax0-1:id_imax0,id_jmax0-1:id_jmax0) < 0. )
+               dl_lon0(id_imax0-1:id_imax0,id_jmax0-1:id_jmax0) = &
+                  & dl_lon0(id_imax0-1:id_imax0,id_jmax0-1:id_jmax0)+360.
+            END WHERE
+
+            WHERE( dl_lon1(i1:i2,j1:j2) < 0. )
+               dl_lon1(i1:i2,j1:j2)=dl_lon1(i1:i2,j1:j2)+360.
+            END WHERE
          ENDIF
 
@@ -3984,4 +4513,9 @@
       DEALLOCATE( dl_lon0 )
       DEALLOCATE( dl_lon1 )
+
+      IF( ANY(grid__get_fine_offset_cc(:,:)==-1) )THEN
+         CALL logger_fatal("GRID GET FINE OFFSET: can not found "//&
+         &                 " offset between coarse and fine grid.")
+      ENDIF
 
    END FUNCTION grid__get_fine_offset_cc
@@ -3995,5 +4529,8 @@
    !> @date October, 2014
    !> - work on mpp file structure instead of file structure
-   !
+   !> @date February, 2016
+   !> - use F-point to check coincidence for even refinment
+   !> - use F-point estimation, if can not read it.
+   !>
    !> @param[in] td_coord0 coarse grid coordinate file structure 
    !> @param[in] td_coord1 fine   grid coordinate file structure 
@@ -4020,39 +4557,54 @@
 
       ! local variable
-      INTEGER(i4) :: il_imid1
-      INTEGER(i4) :: il_jmid1
+      INTEGER(i4)               :: il_imid1
+      INTEGER(i4)               :: il_jmid1
       
-      INTEGER(i4) :: il_ew0
-      INTEGER(i4) :: il_ew1
-
-      INTEGER(i4) :: il_imin1
-      INTEGER(i4) :: il_imax1
-      INTEGER(i4) :: il_jmin1
-      INTEGER(i4) :: il_jmax1
-
-      INTEGER(i4), DIMENSION(2) :: il_indC
-      INTEGER(i4), DIMENSION(2) :: il_indF
-      INTEGER(i4), DIMENSION(2) :: il_iind
-      INTEGER(i4), DIMENSION(2) :: il_jind
-
-      REAL(dp)    :: dl_lon0
-      REAL(dp)    :: dl_lat0
-      REAL(dp)    :: dl_lon1
-      REAL(dp)    :: dl_lat1
-
-      REAL(dp)    :: dl_lon1p
-      REAL(dp)    :: dl_lat1p
-
-      LOGICAL     :: ll_coincidence
-
-      TYPE(TVAR)  :: tl_lon0
-      TYPE(TVAR)  :: tl_lat0
-      TYPE(TVAR)  :: tl_lon1
-      TYPE(TVAR)  :: tl_lat1
-
-      TYPE(TMPP)  :: tl_coord0
-      TYPE(TMPP)  :: tl_coord1
-
-      TYPE(TDOM)  :: tl_dom0
+      INTEGER(i4)               :: il_ew0
+      INTEGER(i4)               :: il_ew1
+
+      INTEGER(i4)               :: il_ind
+
+      INTEGER(i4)               :: il_imin1
+      INTEGER(i4)               :: il_imax1
+      INTEGER(i4)               :: il_jmin1
+      INTEGER(i4)               :: il_jmax1
+
+      INTEGER(i4), DIMENSION(2) :: il_ind0
+      INTEGER(i4), DIMENSION(2) :: il_ind1
+
+      INTEGER(i4), DIMENSION(2) :: il_ill1
+      INTEGER(i4), DIMENSION(2) :: il_ilr1
+      INTEGER(i4), DIMENSION(2) :: il_iul1
+      INTEGER(i4), DIMENSION(2) :: il_iur1
+
+      REAL(dp)                  :: dl_lon0F
+      REAL(dp)                  :: dl_lat0F
+      REAL(dp)                  :: dl_lon0
+      REAL(dp)                  :: dl_lat0
+      REAL(dp)                  :: dl_lon1F
+      REAL(dp)                  :: dl_lat1F
+      REAL(dp)                  :: dl_lon1
+      REAL(dp)                  :: dl_lat1
+
+      REAL(dp)                  :: dl_delta
+
+      LOGICAL                   :: ll_coincidence
+      LOGICAL                   :: ll_even
+      LOGICAL                   :: ll_grid0F
+      LOGICAL                   :: ll_grid1F
+
+      TYPE(TVAR)                :: tl_lon0
+      TYPE(TVAR)                :: tl_lat0
+      TYPE(TVAR)                :: tl_lon0F
+      TYPE(TVAR)                :: tl_lat0F
+      TYPE(TVAR)                :: tl_lon1
+      TYPE(TVAR)                :: tl_lat1
+      TYPE(TVAR)                :: tl_lon1F
+      TYPE(TVAR)                :: tl_lat1F
+
+      TYPE(TMPP)                :: tl_coord0
+      TYPE(TMPP)                :: tl_coord1
+
+      TYPE(TDOM)                :: tl_dom0
 
       ! loop indices
@@ -4063,4 +4615,9 @@
       ll_coincidence=.TRUE.
 
+      ll_even=.FALSE.
+      IF( MOD(id_rho(jp_I)*id_rho(jp_J),2) == 0 )THEN
+         ll_even=.TRUE.
+      ENDIF
+
       ! copy structure
       tl_coord0=mpp_copy(td_coord0)
@@ -4075,6 +4632,37 @@
 
       ! read variable value on domain
-      tl_lon0=iom_dom_read_var(tl_coord0,'longitude',tl_dom0)
-      tl_lat0=iom_dom_read_var(tl_coord0,'latitude' ,tl_dom0)
+      il_ind=var_get_index(tl_coord0%t_proc(1)%t_var(:), 'longitude_T')
+      IF( il_ind /= 0 )THEN
+         tl_lon0=iom_dom_read_var(tl_coord0,'longitude_T',tl_dom0)
+      ELSE
+         tl_lon0=iom_dom_read_var(tl_coord0,'longitude',tl_dom0)
+      ENDIF
+
+      il_ind=var_get_index(tl_coord0%t_proc(1)%t_var(:), 'latitude_T')
+      IF( il_ind /= 0 )THEN
+         tl_lat0=iom_dom_read_var(tl_coord0,'latitude_T' ,tl_dom0)
+      ELSE
+         tl_lat0=iom_dom_read_var(tl_coord0,'latitude' ,tl_dom0)
+      ENDIF
+
+      IF( ll_even )THEN
+         ! look for variable value on domain for F point
+         il_ind=var_get_index(tl_coord0%t_proc(1)%t_var(:), 'longitude_F')
+         IF( il_ind /= 0 )THEN
+            tl_lon0F=iom_dom_read_var(tl_coord0,'longitude_F',tl_dom0)
+         ENDIF
+
+         il_ind=var_get_index(tl_coord0%t_proc(1)%t_var(:), 'latitude_F')
+         IF( il_ind /= 0 )THEN
+            tl_lat0F=iom_dom_read_var(tl_coord0,'latitude_F' ,tl_dom0)
+         ENDIF
+
+         ll_grid0F=.FALSE.
+         IF( ASSOCIATED(tl_lon0F%d_value) .AND. &
+         &   ASSOCIATED(tl_lat0F%d_value) )THEN
+            ll_grid0F=.TRUE.
+         ENDIF
+
+      ENDIF
 
       ! close mpp files
@@ -4092,9 +4680,40 @@
 
       ! read fine longitue and latitude
-      tl_lon1=iom_mpp_read_var(tl_coord1,'longitude')
-      tl_lat1=iom_mpp_read_var(tl_coord1,'latitude')
+      il_ind=var_get_index(tl_coord1%t_proc(1)%t_var(:), TRIM(tl_lon0%c_longname))
+      IF( il_ind /= 0 )THEN
+         tl_lon1=iom_mpp_read_var(tl_coord1,TRIM(tl_lon0%c_longname))
+      ELSE
+         tl_lon1=iom_mpp_read_var(tl_coord1,'longitude')
+      ENDIF
+      il_ind=var_get_index(tl_coord1%t_proc(1)%t_var(:), TRIM(tl_lat0%c_longname))
+      IF( il_ind /= 0 )THEN
+         tl_lat1=iom_mpp_read_var(tl_coord1,TRIM(tl_lat0%c_longname))
+      ELSE
+         tl_lat1=iom_mpp_read_var(tl_coord1,'latitude')
+      ENDIF
       
+      IF( ll_even )THEN
+
+         ! look for variable value on domain for F point
+         il_ind=var_get_index(tl_coord1%t_proc(1)%t_var(:), 'longitude_F')
+         IF( il_ind /= 0 )THEN
+            tl_lon1F=iom_mpp_read_var(tl_coord1,'longitude_F')
+         ENDIF
+
+         il_ind=var_get_index(tl_coord1%t_proc(1)%t_var(:), 'latitude_F')
+         IF( il_ind /= 0 )THEN
+            tl_lat1F=iom_mpp_read_var(tl_coord1,'latitude_F')
+         ENDIF
+
+         ll_grid1F=.FALSE.
+         IF( ASSOCIATED(tl_lon1F%d_value) .AND. &
+         &   ASSOCIATED(tl_lat1F%d_value) )THEN
+            ll_grid1F=.TRUE.
+         ENDIF
+
+      ENDIF
+
       ! close mpp files
-      CALL iom_dom_close(tl_coord1)
+      CALL iom_mpp_close(tl_coord1)
       ! clean structure
       CALL mpp_clean(tl_coord1)
@@ -4158,5 +4777,5 @@
          IF( .NOT. ll_coincidence )THEN
             CALL logger_fatal("GRID CHECK COINCIDENCE: no coincidence "//&
-            &              "between fine grid and coarse grid. invalid domain" )
+            &              "between fine grid and coarse grid: invalid domain." )
          ENDIF
 
@@ -4172,61 +4791,36 @@
 
       ! select closest point on coarse grid
-      il_indC(:)=grid_get_closest(tl_lon0%d_value(:,:,1,1),&
+      il_ind0(:)=grid_get_closest(tl_lon0%d_value(:,:,1,1),&
       &                           tl_lat0%d_value(:,:,1,1),&
       &                           dl_lon1, dl_lat1   )
 
-      IF( ANY(il_indC(:)==0) )THEN
+      IF( ANY(il_ind0(:)==0) )THEN
          CALL logger_fatal("GRID CHECK COINCIDENCE: can not find valid "//&
-         &              "coarse grid indices. invalid domain" )
-      ENDIF
-
-      dl_lon0=tl_lon0%d_value(il_indC(1),il_indC(2),1,1)
-      dl_lat0=tl_lat0%d_value(il_indC(1),il_indC(2),1,1)
-
-      ! look for closest fine grid point from selected coarse grid point
-      il_iind(:)=MAXLOC( tl_lon1%d_value(:,:,1,1), &
-      &                  tl_lon1%d_value(:,:,1,1) <= dl_lon0 )
-
-      il_jind(:)=MAXLOC( tl_lat1%d_value(:,:,1,1), &
-      &                  tl_lat1%d_value(:,:,1,1) <= dl_lat0 )
-
-      il_indF(1)=il_iind(1)
-      il_indF(2)=il_jind(2)
-
-      IF( ANY(il_indF(:)==0) )THEN
-         CALL logger_fatal("GRID CHECK COINCIDENCE: can not find valid "//&
-         &              "fine grid indices. invalid domain" )
-      ENDIF
-
-      dl_lon1=tl_lon1%d_value(il_indF(1),il_indF(2),1,1)
-      dl_lat1=tl_lat1%d_value(il_indF(1),il_indF(2),1,1)
-
-      ! check i-direction refinement factor
-      DO ji=1,MIN(3,il_imid1)
-
-         IF( il_indF(1)+ji*id_rho(jp_I)+1 > tl_lon1%t_dim(1)%i_len )THEN
-            CALL logger_warn("GRID CHECK COINCIDENCE: domain to small "//&
-            &  " to check i-direction refinement factor ")
-            EXIT
-         ELSE
-            dl_lon1=tl_lon1%d_value(il_indF(1)+ji*id_rho(jp_I),il_indF(2),1,1)
-            dl_lon0=tl_lon0%d_value(il_indC(1)+ji,il_indC(2),1,1)
-
-            dl_lon1p=tl_lon1%d_value(il_indF(1)+ji*id_rho(jp_I)+1,il_indF(2),1,1)
-
-            SELECT CASE(MOD(id_rho(jp_I),2))
-
-            CASE(0)
-
-               IF( dl_lon1 >= dl_lon0 .OR. dl_lon0 >= dl_lon1p )THEN
-                  ll_coincidence=.FALSE.
-                  CALL logger_debug("GRID CHECK COINCIDENCE: invalid "//&
-                  &  "i-direction refinement factor ("//&
-                  &   TRIM(fct_str(id_rho(jp_I)))//&
-                  &   ") between fine grid and coarse grid ")
-               ENDIF
-
-            CASE DEFAULT         
-            
+         &              "coarse grid indices: invalid domain." )
+      ENDIF
+
+      IF( .NOT. ll_even )THEN
+         ! case odd refinment in both direction
+         ! work on T-point
+
+         dl_lon0=tl_lon0%d_value(il_ind0(1),il_ind0(2),1,1)
+         dl_lat0=tl_lat0%d_value(il_ind0(1),il_ind0(2),1,1)
+
+         il_ind1(:)=grid_get_closest(tl_lon1%d_value(:,:,1,1),&
+         &                           tl_lat1%d_value(:,:,1,1),&
+         &                           dl_lon0, dl_lat0 )
+
+         ! check i-direction refinement factor
+         DO ji=0,MIN(3,il_imid1)
+
+            IF( il_ind1(1)+ji*id_rho(jp_I)+1 > tl_lon1%t_dim(1)%i_len )THEN
+               CALL logger_warn("GRID CHECK COINCIDENCE: domain to small "//&
+               &  " to check i-direction refinement factor ")
+               EXIT
+            ELSE
+               dl_lon0=tl_lon0%d_value(il_ind0(1)+ji             ,il_ind0(2),1,1)
+               dl_lon1=tl_lon1%d_value(il_ind1(1)+ji*id_rho(jp_I),il_ind1(2),1,1)
+
+               ! assume there could be little difference due to interpolation
                IF( ABS(dl_lon1 - dl_lon0) > dp_delta )THEN
                   ll_coincidence=.FALSE.
@@ -4236,37 +4830,20 @@
                   &  ") between fine grid and coarse grid ")
                ENDIF
-            
-            END SELECT
-         ENDIF
-
-      ENDDO
-
-      ! check j-direction refinement factor
-      DO jj=1,MIN(3,il_jmid1)
-
-         IF( il_indF(2)+jj*id_rho(jp_J)+1 > tl_lat1%t_dim(2)%i_len )THEN
-            CALL logger_warn("GRID CHECK COINCIDENCE: domain to small "//&
-            &  " to check j-direction refinement factor ")
-            EXIT
-         ELSE      
-            dl_lat1=tl_lat1%d_value(il_indF(1),il_indF(2)+jj*id_rho(jp_J),1,1)
-            dl_lat0=tl_lat0%d_value(il_indC(1),il_indC(2)+jj,1,1)
-
-            dl_lat1p=tl_lat1%d_value(il_indF(1),il_indF(2)+jj*id_rho(jp_J)+1,1,1)
-
-            SELECT CASE(MOD(id_rho(jp_J),2))
-
-            CASE(0)
-               
-               IF( dl_lat1 >= dl_lat0 .OR. dl_lat0 >= dl_lat1p )THEN
-                  ll_coincidence=.FALSE.
-                  CALL logger_debug("GRID CHECK COINCIDENCE: invalid "//&
-                  &  "j-direction refinement factor ("//&
-                  &   TRIM(fct_str(id_rho(jp_J)))//&
-                  &  ") between fine grid and coarse grid ")
-               ENDIF
-
-            CASE DEFAULT
-
+            ENDIF
+
+         ENDDO
+
+         ! check j-direction refinement factor
+         DO jj=0,MIN(3,il_jmid1)
+
+            IF( il_ind1(2)+jj*id_rho(jp_J)+1 > tl_lat1%t_dim(2)%i_len )THEN
+               CALL logger_warn("GRID CHECK COINCIDENCE: domain to small "//&
+               &  " to check j-direction refinement factor ")
+               EXIT
+            ELSE      
+               dl_lat0=tl_lat0%d_value(il_ind0(1),il_ind0(2)+jj             ,1,1)
+               dl_lat1=tl_lat1%d_value(il_ind1(1),il_ind1(2)+jj*id_rho(jp_J),1,1)
+
+               ! assume there could be little difference due to interpolation
                IF( ABS(dl_lat1-dl_lat0) > dp_delta )THEN
                   ll_coincidence=.FALSE.
@@ -4276,9 +4853,159 @@
                   &  ") between fine grid and coarse grid ")
                ENDIF
-
-            END SELECT
-         ENDIF
-
-      ENDDO
+            ENDIF
+
+         ENDDO
+
+      ELSE
+         ! case even refinment at least in one direction
+         ! work on F-point
+
+         dl_delta=dp_delta
+         ! look for lower left fine point in coarse cell.
+         IF( ll_grid0F )THEN
+      
+            ! lower left corner of coarse cell
+            dl_lon0F=tl_lon0F%d_value(il_ind0(1)-1,il_ind0(2)-1,1,1)
+            dl_lat0F=tl_lat0F%d_value(il_ind0(1)-1,il_ind0(2)-1,1,1)
+
+         ELSE
+
+            ! approximate lower left corner of coarse cell (with T point)
+            dl_lon0F=( tl_lon0%d_value(il_ind0(1)  ,il_ind0(2)  ,1,1) + &
+            &          tl_lon0%d_value(il_ind0(1)  ,il_ind0(2)-1,1,1) + &
+            &          tl_lon0%d_value(il_ind0(1)-1,il_ind0(2)  ,1,1) + &
+            &          tl_lon0%d_value(il_ind0(1)-1,il_ind0(2)-1,1,1) ) * 0.25
+
+            dl_lat0F=( tl_lat0%d_value(il_ind0(1)  ,il_ind0(2)  ,1,1) + &
+            &          tl_lat0%d_value(il_ind0(1)  ,il_ind0(2)-1,1,1) + &
+            &          tl_lat0%d_value(il_ind0(1)-1,il_ind0(2)  ,1,1) + &
+            &          tl_lat0%d_value(il_ind0(1)-1,il_ind0(2)-1,1,1) ) * 0.25
+
+            ! as we use approximation of F-point we relax condition
+            dl_delta=100*dp_delta
+
+         ENDIF
+
+         IF( ll_grid1F )THEN
+      
+            il_ind1(:)=grid_get_closest(tl_lon1F%d_value(:,:,1,1),&
+            &                           tl_lat1F%d_value(:,:,1,1),&
+            &                           dl_lon0F, dl_lat0F )
+
+         ELSE
+
+            il_ill1(:)=grid_get_closest(tl_lon1%d_value(:,:,1,1),&
+            &                           tl_lat1%d_value(:,:,1,1),&
+            &                           dl_lon0F, dl_lat0F, 'll' )
+
+            il_ilr1(:)=grid_get_closest(tl_lon1%d_value(:,:,1,1),&
+            &                           tl_lat1%d_value(:,:,1,1),&
+            &                           dl_lon0F, dl_lat0F, 'lr' )
+
+            il_iul1(:)=grid_get_closest(tl_lon1%d_value(:,:,1,1),&
+            &                           tl_lat1%d_value(:,:,1,1),&
+            &                           dl_lon0F, dl_lat0F, 'ul' )
+
+            il_iur1(:)=grid_get_closest(tl_lon1%d_value(:,:,1,1),&
+            &                           tl_lat1%d_value(:,:,1,1),&
+            &                           dl_lon0F, dl_lat0F, 'ur' )
+
+            ! as we use approximation of F-point we relax condition
+            dl_delta=100*dp_delta
+
+         ENDIF
+
+         ! check i-direction refinement factor
+         DO ji=0,MIN(3,il_imid1)
+
+            IF( il_ind1(1)+ji*id_rho(jp_I)+1 > tl_lon1%t_dim(1)%i_len )THEN
+               CALL logger_warn("GRID CHECK COINCIDENCE: domain to small "//&
+               &  " to check i-direction refinement factor ")
+               EXIT
+            ELSE
+               IF( ll_grid0F )THEN
+                  dl_lon0F=tl_lon0F%d_value(il_ind0(1)+ji-1, il_ind0(2)-1,1,1)
+               ELSE
+                  dl_lon0F= 0.25 * &
+                  & ( tl_lon0%d_value(il_ind0(1)+ji  , il_ind0(2)  ,1,1) + &
+                  &   tl_lon0%d_value(il_ind0(1)+ji-1, il_ind0(2)  ,1,1) + &
+                  &   tl_lon0%d_value(il_ind0(1)+ji  , il_ind0(2)-1,1,1) + &
+                  &   tl_lon0%d_value(il_ind0(1)+ji-1, il_ind0(2)-1,1,1) )
+               ENDIF
+
+               IF( ll_grid1F )THEN
+                  dl_lon1F= tl_lon1F%d_value( il_ind1(1)+ji*id_rho(jp_I), &
+                                            & il_ind1(2),1,1)
+               ELSE
+                  dl_lon1F= 0.25 * &
+                  & ( tl_lon1%d_value( il_ill1(1)+ji*id_rho(jp_I), &
+                                     & il_ill1(2),1,1) + &
+                  &   tl_lon1%d_value( il_ilr1(1)+ji*id_rho(jp_I), &
+                                     & il_ilr1(2),1,1) + &
+                  &   tl_lon1%d_value( il_iul1(1)+ji*id_rho(jp_I), &
+                                     & il_iul1(2),1,1) + &
+                  &   tl_lon1%d_value( il_iur1(1)+ji*id_rho(jp_I), &
+                                     & il_iur1(2),1,1) )
+                  
+               ENDIF
+
+               ! assume there could be little difference due to interpolation
+               IF( ABS(dl_lon1F - dl_lon0F) > dl_delta )THEN
+                  ll_coincidence=.FALSE.
+                  CALL logger_debug("GRID CHECK COINCIDENCE: invalid "//&
+                  &  "i-direction refinement factor ("//&
+                  &   TRIM(fct_str(id_rho(jp_I)))//&
+                  &  ") between fine grid and coarse grid ")
+               ENDIF
+            ENDIF
+
+         ENDDO
+
+         ! check j-direction refinement factor
+         DO jj=0,MIN(3,il_jmid1)
+
+            IF( il_ind1(2)+jj*id_rho(jp_J)+1 > tl_lat1%t_dim(2)%i_len )THEN
+               CALL logger_warn("GRID CHECK COINCIDENCE: domain to small "//&
+               &  " to check j-direction refinement factor ")
+               EXIT
+            ELSE      
+               IF( ll_grid0F )THEN
+                  dl_lat0F=tl_lat0F%d_value(il_ind0(1)-1, il_ind0(2)+jj-1,1,1)
+               ELSE
+                  dl_lat0F= 0.25 * &
+                  & ( tl_lat0%d_value(il_ind0(1)  , il_ind0(2)+jj  ,1,1) + &
+                  &   tl_lat0%d_value(il_ind0(1)-1, il_ind0(2)+jj  ,1,1) + &
+                  &   tl_lat0%d_value(il_ind0(1)  , il_ind0(2)+jj-1,1,1) + &
+                  &   tl_lat0%d_value(il_ind0(1)-1, il_ind0(2)+jj-1,1,1) )
+               ENDIF
+
+               IF( ll_grid1F )THEN
+                  dl_lat1F= tl_lat1F%d_value( il_ind1(1), &
+                                            & il_ind1(2)+jj*id_rho(jp_J),1,1)
+               ELSE
+                  dl_lat1F= 0.25 * &
+                  & ( tl_lat1%d_value( il_ill1(1), &
+                                     & il_ill1(2)+jj*id_rho(jp_J),1,1) + &
+                  &   tl_lat1%d_value( il_ilr1(1), &
+                                     & il_ilr1(2)+jj*id_rho(jp_J),1,1) + &
+                  &   tl_lat1%d_value( il_iul1(1), &
+                                     & il_iul1(2)+jj*id_rho(jp_J),1,1) + &
+                  &   tl_lat1%d_value( il_iur1(1), &
+                                     & il_iur1(2)+jj*id_rho(jp_J),1,1) )
+                  
+               ENDIF
+
+               ! assume there could be little difference due to interpolation
+               IF( ABS(dl_lat1F - dl_lat0F) > dl_delta )THEN
+                  ll_coincidence=.FALSE.
+                  CALL logger_debug("GRID CHECK COINCIDENCE: invalid "//&
+                  &  "i-direction refinement factor ("//&
+                  &   TRIM(fct_str(id_rho(jp_I)))//&
+                  &  ") between fine grid and coarse grid ")
+               ENDIF
+            ENDIF
+
+         ENDDO
+      ENDIF
 
       ! clean 
@@ -4851,11 +5578,11 @@
 
          ! copy structure
-          tl_mpp=mpp_copy(td_mpp)
-
-          CALL logger_info("GRID GET FINE GHOST perio"//TRIM(fct_str(tl_mpp%i_perio)))
-          IF( tl_mpp%i_perio < 0 )THEN
-             ! compute NEMO periodicity index
-             CALL grid_get_info(tl_mpp)
-          ENDIF
+         tl_mpp=mpp_copy(td_mpp)
+
+         CALL logger_info("GRID GET FINE GHOST perio"//TRIM(fct_str(tl_mpp%i_perio)))
+         IF( tl_mpp%i_perio < 0 )THEN
+            ! compute NEMO periodicity index
+            CALL grid_get_info(tl_mpp)
+         ENDIF
 
          SELECT CASE(tl_mpp%i_perio)
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/interp_linear.f90
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/interp_linear.f90	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/interp_linear.f90	(revision 6392)
@@ -627,13 +627,13 @@
       
       IF( ld_even(jp_I) )THEN
-         dl_dx=1./REAL(id_rho(jp_I)-1)
+         dl_dx=1._dp/REAL(id_rho(jp_I)-1,dp)
       ELSE ! odd refinement
-         dl_dx=1./REAL(id_rho(jp_I))
+         dl_dx=1._dp/REAL(id_rho(jp_I),dp)
       ENDIF
 
       IF( ld_even(jp_J) )THEN
-         dl_dy=1./REAL(id_rho(jp_J)-1)
+         dl_dy=1._dp/REAL(id_rho(jp_J)-1,dp)
       ELSE ! odd refinement
-         dl_dy=1./REAL(id_rho(jp_J))
+         dl_dy=1._dp/REAL(id_rho(jp_J),dp)
       ENDIF
 
@@ -642,7 +642,7 @@
 
          IF( ld_even(jp_J) )THEN
-            dl_y=(jj-1)*dl_dy - dl_dy*0.5 
+            dl_y=REAL(jj-1,dp)*dl_dy - dl_dy*0.5_dp
          ELSE ! odd refinement
-            dl_y=(jj-1)*dl_dy 
+            dl_y=REAL(jj-1,dp)*dl_dy 
          ENDIF
 
@@ -653,7 +653,7 @@
 
             IF( ld_even(jp_I) )THEN
-               dl_x=(ji-1)*dl_dx - dl_dx*0.5 
+               dl_x=REAL(ji-1,dp)*dl_dx - dl_dx*0.5_dp 
             ELSE ! odd refinement
-               dl_x=(ji-1)*dl_dx 
+               dl_x=REAL(ji-1,dp)*dl_dx 
             ENDIF
 
@@ -692,14 +692,14 @@
       
       IF( ld_even )THEN
-         dl_dx=1./REAL(id_rho-1)
+         dl_dx=1._dp/REAL(id_rho-1,dp)
       ELSE ! odd refinement
-         dl_dx=1./REAL(id_rho)
+         dl_dx=1._dp/REAL(id_rho,dp)
       ENDIF
 
       DO ji=1,id_rho+1
          IF( ld_even )THEN
-            dl_x=(ji-1)*dl_dx - dl_dx*0.5 
+            dl_x=REAL(ji-1,dp)*dl_dx - dl_dx*0.5_dp 
          ELSE ! odd refinement
-            dl_x=(ji-1)*dl_dx 
+            dl_x=REAL(ji-1,dp)*dl_dx 
          ENDIF
 
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/iom_cdf.f90
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/iom_cdf.f90	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/iom_cdf.f90	(revision 6392)
@@ -214,5 +214,4 @@
             &                       cmode=NF90_64BIT_OFFSET,&
             &                       ncid=td_file%i_id)
-         !NF90_WRITE,               &
             CALL iom_cdf__check(il_status," IOM CDF CREATE: ")
 
@@ -222,4 +221,5 @@
 
       ELSE
+
          IF( td_file%i_id /= 0 )THEN
 
@@ -239,6 +239,4 @@
                CALL iom_cdf__check(il_status," IOM CDF OPEN: ")
 
-               CALL logger_trace("IOM CDF OPEN "//TRIM(td_file%c_name)//" "//&
-                  &  TRIM(fct_str(td_file%i_id)))
             ELSE
 
@@ -363,7 +361,10 @@
       ! Argument      
       TYPE(TFILE), INTENT(INOUT) :: td_file
+      ! local variable
+      TYPE(TDIM) :: tl_dim
 
       ! loop indices
       INTEGER(i4) :: ji
+      INTEGER(i4) :: ii
       !----------------------------------------------------------------
 
@@ -374,7 +375,17 @@
 
       IF( td_file%i_ndim > 0 )THEN
+         ii=1
          DO ji = 1, td_file%i_ndim
             ! read dimension information
-            td_file%t_dim(ji)=iom_cdf_read_dim( td_file, ji)
+            tl_dim=iom_cdf_read_dim( td_file, ji)
+            IF( .NOT. dim_is_dummy(tl_dim) )THEN
+               IF( ii > ip_maxdim )THEN
+                  CALL logger_fatal("IOM CDF OPEN: too much dimension "//&
+                  & "to be read. you should remove dummy dimension using "//&
+                  & " configuration file")
+               ENDIF
+               td_file%t_dim(ii)=dim_copy(tl_dim)
+               ii=ii+1
+            ENDIF
          ENDDO
 
@@ -418,6 +429,9 @@
 
       ! local variable
+      TYPE(TATT) :: tl_att
+
       ! loop indices
       INTEGER(i4) :: ji
+      INTEGER(i4) :: ii
       !----------------------------------------------------------------
 
@@ -429,7 +443,12 @@
          ALLOCATE(td_file%t_att(td_file%i_natt))
 
+         ii=1
          DO ji = 1, td_file%i_natt
             ! read global attribute
-            td_file%t_att(ji)=iom_cdf_read_att( td_file, NF90_GLOBAL, ji)
+            tl_att=iom_cdf_read_att( td_file, NF90_GLOBAL, ji)
+            IF( .NOT. att_is_dummy(tl_att) )THEN
+               td_file%t_att(ii)=att_copy(tl_att)
+               ii=ii+1
+            ENDIF
             
          ENDDO
@@ -450,4 +469,8 @@
    !> @author J.Paul
    !> @date November, 2013 - Initial Version
+   !> @date September, 2015
+   !> - manage useless (dummy) variable
+   !> @date January, 2016
+   !> - increment n3d for 4D variable
    !
    !> @param[inout] td_file   file structure
@@ -460,66 +483,92 @@
       ! local variable
       INTEGER(i4) :: il_attid
+      INTEGER(i4) :: il_nvar
+
+      TYPE(TVAR), DIMENSION(:), ALLOCATABLE  :: tl_var
 
       ! loop indices
       INTEGER(i4) :: ji
+      INTEGER(i4) :: ii
       !----------------------------------------------------------------
 
       IF( td_file%i_nvar > 0 )THEN
+
          IF(ASSOCIATED(td_file%t_var))THEN
             CALL var_clean(td_file%t_var(:))
             DEALLOCATE(td_file%t_var)
          ENDIF
+
+         il_nvar=td_file%i_nvar
+         ALLOCATE(tl_var(il_nvar))
+         ii=0
+         DO ji = 1, il_nvar
+           ! read variable information
+           tl_var(ji)=iom_cdf__read_var_meta( td_file, ji) 
+           IF( .NOT. var_is_dummy(tl_var(ji)) )THEN
+              ii=ii+1
+           ENDIF
+         ENDDO
+
+         ! update number of variable used
+         td_file%i_nvar=ii
+
          ALLOCATE(td_file%t_var(td_file%i_nvar))
 
-         DO ji = 1, td_file%i_nvar
-            ! read dimension information
-            td_file%t_var(ji)=iom_cdf__read_var_meta( td_file, ji)
-            SELECT CASE(td_file%t_var(ji)%i_ndim)
-               CASE(0)
-                  td_file%i_n0d=td_file%i_n0d+1
-               CASE(1)
-                  td_file%i_n1d=td_file%i_n1d+1
-                  td_file%i_rhd=td_file%i_rhd+1
-               CASE(2)
-                  td_file%i_n2d=td_file%i_n2d+1
-                  td_file%i_rhd=td_file%i_rhd+1
-               CASE(3)
-                  td_file%i_n3d=td_file%i_n3d+1
-                  td_file%i_rhd=td_file%i_rhd+td_file%t_dim(3)%i_len
-            END SELECT
-
-            ! look for depth id
-            IF( INDEX(TRIM(fct_lower(td_file%t_var(ji)%c_name)),'depth')/=0 )THEN
-               IF( td_file%i_depthid == 0 )THEN
-                  td_file%i_depthid=ji
-               ELSE
-                  IF( td_file%i_depthid /= ji )THEN
-                     CALL logger_error("IOM CDF GET FILE VAR: find more"//&
-                        &  " than one depth variable in file "//&
-                        &  TRIM(td_file%c_name) )
+         ii=0
+         DO ji = 1, il_nvar
+            IF( .NOT. var_is_dummy(tl_var(ji)) )THEN
+               ii=ii+1
+               td_file%t_var(ii)=var_copy(tl_var(ji))
+               SELECT CASE(td_file%t_var(ii)%i_ndim)
+                  CASE(0)
+                     td_file%i_n0d=td_file%i_n0d+1
+                  CASE(1)
+                     td_file%i_n1d=td_file%i_n1d+1
+                     td_file%i_rhd=td_file%i_rhd+1
+                  CASE(2)
+                     td_file%i_n2d=td_file%i_n2d+1
+                     td_file%i_rhd=td_file%i_rhd+1
+                  CASE(3,4)
+                     td_file%i_n3d=td_file%i_n3d+1
+                     td_file%i_rhd=td_file%i_rhd+td_file%t_dim(3)%i_len
+               END SELECT
+
+               ! look for depth id
+               IF( INDEX(TRIM(fct_lower(td_file%t_var(ii)%c_name)),'depth')/=0 )THEN
+                  IF( td_file%i_depthid == 0 )THEN
+                     td_file%i_depthid=ji
+                  ELSE
+                     IF( td_file%i_depthid /= ji )THEN
+                        CALL logger_error("IOM CDF GET FILE VAR: find more"//&
+                           &  " than one depth variable in file "//&
+                           &  TRIM(td_file%c_name) )
+                     ENDIF
                   ENDIF
                ENDIF
-            ENDIF
-
-            ! look for time id
-            IF( INDEX(TRIM(fct_lower(td_file%t_var(ji)%c_name)),'time')/=0 )THEN
-               IF( td_file%i_timeid == 0 )THEN
-                  td_file%i_timeid=ji
-               ELSE
-                  il_attid=0
-                  IF( ASSOCIATED(td_file%t_var(ji)%t_att) )THEN
-                     il_attid=att_get_id(td_file%t_var(ji)%t_att(:),'calendar')
-                  ENDIF
-                  IF( il_attid /= 0 )THEN
+
+               ! look for time id
+               IF( INDEX(TRIM(fct_lower(td_file%t_var(ii)%c_name)),'time')/=0 )THEN
+                  IF( td_file%i_timeid == 0 )THEN
                      td_file%i_timeid=ji
-                  !ELSE
-                  !   CALL logger_error("IOM CDF GET FILE VAR: find more "//&
-                  !   &                 "than one time variable in file "//&
-                  !   &                 TRIM(td_file%c_name) )
+                  ELSE
+                     il_attid=0
+                     IF( ASSOCIATED(td_file%t_var(ii)%t_att) )THEN
+                        il_attid=att_get_id(td_file%t_var(ii)%t_att(:),'calendar')
+                     ENDIF
+                     IF( il_attid /= 0 )THEN
+                        td_file%i_timeid=ji
+                     !ELSE
+                     !   CALL logger_error("IOM CDF GET FILE VAR: find more "//&
+                     !   &                 "than one time variable in file "//&
+                     !   &                 TRIM(td_file%c_name) )
+                     ENDIF
                   ENDIF
                ENDIF
+
             ENDIF
-
          ENDDO
+
+         CALL var_clean(tl_var(:))
+         DEALLOCATE(tl_var)
 
       ELSE
@@ -605,6 +654,4 @@
       ELSE      
 
-         iom_cdf__read_dim_id%i_id=id_dimid
-
          CALL logger_trace( &
          &  " IOM CDF READ DIM: dimension "//TRIM(fct_str(id_dimid))//&
@@ -627,4 +674,6 @@
       ENDIF
 
+      iom_cdf__read_dim_id%i_id=id_dimid
+
    END FUNCTION iom_cdf__read_dim_id
    !-------------------------------------------------------------------
@@ -748,5 +797,5 @@
                IF( LEN(cl_value) < il_len )THEN
 
-                  CALL logger_error( &
+                  CALL logger_warn( &
                   &  " IOM CDF READ ATT: not enough space to put "//&
                   &  "attribute "//TRIM(cl_name) )
@@ -1223,4 +1272,6 @@
    !> @date September, 2014
    !> - force to use FillValue=1.e20 if no FillValue for coordinate variable.
+   !> @date September, 2015
+   !> - manage useless (dummy) attribute
    !
    !> @param[in] td_file   file structure
@@ -1250,4 +1301,5 @@
 
       ! loop indices
+      INTEGER(i4) :: ji
       !----------------------------------------------------------------
       ! check if file opened
@@ -1275,6 +1327,7 @@
          &                                il_natt )
          CALL iom_cdf__check(il_status,"IOM CDF READ VAR META: ")
+
          !!! fill variable dimension structure
-         tl_dim(:)=iom_cdf__read_var_dim( td_file, il_ndim, il_dimid(:) )
+         tl_dim(:)=iom_cdf__read_var_dim( td_file, il_ndim, cl_name, il_dimid(:) )
 
          IF( il_natt /= 0 )THEN
@@ -1353,4 +1406,11 @@
          &                                tl_att(:), id_id=id_varid )
 
+         !! look for dummy attribute
+         DO ji=il_natt,1,-1
+            IF( att_is_dummy(tl_att(ji)) )THEN
+               CALL var_del_att(iom_cdf__read_var_meta, tl_att(ji))
+            ENDIF
+         ENDDO
+
          ! clean
          CALL dim_clean(tl_dim(:))
@@ -1373,20 +1433,26 @@
    !> So the array of dimension structure of a variable is always compose of 4
    !> dimension (use or not). 
-   !
+   !>
+   !> @warn dummy dimension are not used. 
+   !>
    !> @author J.Paul
    !> @date November, 2013 - Initial Version
    !> @date July, 2015 
    !> - Bug fix: use order to disorder table (see dim_init)
+   !> @date September, 2015
+   !> - check dummy dimension
    !>
    !> @param[in] td_file   file structure
    !> @param[in] id_ndim   number of dimension
+   !> @param[in] cd_name   variable name
    !> @param[in] id_dimid  array of dimension id
    !> @return array dimension structure 
    !-------------------------------------------------------------------
-   FUNCTION iom_cdf__read_var_dim(td_file, id_ndim, id_dimid)
+   FUNCTION iom_cdf__read_var_dim(td_file, id_ndim, cd_name, id_dimid)
       IMPLICIT NONE
       ! Argument      
       TYPE(TFILE),               INTENT(IN) :: td_file
       INTEGER(i4),               INTENT(IN) :: id_ndim
+      CHARACTER(LEN=*)         , INTENT(IN) :: cd_name
       INTEGER(i4), DIMENSION(:), INTENT(IN) :: id_dimid
 
@@ -1401,4 +1467,5 @@
       ! loop indices
       INTEGER(i4) :: ji
+      INTEGER(i4) :: ii
       !----------------------------------------------------------------
 
@@ -1415,16 +1482,32 @@
          CALL dim_clean(tl_dim(:))
 
-      ELSE IF( id_ndim > 0 .AND. id_ndim <= 4 )THEN
-
-
+      ELSE IF( id_ndim > 0 )THEN
+
+
+         ii=1
          DO ji = 1, id_ndim
-            CALL logger_debug( " IOM CDF READ VAR DIM: get variable "//&
-               &  "dimension "//TRIM(fct_str(ji)) )
-
-            il_xyzt2(ji)=td_file%t_dim(id_dimid(ji))%i_xyzt2
-
-            ! read dimension information
-            tl_dim(ji) = dim_init( td_file%t_dim(il_xyzt2(ji))%c_name, &
-            &                      td_file%t_dim(il_xyzt2(ji))%i_len )
+
+            !!! check no dummy dimension to be used
+            IF( ANY(td_file%t_dim(:)%i_id == id_dimid(ji)) )THEN
+               IF( ii > ip_maxdim )THEN
+                  CALL logger_error(" IOM CDF READ VAR DIM: "//&
+                  &  "too much dimensions for variable "//&
+                  &  TRIM(cd_name)//". check dummy configuration file.")
+               ENDIF
+
+               CALL logger_debug( " IOM CDF READ VAR DIM: get variable "//&
+                  &  "dimension "//TRIM(fct_str(ji)) )
+
+               il_xyzt2(ii)=td_file%t_dim(id_dimid(ji))%i_xyzt2
+
+               ! read dimension information
+               tl_dim(ii) = dim_init( td_file%t_dim(il_xyzt2(ii))%c_name, &
+               &                      td_file%t_dim(il_xyzt2(ii))%i_len )
+            
+               ii=ii+1
+            ELSE
+               CALL logger_debug( " IOM CDF READ VAR DIM: dummy variable "//&
+               &  "dimension "//TRIM(fct_str(ji))//" not used." )
+            ENDIF
          ENDDO
 
@@ -1436,9 +1519,4 @@
          ! clean
          CALL dim_clean(tl_dim(:))
-
-      ELSE
-
-         CALL logger_error(" IOM CDF READ VAR DIM: can't manage "//&
-         &              TRIM(fct_str(id_ndim))//" dimension(s)" )
 
       ENDIF
@@ -1943,4 +2021,6 @@
    !> @author J.Paul
    !> @date November, 2013 - Initial Version
+   !> @date September, 2015
+   !> - do not force to use zero as FillValue for any meshmask variable
    !
    !> @param[inout] td_file   file structure
@@ -1976,7 +2056,4 @@
       ! check if file and variable dimension conform
       IF( file_check_var_dim(td_file, td_var) )THEN
-
-         ! check variable dimension expected
-         CALL var_check_dim(td_var)
 
          ll_chg=.TRUE.
@@ -1998,5 +2075,19 @@
                CASE('nav_lon','nav_lat', &
                   & 'glamt','glamu','glamv','glamf', &
-                  & 'gphit','gphiu','gphiv','gphif')
+                  & 'gphit','gphiu','gphiv','gphif', &
+                  & 'e1t','e1u','e1v','e1f',         &
+                  & 'e2t','e2u','e2v','e2f','ff',    &
+                  & 'gcost','gcosu','gcosv','gcosf', &
+                  & 'gsint','gsinu','gsinv','gsinf', &
+                  & 'mbathy','misf','isf_draft',     &
+                  & 'hbatt','hbatu','hbatv','hbatf', &
+                  & 'gsigt','gsigu','gsigv','gsigf', &
+                  & 'e3t_0','e3u_0','e3v_0','e3w_0', &
+                  & 'e3f_0','gdepw_1d','gdept_1d',   &
+                  & 'e3tp','e3wp','gdepw_0','rx1',   &
+                  & 'gdept_0','gdepu','gdepv',       &
+                  & 'hdept','hdepw','e3w_1d','e3t_1d',&
+                  & 'tmask','umask','vmask','fmask'  )
+                  ! do not change for coordinates and meshmask variables
             END SELECT
          ENDIF
@@ -2118,41 +2209,39 @@
          ENDIF
 
-         IF( tl_var%t_att(ji)%i_type == NF90_CHAR )THEN
-            IF( TRIM(tl_var%t_att(ji)%c_value) /= '' )THEN
-               il_status = NF90_PUT_ATT(td_file%i_id, iom_cdf__write_var_def, &
-               &                        TRIM(tl_var%t_att(ji)%c_name),        &
-               &                        TRIM(tl_var%t_att(ji)%c_value)        )
-               CALL iom_cdf__check(il_status,"IOM CDF WRITE VAR DEF: ")
-            ENDIF
-         ELSE
-            SELECT CASE(tl_var%t_att(ji)%i_type)
-               CASE(NF90_BYTE)
-                  il_status = NF90_PUT_ATT(td_file%i_id,                   &
-                  &                        iom_cdf__write_var_def,         &
-                  &                        TRIM(tl_var%t_att(ji)%c_name),  &
-                  &                        INT(tl_var%t_att(ji)%d_value(:),i1))
-               CASE(NF90_SHORT)
-                  il_status = NF90_PUT_ATT(td_file%i_id,                   &
-                  &                        iom_cdf__write_var_def,         &
-                  &                        TRIM(tl_var%t_att(ji)%c_name),  &
-                  &                        INT(tl_var%t_att(ji)%d_value(:),i2))
-               CASE(NF90_INT)
-                  il_status = NF90_PUT_ATT(td_file%i_id,                   &
-                  &                        iom_cdf__write_var_def,         &
-                  &                        TRIM(tl_var%t_att(ji)%c_name),  &
-                  &                        INT(tl_var%t_att(ji)%d_value(:),i4))
-               CASE(NF90_FLOAT)
-                  il_status = NF90_PUT_ATT(td_file%i_id,                   &
-                  &                        iom_cdf__write_var_def,         &
-                  &                        TRIM(tl_var%t_att(ji)%c_name),  &
-                  &                        REAL(tl_var%t_att(ji)%d_value(:),sp))
-               CASE(NF90_DOUBLE)
-                  il_status = NF90_PUT_ATT(td_file%i_id,                   &
-                  &                        iom_cdf__write_var_def,         &
-                  &                        TRIM(tl_var%t_att(ji)%c_name),  &
-                  &                        REAL(tl_var%t_att(ji)%d_value(:),dp))
-            END SELECT
-            CALL iom_cdf__check(il_status,"IOM CDF WRITE VAR DEF: ")
-         ENDIF
+         SELECT CASE(tl_var%t_att(ji)%i_type)
+            CASE(NF90_CHAR)
+               IF( TRIM(tl_var%t_att(ji)%c_value) /= '' )THEN
+                  il_status = NF90_PUT_ATT(td_file%i_id, iom_cdf__write_var_def, &
+                  &                        TRIM(tl_var%t_att(ji)%c_name),        &
+                  &                        TRIM(tl_var%t_att(ji)%c_value)        )
+               ENDIF
+            CASE(NF90_BYTE)
+               il_status = NF90_PUT_ATT(td_file%i_id,                   &
+               &                        iom_cdf__write_var_def,         &
+               &                        TRIM(tl_var%t_att(ji)%c_name),  &
+               &                        INT(tl_var%t_att(ji)%d_value(:),i1))
+            CASE(NF90_SHORT)
+               il_status = NF90_PUT_ATT(td_file%i_id,                   &
+               &                        iom_cdf__write_var_def,         &
+               &                        TRIM(tl_var%t_att(ji)%c_name),  &
+               &                        INT(tl_var%t_att(ji)%d_value(:),i2))
+            CASE(NF90_INT)
+               il_status = NF90_PUT_ATT(td_file%i_id,                   &
+               &                        iom_cdf__write_var_def,         &
+               &                        TRIM(tl_var%t_att(ji)%c_name),  &
+               &                        INT(tl_var%t_att(ji)%d_value(:),i4))
+            CASE(NF90_FLOAT)
+               il_status = NF90_PUT_ATT(td_file%i_id,                   &
+               &                        iom_cdf__write_var_def,         &
+               &                        TRIM(tl_var%t_att(ji)%c_name),  &
+               &                        REAL(tl_var%t_att(ji)%d_value(:),sp))
+            CASE(NF90_DOUBLE)
+               il_status = NF90_PUT_ATT(td_file%i_id,                   &
+               &                        iom_cdf__write_var_def,         &
+               &                        TRIM(tl_var%t_att(ji)%c_name),  &
+               &                        REAL(tl_var%t_att(ji)%d_value(:),dp))
+         END SELECT
+         CALL iom_cdf__check(il_status,"IOM CDF WRITE VAR DEF: ")
+
       ENDDO
 
@@ -2200,5 +2289,5 @@
          &  (td_var%d_value(:,:,:,:)-td_var%d_ofs)/td_var%d_scf
       END WHERE
-      
+
       jj=0
       DO ji = 1, ip_maxdim
@@ -2226,10 +2315,11 @@
 
       ! put value
-      CALL logger_trace( &
+      CALL logger_debug( &
       &  "IOM CDF WRITE VAR VALUE: put "//TRIM(td_var%c_name)//" value "//&
       &  "in file "//TRIM(td_file%c_name))
 
       il_status = NF90_PUT_VAR( td_file%i_id, td_var%i_id, dl_value(:,:,:,:))
-      CALL iom_cdf__check(il_status,"IOM CDF WRITE VAR VALUE: ")
+      CALL iom_cdf__check(il_status,"IOM CDF WRITE VAR VALUE ("//&
+         &  TRIM(td_var%c_name)//") :" )
 
       DEALLOCATE( dl_value )
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/iom_dom.f90
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/iom_dom.f90	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/iom_dom.f90	(revision 6392)
@@ -234,5 +234,5 @@
                CALL logger_error( &
                &  " IOM DOM READ VAR: there is no variable with "//&
-               &  "name or standard name"//TRIM(cd_name)//&
+               &  "name or standard name "//TRIM(cd_name)//&
                &  " in processor/file "//TRIM(td_mpp%t_proc(1)%c_name))
             ENDIF
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/iom_mpp.f90
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/iom_mpp.f90	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/iom_mpp.f90	(revision 6392)
@@ -415,5 +415,5 @@
             ELSE
 
-               CALL logger_error( &
+               CALL logger_fatal( &
                &  " IOM MPP READ VAR: there is no variable with "//&
                &  "name or standard name "//TRIM(cd_name)//&
@@ -648,7 +648,4 @@
          DO ji=1, td_mpp%i_nproc
             IF( td_mpp%t_proc(ji)%i_id /= 0 )THEN
-               !CALL file_del_att(td_mpp%t_proc(ji), 'periodicity')
-               !CALL file_del_att(td_mpp%t_proc(ji), 'ew_overlap')
-
                CALL iom_write_file(td_mpp%t_proc(ji), cd_dimorder)
             ELSE
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/iom_rstdimg.f90
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/iom_rstdimg.f90	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/iom_rstdimg.f90	(revision 6392)
@@ -395,5 +395,7 @@
    !> @author J.Paul
    !> @date November, 2013 - Initial Version
-   !
+   !> @date January, 2016
+   !> - mismatch with "halo" indices
+   !>
    !> @param[inout] td_file   file structure
    !-------------------------------------------------------------------
@@ -494,34 +496,22 @@
       ENDIF
 
-      tl_att=att_init( "DOMAIN_position_first", (/il_impp(il_area), il_jmpp(il_area)/))
+      tl_att=att_init( "SUBDOMAIN_I_left_bottom_indices", il_impp(:) )
       CALL file_move_att(td_file, tl_att)
-
-      tl_att=att_init( "DOMAIN_position_last", (/il_lci(il_area), il_lcj(il_area)/))
+      tl_att=att_init( "SUBDOMAIN_J_left_bottom_indices", il_jmpp(:) )
       CALL file_move_att(td_file, tl_att)
 
-      tl_att=att_init( "DOMAIN_halo_size_start", (/il_ldi(il_area), il_ldj(il_area)/))
+      tl_att=att_init( "SUBDOMAIN_I_dimensions", il_lci(:))
       CALL file_move_att(td_file, tl_att)
-
-      tl_att=att_init( "DOMAIN_halo_size_end", (/il_lei(il_area), il_lej(il_area)/))
+      tl_att=att_init( "SUBDOMAIN_J_dimensions", il_lcj(:))
       CALL file_move_att(td_file, tl_att)
 
-      tl_att=att_init( "DOMAIN_I_position_first", il_impp(:) )
+      tl_att=att_init( "SUBDOMAIN_I_first_indoor_indices", il_ldi(:))
       CALL file_move_att(td_file, tl_att)
-      tl_att=att_init( "DOMAIN_J_position_first", il_jmpp(:) )
+      tl_att=att_init( "SUBDOMAIN_J_first_indoor_indices", il_ldj(:))
       CALL file_move_att(td_file, tl_att)
 
-      tl_att=att_init( "DOMAIN_I_position_last", il_lci(:) )
+      tl_att=att_init( "SUBDOMAIN_I_last_indoor_indices", il_lei(:))
       CALL file_move_att(td_file, tl_att)
-      tl_att=att_init( "DOMAIN_J_position_last", il_lcj(:) )
-      CALL file_move_att(td_file, tl_att)
-
-      tl_att=att_init( "DOMAIN_I_halo_size_start", il_ldi(:) )
-      CALL file_move_att(td_file, tl_att)
-      tl_att=att_init( "DOMAIN_J_halo_size_start", il_ldj(:) )
-      CALL file_move_att(td_file, tl_att)
-
-      tl_att=att_init( "DOMAIN_I_halo_size_end", il_lei(:) )
-      CALL file_move_att(td_file, tl_att)
-      tl_att=att_init( "DOMAIN_J_halo_size_end", il_lej(:) )
+      tl_att=att_init( "SUBDOMAIN_J_last_indoor_indices", il_lej(:))
       CALL file_move_att(td_file, tl_att)
 
@@ -1038,4 +1028,6 @@
    !> @author J.Paul
    !> @date November, 2013 - Initial Version
+   !> @date February, 2016
+   !> - use temporary array to read value from file
    !
    !> @param[in] td_file   file structure
@@ -1059,4 +1051,5 @@
       INTEGER(i4), DIMENSION(ip_maxdim)            :: il_count
 
+      REAL(dp),    DIMENSION(:,:,:)  , ALLOCATABLE :: dl_tmp
       REAL(dp),    DIMENSION(:,:,:,:), ALLOCATABLE :: dl_value
 
@@ -1142,7 +1135,10 @@
          IF( ALL(td_var%t_dim(1:3)%l_use) )THEN
             ! 3D variable (X,Y,Z)
+            ALLOCATE(dl_tmp( td_var%t_dim(1)%i_len, &
+            &                td_var%t_dim(2)%i_len, &
+            &                td_var%t_dim(4)%i_len) )           
             DO ji=1,td_var%t_dim(3)%i_len
                READ(td_file%i_id, IOSTAT=il_status, REC=td_var%i_rec +ji-1) &
-               &  dl_value(:,:,ji,:)
+               &  dl_tmp(:,:,:)
                CALL fct_err(il_status)
                IF( il_status /= 0 )THEN
@@ -1150,5 +1146,7 @@
                   &              TRIM(td_var%c_name))
                ENDIF
+               dl_value(:,:,ji,:)=dl_tmp(:,:,:)
             ENDDO
+            DEALLOCATE(dl_tmp)
          ELSEIF( ALL(td_var%t_dim(1:2)%l_use) )THEN
             ! 2D variable (X,Y)
@@ -1427,5 +1425,7 @@
    !> @author J.Paul
    !> @date November, 2013 - Initial Version
-   !
+   !> @date January, 2016
+   !> - mismatch with "halo" indices
+   !>
    !> @param[inout] td_file   file structure
    !-------------------------------------------------------------------
@@ -1542,6 +1542,6 @@
       &         il_lei(il_nproc),  il_lej(il_nproc) )
 
-      ! get domain first poistion
-      il_ind=att_get_index( td_file%t_att, "DOMAIN_I_position_first" )
+      ! get left bottom indices
+      il_ind=att_get_index( td_file%t_att, "SUBDOMAIN_I_left_bottom_indices" )
       il_impp(:) = 0
       IF( il_ind /= 0 )THEN
@@ -1549,5 +1549,5 @@
       ENDIF
 
-      il_ind=att_get_index( td_file%t_att, "DOMAIN_J_position_first" )
+      il_ind=att_get_index( td_file%t_att, "SUBDOMAIN_J_left_bottom_indices" )
       il_jmpp(:) = 0
       IF( il_ind /= 0 )THEN
@@ -1555,11 +1555,11 @@
       ENDIF
       
-      ! check domain first poistion
+      ! check left bottom indices
       IF( ANY(il_impp(:)==0) .OR. ANY(il_jmpp(:)==0) )THEN
-         CALL logger_warn("WRITE FILE: no data for domain first position")
-      ENDIF
-
-      ! get domain last poistion
-      il_ind=att_get_index( td_file%t_att, "DOMAIN_I_position_last" )
+         CALL logger_warn("WRITE FILE: no data for subdomain left bottom indices")
+      ENDIF
+
+      ! get subdomain dimensions
+      il_ind=att_get_index( td_file%t_att, "SUBDOMAIN_I_dimensions" )
       il_lci(:) = 0
       IF( il_ind /= 0 )THEN
@@ -1567,5 +1567,5 @@
       ENDIF
 
-      il_ind=att_get_index( td_file%t_att, "DOMAIN_J_position_last" )
+      il_ind=att_get_index( td_file%t_att, "SUBDOMAIN_J_dimensions" )
       il_lcj(:) = 0
       IF( il_ind /= 0 )THEN
@@ -1573,11 +1573,11 @@
       ENDIF
 
-      ! check domain last poistion
+      ! check subdomain dimension
       IF( ANY(il_lci(:)==0) .OR. ANY(il_lcj(:)==0) )THEN
-         CALL logger_warn("WRITE FILE: no data for domain last position")
-      ENDIF
-
-      ! get halo size start
-      il_ind=att_get_index( td_file%t_att, "DOMAIN_I_halo_size_start" )
+         CALL logger_warn("WRITE FILE: no data for subdomain dimensions")
+      ENDIF
+
+      ! get first indoor indices
+      il_ind=att_get_index( td_file%t_att, "SUBDOMAIN_I_first_indoor_indices" )
       il_ldi(:) = 0
       IF( il_ind /= 0 )THEN
@@ -1585,5 +1585,5 @@
       ENDIF
 
-      il_ind=att_get_index( td_file%t_att, "DOMAIN_J_halo_size_start" )
+      il_ind=att_get_index( td_file%t_att, "SUBDOMAIN_J_first_indoor_indices" )
       il_ldj(:) = 0
       IF( il_ind /= 0 )THEN
@@ -1591,11 +1591,11 @@
       ENDIF
       
-      ! check halo size start
+      ! check first indoor indices
       IF( ANY(il_ldi(:)==0) .OR. ANY(il_ldj(:)==0) )THEN
-         CALL logger_warn("WRITE FILE: no data for halo size start")
-      ENDIF
-
-      ! get halo size end
-      il_ind=att_get_index( td_file%t_att, "DOMAIN_I_halo_size_end" )
+         CALL logger_warn("WRITE FILE: no data for subdomain first indoor indices")
+      ENDIF
+
+      ! get last indoor indices
+      il_ind=att_get_index( td_file%t_att, "SUBDOMAIN_I_last_indoor_indices" )
       il_lei(:) = 0
       IF( il_ind /= 0 )THEN
@@ -1603,5 +1603,5 @@
       ENDIF
 
-      il_ind=att_get_index( td_file%t_att, "DOMAIN_J_halo_size_end" )
+      il_ind=att_get_index( td_file%t_att, "SUBDOMAIN_J_last_indoor_indices" )
       il_lej(:) = 0
       IF( il_ind /= 0 )THEN
@@ -1609,7 +1609,7 @@
       ENDIF
 
-      ! check halo size end
+      ! check last indoor indices
       IF( ANY(il_lei(:)==0) .OR. ANY(il_lej(:)==0) )THEN
-         CALL logger_warn("WRITE FILE: no data for halo size end")
+         CALL logger_warn("WRITE FILE: no data for subdomain last indoor indices")
       ENDIF      
 
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/logger.f90
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/logger.f90	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/logger.f90	(revision 6392)
@@ -6,6 +6,8 @@
 !
 ! DESCRIPTION:
-!> @brief This module create logger file and allow to fill it depending of verbosity.
+!> @brief This module manage log file.
 !> @details
+!> This module create log file and fill it depending of verbosity.
+!>
 !> verbosity could be choosen between :
 !>    - trace : Most detailed information.
@@ -17,7 +19,9 @@
 !>    - error : Other runtime errors or unexpected conditions.
 !>    - fatal : Severe errors that cause premature termination.
-!>  default verbosity is warning
 !>    - none  : to not create and write any information in logger file.<br />
-!
+!>       @warn in this case only FATAL ERROR will be detected.<br />
+!>
+!> @note default verbosity is warning
+!>
 !> If total number of error exceeded maximum number 
 !> authorized, program stop.
@@ -35,4 +39,9 @@
 !> @code
 !> CALL logger_close()
+!> @endcode
+!>
+!> to clean logger file:<br/>
+!> @code
+!> CALL logger_clean()
 !> @endcode
 !>
@@ -104,4 +113,5 @@
 !>   CALL logger_footer()
 !>   CALL logger_close()
+!>   CALL logger_clean()
 !> @endcode
 !>
@@ -116,4 +126,5 @@
 !>   CALL logger_footer()
 !>   CALL logger_close()
+!>   CALL logger_clean()
 !> @endcode
 !
@@ -125,4 +136,6 @@
 !> - check verbosity validity
 !> - add 'none' verbosity level to not used logger file
+!> @date January, 2016
+!> - add logger_clean subroutine
 !>
 !> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -144,4 +157,5 @@
    PUBLIC :: logger_open        !< create a log file with given verbosity
    PUBLIC :: logger_close       !< close log file
+   PUBLIC :: logger_clean       !< clean log structure
    PUBLIC :: logger_header      !< write header on log file
    PUBLIC :: logger_footer      !< write footer on log file
@@ -273,9 +287,9 @@
       IMPLICIT NONE
       ! local variable
-      INTEGER(i4) :: il_status
-      !----------------------------------------------------------------
-      IF( tm_logger%l_use )THEN
-         IF( tm_logger%i_id /= 0 )THEN
-            tm_logger%i_id = 0
+      INTEGER(i4)   :: il_status
+      !----------------------------------------------------------------
+      IF( tm_logger%l_use )THEN
+         IF( tm_logger%i_id /= 0 )THEN
+            !tm_logger%i_id = 0
             CLOSE( tm_logger%i_id, &
             &      IOSTAT=il_status)      
@@ -289,4 +303,18 @@
 
    END SUBROUTINE logger_close
+   !-------------------------------------------------------------------
+   !> @brief This subroutine clean a log structure.
+   !>
+   !> @author J.Paul
+   !> @date January, 2016 - Initial Version
+   !-------------------------------------------------------------------
+   SUBROUTINE logger_clean()
+      IMPLICIT NONE
+      ! local variable
+      TYPE(TLOGGER) :: tl_logger
+      !----------------------------------------------------------------
+      tm_logger = tl_logger
+
+   END SUBROUTINE logger_clean
    !-------------------------------------------------------------------
    !> @brief This subroutine flushing output into log file.
@@ -537,8 +565,6 @@
       IF( tm_logger%l_use )THEN
          IF( tm_logger%i_id /= 0 )THEN
-            IF( TRIM(tm_logger%c_verb) /= 'none' )THEN
-               ! increment the error number
-               tm_logger%i_nerror=tm_logger%i_nerror+1
-            ENDIF
+            ! increment the error number
+            tm_logger%i_nerror=tm_logger%i_nerror+1
 
             IF( INDEX(TRIM(tm_logger%c_verb),'error')/=0 )THEN
@@ -571,4 +597,6 @@
    !> @author J.Paul
    !> @date November, 2013 - Initial Version
+   !> @date September, 2015
+   !> - stop program for FATAL ERROR if verbosity is none
    !
    !> @param[in] cd_msg message to write
@@ -598,4 +626,7 @@
              CALL logger_fatal('you must have create logger to use logger_fatal')
          ENDIF
+      ELSE
+         PRINT *,"FATAL ERROR :"//TRIM(cd_msg)
+         STOP
       ENDIF
    END SUBROUTINE logger_fatal
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/math.f90
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/math.f90	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/math.f90	(revision 6392)
@@ -1224,4 +1224,6 @@
          
       CASE('K')
+
+         ALLOCATE( dl_value(il_shape(1),il_shape(2),3) )
          ! compute derivative in k-direction
          DO jk=1,il_shape(3)
@@ -1266,7 +1268,7 @@
             ENDIF         
 
-            WHERE( dl_value(:,:, 2) /= dd_fill .AND. & ! jk
-               &   dl_value(:,:, 3) /= dd_fill .AND. & ! jk+1
-               &   dl_value(:,:, 1) /= dd_fill )       ! jk-1
+            WHERE( dl_value(:,:,2) /= dd_fill .AND. & ! jk
+               &   dl_value(:,:,3) /= dd_fill .AND. & ! jk+1
+               &   dl_value(:,:,1) /= dd_fill )       ! jk-1
 
                math_deriv_3D(:,:,jk)=&
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/merge_bathy.f90
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/merge_bathy.f90	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/merge_bathy.f90	(revision 6392)
@@ -9,9 +9,10 @@
 !> @file
 !> @brief 
-!> This program merge bathymetry file at boundaries.
+!> This program merges bathymetry file at boundaries.
 !>
 !> @details
 !> @section sec1 method
-!> Coarse grid Bathymetry is interpolated on fine grid. 
+!> Coarse grid Bathymetry is interpolated on fine grid 
+!> (nearest interpolation method is used).  
 !> Then fine Bathymetry and refined coarse bathymetry are merged at boundaries.<br/>
 !>    @f[BathyFine= Weight * BathyCoarse + (1-Weight)*BathyFine@f]
@@ -31,18 +32,14 @@
 !>    you could find a template of the namelist in templates directory.
 !>
-!>    merge_bathy.nam comprise 8 namelists:
+!>    merge_bathy.nam contains 7 namelists:
 !>       - logger namelist (namlog)
 !>       - config namelist (namcfg)
 !>       - coarse grid namelist (namcrs)
 !>       - fine grid namelist (namfin)
-!>       - variable namelist (namvar)
+!       - variable namelist (namvar)
 !>       - nesting namelist (namnst)
 !>       - boundary namelist (nambdy)
 !>       - output namelist (namout)
 !> 
-!>    @note 
-!>       All namelists have to be in file merge_bathy.nam, 
-!>       however variables of those namelists are all optional.
-!>
 !>    * _logger namelist (namlog)_:
 !>       - cn_logfile   : logger filename
@@ -52,5 +49,8 @@
 !>
 !>    * _config namelist (namcfg)_:
-!>       - cn_varcfg : variable configuration file (see ./SIREN/cfg/variable.cfg)
+!>       - cn_varcfg : variable configuration file 
+!> (see ./SIREN/cfg/variable.cfg)
+!>       - cn_dumcfg : useless (dummy) configuration file, for useless 
+!> dimension or variable (see ./SIREN/cfg/dummy.cfg).
 !>
 !>    * _coarse grid namelist (namcrs)_:
@@ -63,24 +63,24 @@
 !>       - in_perio1 : NEMO periodicity index
 !>
-!>    * _variable namelist (namvar)_:
-!>       - cn_varinfo : list of variable and extra information about request(s) 
-!>       to be used (separated by ',').<br/>
-!>          each elements of *cn_varinfo* is a string character.<br/>
-!>          it is composed of the variable name follow by ':', 
-!>          then request(s) to be used on this variable.<br/> 
-!>          request could be:
-!>             - int = interpolation method
-!> 
-!>                requests must be separated by ';'.<br/>
-!>                order of requests does not matter.<br/>
-!>
-!>          informations about available method could be find in 
-!>          @ref interp modules.<br/>
-!>          Example: 'bathymetry: int=cubic'
-!>          @note 
-!>             If you do not specify a method which is required, 
-!>             default one is apply.
-!>          @warning 
-!>             variable name must be __Bathymetry__ here.
+!    * _variable namelist (namvar)_:
+!       - cn_varinfo : list of variable and extra information about request(s) 
+!       to be used (separated by ',').<br/>
+!          each elements of *cn_varinfo* is a string character.<br/>
+!          it is composed of the variable name follow by ':', 
+!          then request(s) to be used on this variable.<br/> 
+!          request could be:
+!             - int = interpolation method
+! 
+!                requests must be separated by ';'.<br/>
+!                order of requests does not matter.<br/>
+!
+!          informations about available method could be find in 
+!          @ref interp modules.<br/>
+!          Example: 'bathymetry: int=cubic'
+!          @note 
+!             If you do not specify a method which is required, 
+!             default one is apply.
+!          @warning 
+!             variable name must be __Bathymetry__ here.
 !>
 !>    * _nesting namelist (namnst)_:
@@ -128,4 +128,6 @@
 !> - extrapolate all land points
 !> - add attributes with boundary string character (as in namelist)
+!> @date September, 2015
+!> - manage useless (dummy) variable, attributes, and dimension
 !>
 !> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -207,4 +209,5 @@
    ! namcfg
    CHARACTER(LEN=lc)                       :: cn_varcfg = 'variable.cfg' 
+   CHARACTER(LEN=lc)                       :: cn_dumcfg = 'dummy.cfg'
 
    ! namcrs
@@ -216,6 +219,6 @@
    INTEGER(i4)                             :: in_perio1 = -1
 
-   ! namvar
-   CHARACTER(LEN=lc), DIMENSION(ip_maxvar) :: cn_varinfo = ''
+!   ! namvar
+!   CHARACTER(LEN=lc), DIMENSION(ip_maxvar) :: cn_varinfo = ''
 
    ! namnst
@@ -244,5 +247,6 @@
 
    NAMELIST /namcfg/ &  !< config namelist
-   &  cn_varcfg         !< variable configuration file
+   &  cn_varcfg, &       !< variable configuration file
+   &  cn_dumcfg          !< dummy configuration file
 
    NAMELIST /namcrs/ &  !< coarse grid namelist
@@ -254,8 +258,8 @@
    &  in_perio1         !< periodicity index
  
-   NAMELIST /namvar/ &  !< variable namelist
-   &  cn_varinfo        !< list of variable and interpolation 
-                        !< method to be used. 
-                        !< (ex: 'votemper|linear','vosaline|cubic' ) 
+!   NAMELIST /namvar/ &  !< variable namelist
+!   &  cn_varinfo        !< list of variable and interpolation 
+!                        !< method to be used. 
+!                        !< (ex: 'votemper|linear','vosaline|cubic' ) 
    
    NAMELIST /namnst/ &  !< nesting namelist
@@ -315,9 +319,16 @@
       CALL var_def_extra(TRIM(cn_varcfg))
 
+      ! get dummy variable
+      CALL var_get_dummy(TRIM(cn_dumcfg))
+      ! get dummy dimension
+      CALL dim_get_dummy(TRIM(cn_dumcfg))
+      ! get dummy attribute
+      CALL att_get_dummy(TRIM(cn_dumcfg))
+
       READ( il_fileid, NML = namcrs )
       READ( il_fileid, NML = namfin )
-      READ( il_fileid, NML = namvar )
-      ! add user change in extra information
-      CALL var_chg_extra(cn_varinfo)
+!      READ( il_fileid, NML = namvar )
+!      ! add user change in extra information
+!      CALL var_chg_extra(cn_varinfo)
 
       READ( il_fileid, NML = namnst )
@@ -630,4 +641,6 @@
    !> @param[inout] dd_weight    array of weight
    !> @param[in] dd_fill         fillValue
+   !>
+   !> @todo improve boundary weight function
    !-------------------------------------------------------------------
    SUBROUTINE merge_bathy_get_boundary( td_bathy0, td_bathy1, td_bdy, &
@@ -690,4 +703,8 @@
                il_jmax1=td_bdy%t_seg(jl)%i_index
 
+               ! do not used grid point to compute 
+               ! boundaries indices (cf create_boundary)
+               ! as Bathymetry always on T point
+
             CASE('south')
 
@@ -703,4 +720,8 @@
                il_jmin1=td_bdy%t_seg(jl)%i_first
                il_jmax1=td_bdy%t_seg(jl)%i_last 
+
+               ! do not used grid point to compute 
+               ! boundaries indices (cf create_boundary)
+               ! as Bathymetry always on T point
 
             CASE('west')
@@ -777,4 +798,7 @@
             tl_var0=iom_dom_read_var(tl_bathy0,'Bathymetry',tl_dom0)
 
+            ! force to use nearest interpolation
+            tl_var0%c_interp(1)='nearest'
+
             ! close mpp files
             CALL iom_dom_close(tl_bathy0)
@@ -814,6 +838,14 @@
             CASE('north')
 
+!               ! npoint coarse
+!               il_width=td_bdy%t_seg(jl)%i_width-id_npoint
+!               ! compute "distance"
+!               dl_tmp1d(:)=(/(ji,ji=il_width-1,1,-1),(0,ji=1,id_npoint)/)
+!               ! compute weight on segment
+!               dl_tmp1d(:)= 0.5 + 0.5*COS( (dp_pi*dl_tmp1d(:)) / &
+!               &                           (il_width) )
+
                ! compute "distance"
-               dl_tmp1d(:)=(/(ji-1,ji=td_bdy%t_seg(jl)%i_width,1,-1)/)
+               dl_tmp1d(:)=(/(ji-1,ji=td_bdy%t_seg(jl)%i_width-1,1,-1),0/)
 
                ! compute weight on segment
@@ -831,5 +863,5 @@
 
                ! compute "distance"
-               dl_tmp1d(:)=(/(ji-1,ji=1,td_bdy%t_seg(jl)%i_width)/)               
+               dl_tmp1d(:)=(/0,(ji-1,ji=1,td_bdy%t_seg(jl)%i_width-1)/)               
 
                ! compute weight on segment
@@ -847,5 +879,5 @@
 
                ! compute "distance"
-               dl_tmp1d(:)=(/(ji-1,ji=td_bdy%t_seg(jl)%i_width,1,-1)/)
+               dl_tmp1d(:)=(/(ji-1,ji=td_bdy%t_seg(jl)%i_width-1,1,-1),0/)
 
                ! compute weight on segment
@@ -863,5 +895,5 @@
 
                ! compute "distance"
-               dl_tmp1d(:)=(/(ji-1,ji=1,td_bdy%t_seg(jl)%i_width)/)               
+               dl_tmp1d(:)=(/0,(ji-1,ji=1,td_bdy%t_seg(jl)%i_width-1)/)               
 
                ! compute weight on segment
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/mpp.f90
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/mpp.f90	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/mpp.f90	(revision 6392)
@@ -196,5 +196,11 @@
 ! REVISION HISTORY:
 !> @date November, 2013 - Initial Version
-!> @date November, 2014 - Fix memory leaks bug
+!> @date November, 2014 
+!> - Fix memory leaks bug
+!> @date October, 2015
+!> - improve way to compute domain layout
+!> @date January, 2016
+!> - allow to print layout file (use lm_layout, hard coded)
+!> - add mpp__compute_halo and mpp__read_halo
 !
 !> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -214,5 +220,6 @@
 
    ! type and variable
-   PUBLIC :: TMPP       !< mpp structure
+   PUBLIC  :: TMPP       !< mpp structure
+   PRIVATE :: TLAY       !< domain layout structure
 
    ! function and subroutine
@@ -239,13 +246,12 @@
    PUBLIC :: mpp_get_proc_size  !< get processor domain size
 
-   PRIVATE :: mpp__add_proc            ! add one proc strucutre in mpp structure
+   PRIVATE :: mpp__add_proc            ! add proc strucutre in mpp structure
+   PRIVATE :: mpp__add_proc_unit       ! 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__create_layout       ! create mpp structure using domain layout
    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
@@ -267,7 +273,12 @@
    PRIVATE :: mpp__clean_unit          ! clean mpp strcuture
    PRIVATE :: mpp__clean_arr           ! clean array of mpp strcuture
+   PRIVATE :: mpp__compute_halo        ! compute subdomain indices defined with halo 
+   PRIVATE :: mpp__read_halo           ! read subdomain indices defined with halo
+
+   PRIVATE :: layout__init             ! initialise domain layout structure
+   PRIVATE :: layout__copy             ! clean domain layout structure
+   PRIVATE :: layout__clean            ! copy  domain layout structure
 
    TYPE TMPP !< mpp structure
-
       ! general 
       CHARACTER(LEN=lc)                  :: c_name = ''   !< base name 
@@ -284,5 +295,5 @@
 
       CHARACTER(LEN=lc)                  :: c_type = ''   !< type of the files (cdf, cdf4, dimg)
-      CHARACTER(LEN=lc)                  :: c_dom  = ''   !< type of domain (full, overlap, nooverlap)
+      CHARACTER(LEN=lc)                  :: c_dom  = ''   !< type of domain (full, noextra, nooverlap)
 
       INTEGER(i4)                        :: i_ndim = 0    !< number of dimensions used in mpp
@@ -290,10 +301,32 @@
 
       TYPE(TFILE), DIMENSION(:), POINTER :: t_proc => NULL()     !< files/processors composing mpp
-
    END TYPE
+
+   TYPE TLAY !< domain layout structure
+      INTEGER(i4)                          :: i_niproc = 0  !< number of processors following i
+      INTEGER(i4)                          :: i_njproc = 0  !< number of processors following j
+      INTEGER(i4)                          :: i_nland  = 0       !< number of land processors
+      INTEGER(i4)                          :: i_nsea   = 0       !< number of sea  processors
+      INTEGER(i4)                          :: i_mean   = 0       !< mean sea point per proc
+      INTEGER(i4)                          :: i_min    = 0       !< min  sea point per proc
+      INTEGER(i4)                          :: i_max    = 0       !< max  sea point per proc
+      INTEGER(i4), DIMENSION(:,:), POINTER :: i_msk   => NULL()  !< sea/land processor mask 
+      INTEGER(i4), DIMENSION(:,:), POINTER :: i_impp  => NULL()  !< i-indexes for mpp-subdomain left bottom 
+      INTEGER(i4), DIMENSION(:,:), POINTER :: i_jmpp  => NULL()  !< j-indexes for mpp-subdomain left bottom 
+      INTEGER(i4), DIMENSION(:,:), POINTER :: i_lci   => NULL()  !< i-dimensions of subdomain 
+      INTEGER(i4), DIMENSION(:,:), POINTER :: i_lcj   => NULL()  !< j-dimensions of subdomain 
+   END TYPE
+
+   ! module variable
+   INTEGER(i4) :: im_iumout = 44
+   LOGICAL     :: lm_layout =.FALSE.
 
    INTERFACE mpp_get_use
       MODULE PROCEDURE mpp__get_use_unit 
    END INTERFACE mpp_get_use
+
+   INTERFACE mpp__add_proc
+      MODULE PROCEDURE mpp__add_proc_unit 
+   END INTERFACE mpp__add_proc
 
    INTERFACE mpp_clean
@@ -560,9 +593,12 @@
             ALLOCATE( il_lci(td_mpp%i_niproc,td_mpp%i_njproc) )
             ALLOCATE( il_lcj(td_mpp%i_niproc,td_mpp%i_njproc) )
+            il_proc(:,:)=-1
+            il_lci(:,:) =-1
+            il_lcj(:,:) =-1
 
             DO jk=1,td_mpp%i_nproc
                ji=td_mpp%t_proc(jk)%i_iind
                jj=td_mpp%t_proc(jk)%i_jind
-               il_proc(ji,jj)=jk
+               il_proc(ji,jj)=jk-1
                il_lci(ji,jj)=td_mpp%t_proc(jk)%i_lci
                il_lcj(ji,jj)=td_mpp%t_proc(jk)%i_lcj
@@ -594,5 +630,4 @@
       ENDIF
 
-
 9400   FORMAT('     ***',20('*************',a3))
 9403   FORMAT('     *     ',20('         *   ',a3))
@@ -615,4 +650,9 @@
    !> @author J.Paul
    !> @date November, 2013 - Initial version
+   !> @date September, 2015
+   !> - allow to define dimension with array of dimension structure
+   !> @date January, 2016
+   !> - use RESULT to rename output
+   !> - mismatch with "halo" indices
    !
    !> @param[in] cd_file   file name of one file composing mpp domain
@@ -627,32 +667,42 @@
    !> @param[in] id_perio  NEMO periodicity index
    !> @param[in] id_pivot  NEMO pivot point index F(0),T(1)
+   !> @param[in] td_dim    array of dimension structure
    !> @return mpp structure
    !-------------------------------------------------------------------
-   TYPE(TMPP) FUNCTION mpp__init_mask(cd_file, id_mask,              &
-   &                                  id_niproc, id_njproc, id_nproc,&
-   &                                  id_preci, id_precj,            &
-                                      cd_type, id_ew, id_perio, id_pivot)
+   FUNCTION mpp__init_mask(cd_file, id_mask,                   &
+   &                       id_niproc, id_njproc, id_nproc,     &
+   &                       id_preci, id_precj,                 &
+   &                       cd_type, id_ew, id_perio, id_pivot, &
+   &                       td_dim )                            &
+   & RESULT(td_mpp)
       IMPLICIT NONE
       ! Argument
-      CHARACTER(LEN=*),            INTENT(IN) :: cd_file
-      INTEGER(i4), DIMENSION(:,:), INTENT(IN) :: id_mask
-      INTEGER(i4),                 INTENT(IN), OPTIONAL :: id_niproc
-      INTEGER(i4),                 INTENT(IN), OPTIONAL :: id_njproc
-      INTEGER(i4),                 INTENT(IN), OPTIONAL :: id_nproc
-      INTEGER(i4),                 INTENT(IN), OPTIONAL :: id_preci
-      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
+      CHARACTER(LEN=*),                  INTENT(IN) :: cd_file
+      INTEGER(i4), DIMENSION(:,:),       INTENT(IN) :: id_mask
+      INTEGER(i4),                       INTENT(IN), OPTIONAL :: id_niproc
+      INTEGER(i4),                       INTENT(IN), OPTIONAL :: id_njproc
+      INTEGER(i4),                       INTENT(IN), OPTIONAL :: id_nproc
+      INTEGER(i4),                       INTENT(IN), OPTIONAL :: id_preci
+      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
+      TYPE(TDIM) , DIMENSION(ip_maxdim), INTENT(IN), OPTIONAL :: td_dim
+
+      ! function
+      TYPE(TMPP) :: td_mpp
 
       ! local variable
-      CHARACTER(LEN=lc)                :: cl_type
-
-      INTEGER(i4)      , DIMENSION(2) :: il_shape
-
-      TYPE(TDIM)                      :: tl_dim
-
-      TYPE(TATT)                      :: tl_att
+      CHARACTER(LEN=lc)                            :: cl_type
+
+      INTEGER(i4)      , DIMENSION(2)              :: il_shape
+
+      TYPE(TDIM)                                   :: tl_dim
+
+      TYPE(TATT)                                   :: tl_att
+
+      TYPE(TLAY)                                   :: tl_lay
+
       ! loop indices
       INTEGER(i4) :: ji
@@ -660,5 +710,5 @@
 
       ! clean mpp
-      CALL mpp_clean(mpp__init_mask)
+      CALL mpp_clean(td_mpp)
 
       ! check type
@@ -669,31 +719,39 @@
          SELECT CASE(TRIM(cd_type))
             CASE('cdf')
-               mpp__init_mask%c_type='cdf'
+               td_mpp%c_type='cdf'
             CASE('dimg')
-               mpp__init_mask%c_type='dimg'
+               td_mpp%c_type='dimg'
             CASE DEFAULT
                CALL logger_warn( "MPP INIT: type "//TRIM(cd_type)//&
                & " unknown. type dimg will be used for mpp "//&
-               &  TRIM(mpp__init_mask%c_name) )
-               mpp__init_mask%c_type='dimg'
+               &  TRIM(td_mpp%c_name) )
+               td_mpp%c_type='dimg'
          END SELECT
       ELSE
-         mpp__init_mask%c_type=TRIM(file_get_type(cd_file))
+         td_mpp%c_type=TRIM(file_get_type(cd_file))
       ENDIF
 
       ! get mpp name
-      mpp__init_mask%c_name=TRIM(file_rename(cd_file))
+      td_mpp%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(td_dim) )THEN
+         DO ji=1,ip_maxdim
+            IF( td_dim(ji)%l_use )THEN
+               CALL mpp_add_dim(td_mpp, td_dim(ji))
+            ENDIF
+         ENDDO
+      ELSE
+         tl_dim=dim_init('X',il_shape(1))
+         CALL mpp_add_dim(td_mpp, tl_dim)
+
+         tl_dim=dim_init('Y',il_shape(2))
+         CALL mpp_add_dim(td_mpp, tl_dim)
+
+         ! clean
+         CALL dim_clean(tl_dim)
+      ENDIF
 
       IF( (       PRESENT(id_niproc)  .AND. (.NOT. PRESENT(id_njproc))) .OR. &
@@ -703,125 +761,114 @@
       ELSE
          ! get number of processors following I and J
-         IF( PRESENT(id_niproc) ) mpp__init_mask%i_niproc=id_niproc
-         IF( PRESENT(id_njproc) ) mpp__init_mask%i_njproc=id_njproc
+         IF( PRESENT(id_niproc) ) td_mpp%i_niproc=id_niproc
+         IF( PRESENT(id_njproc) ) td_mpp%i_njproc=id_njproc
       ENDIF
 
       ! get maximum number of processors to be used
-      IF( PRESENT(id_nproc) ) mpp__init_mask%i_nproc = id_nproc
+      IF( PRESENT(id_nproc) ) td_mpp%i_nproc = id_nproc
 
       ! get overlap region length
-      IF( PRESENT(id_preci) ) mpp__init_mask%i_preci= id_preci
-      IF( PRESENT(id_precj) ) mpp__init_mask%i_precj= id_precj
+      IF( PRESENT(id_preci) ) td_mpp%i_preci= id_preci
+      IF( PRESENT(id_precj) ) td_mpp%i_precj= id_precj
 
       ! east-west overlap
-      IF( PRESENT(id_ew) ) mpp__init_mask%i_ew= id_ew
+      IF( PRESENT(id_ew) ) td_mpp%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. &
-      &   mpp__init_mask%i_njproc /= 0 .AND. &
-      &   mpp__init_mask%i_nproc > &
-      &   mpp__init_mask%i_niproc * mpp__init_mask%i_njproc )THEN
+      IF( PRESENT(id_perio) ) td_mpp%i_perio= id_perio
+      IF( PRESENT(id_pivot) ) td_mpp%i_pivot= id_pivot
+
+      IF( td_mpp%i_nproc  /= 0 .AND. &
+      &   td_mpp%i_niproc /= 0 .AND. &
+      &   td_mpp%i_njproc /= 0 .AND. &
+      &   td_mpp%i_nproc > &
+      &   td_mpp%i_niproc * td_mpp%i_njproc )THEN
 
          CALL logger_error("MPP INIT: invalid domain decomposition ")
          CALL logger_debug("MPP INIT: "// &
-         & TRIM(fct_str(mpp__init_mask%i_nproc))//" > "//&
-         & TRIM(fct_str(mpp__init_mask%i_niproc))//" x "//&
-         & TRIM(fct_str(mpp__init_mask%i_njproc)) )
+         & TRIM(fct_str(td_mpp%i_nproc))//" > "//&
+         & TRIM(fct_str(td_mpp%i_niproc))//" x "//&
+         & TRIM(fct_str(td_mpp%i_njproc)) )
 
       ELSE
-
-         IF( mpp__init_mask%i_niproc /= 0 .AND. &
-         &   mpp__init_mask%i_njproc /= 0 )THEN
-            ! compute domain decomposition
-            CALL mpp__compute( mpp__init_mask )
-            ! remove land sub domain
-            CALL mpp__del_land( mpp__init_mask, id_mask )
-         ELSEIF( mpp__init_mask%i_nproc  /= 0 )THEN
+         IF( lm_layout )THEN
+            OPEN(im_iumout,FILE='processor.layout')
+            WRITE(im_iumout,*)
+            WRITE(im_iumout,*) ' optimisation de la partition'
+            WRITE(im_iumout,*) ' ----------------------------'
+            WRITE(im_iumout,*)
+         ENDIF
+
+         IF( td_mpp%i_niproc /= 0 .AND. &
+         &   td_mpp%i_njproc /= 0 )THEN
+            ! compute domain layout
+            tl_lay=layout__init( td_mpp, id_mask, td_mpp%i_niproc, td_mpp%i_njproc )
+            ! create mpp domain layout
+            CALL mpp__create_layout( td_mpp, tl_lay )
+            ! clean
+            CALL layout__clean( tl_lay )
+         ELSEIF( td_mpp%i_nproc  /= 0 )THEN
             ! optimiz
-            CALL mpp__optimiz( mpp__init_mask, id_mask )
+            CALL mpp__optimiz( td_mpp, id_mask, td_mpp%i_nproc )
 
          ELSE
             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 )
+            CALL mpp__optimiz( td_mpp, id_mask, 1 )
          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))//')' )
+         &  'niproc('//TRIM(fct_str(td_mpp%i_niproc))//') * '//&
+         &  'njproc('//TRIM(fct_str(td_mpp%i_njproc))//') = '//&
+         &  'nproc('//TRIM(fct_str(td_mpp%i_nproc))//')' )
 
          ! get domain type
-         CALL mpp_get_dom( mpp__init_mask )
-
-         DO ji=1,mpp__init_mask%i_nproc
+         CALL mpp_get_dom( td_mpp )
+
+         DO ji=1,td_mpp%i_nproc
 
             ! get processor size
-            il_shape(:)=mpp_get_proc_size( mpp__init_mask, ji )
+            il_shape(:)=mpp_get_proc_size( td_mpp, ji )
 
             tl_dim=dim_init('X',il_shape(1))
-            CALL file_move_dim(mpp__init_mask%t_proc(ji), tl_dim)
+            CALL file_move_dim(td_mpp%t_proc(ji), tl_dim)
 
             tl_dim=dim_init('Y',il_shape(2))
-            CALL file_move_dim(mpp__init_mask%t_proc(ji), tl_dim)            
-
+            CALL file_move_dim(td_mpp%t_proc(ji), tl_dim)            
+
+            IF( PRESENT(td_dim) )THEN
+               IF( td_dim(jp_K)%l_use )THEN
+                  CALL file_move_dim(td_mpp%t_proc(ji), td_dim(jp_K))
+               ENDIF
+               IF( td_dim(jp_L)%l_use )THEN
+                  CALL file_move_dim(td_mpp%t_proc(ji), td_dim(jp_L))
+               ENDIF
+            ENDIF
             ! add type
-            mpp__init_mask%t_proc(ji)%c_type=TRIM(mpp__init_mask%c_type)
+            td_mpp%t_proc(ji)%c_type=TRIM(td_mpp%c_type)
 
             ! clean
             CALL dim_clean(tl_dim)
+
          ENDDO
 
          ! add global attribute
-         tl_att=att_init("DOMAIN_number_total",mpp__init_mask%i_nproc)
-         CALL mpp_add_att(mpp__init_mask, tl_att)
-
-         tl_att=att_init("DOMAIN_I_number_total",mpp__init_mask%i_niproc)
-         CALL mpp_add_att(mpp__init_mask, tl_att)
-
-         tl_att=att_init("DOMAIN_J_number_total",mpp__init_mask%i_njproc)
-         CALL mpp_add_att(mpp__init_mask, tl_att)
-
-         tl_att=att_init("DOMAIN_size_global",mpp__init_mask%t_dim(1:2)%i_len)
-         CALL mpp_add_att(mpp__init_mask, tl_att)
-
-         tl_att=att_init( "DOMAIN_I_position_first", &
-         &                mpp__init_mask%t_proc(:)%i_impp )
-         CALL mpp_add_att(mpp__init_mask, tl_att)
-
-         tl_att=att_init( "DOMAIN_J_position_first", &
-         &                mpp__init_mask%t_proc(:)%i_jmpp )
-         CALL mpp_add_att(mpp__init_mask, tl_att)
-
-         tl_att=att_init( "DOMAIN_I_position_last", &
-         &                mpp__init_mask%t_proc(:)%i_lci )
-         CALL mpp_add_att(mpp__init_mask, tl_att)
-
-         tl_att=att_init( "DOMAIN_J_position_last", &
-         &                mpp__init_mask%t_proc(:)%i_lcj )
-         CALL mpp_add_att(mpp__init_mask, tl_att)
-
-         tl_att=att_init( "DOMAIN_I_halo_size_start", &
-         &                mpp__init_mask%t_proc(:)%i_ldi )
-         CALL mpp_add_att(mpp__init_mask, tl_att)
-
-         tl_att=att_init( "DOMAIN_J_halo_size_start", &
-         &                mpp__init_mask%t_proc(:)%i_ldj )
-         CALL mpp_add_att(mpp__init_mask, tl_att)
-
-         tl_att=att_init( "DOMAIN_I_halo_size_end", &
-         &                mpp__init_mask%t_proc(:)%i_lei )
-         CALL mpp_add_att(mpp__init_mask, tl_att)
-
-         tl_att=att_init( "DOMAIN_J_halo_size_end", &
-         &                mpp__init_mask%t_proc(:)%i_lej )
-         CALL mpp_add_att(mpp__init_mask, tl_att)         
-
-         ! clean
-         CALL att_clean(tl_att)
+         tl_att=att_init("DOMAIN_number_total",td_mpp%i_nproc)
+         CALL mpp_add_att(td_mpp, tl_att)
+
+         tl_att=att_init("DOMAIN_LOCAL",TRIM(td_mpp%c_dom))
+         CALL mpp_add_att(td_mpp, tl_att)
+
+         tl_att=att_init("DOMAIN_I_number_total",td_mpp%i_niproc)
+         CALL mpp_add_att(td_mpp, tl_att)
+
+         tl_att=att_init("DOMAIN_J_number_total",td_mpp%i_njproc)
+         CALL mpp_add_att(td_mpp, tl_att)
+
+         tl_att=att_init("DOMAIN_size_global",td_mpp%t_dim(1:2)%i_len)
+         CALL mpp_add_att(td_mpp, tl_att)
+
+         CALL mpp__compute_halo(td_mpp) 
       ENDIF
 
@@ -880,4 +927,6 @@
          il_mask(:,:,:)=var_get_mask(td_var)
          
+         CALL logger_info("MPP INIT: mask compute from variable "//&
+            &             TRIM(td_var%c_name))
          mpp__init_var=mpp_init( cd_file, il_mask(:,:,1),       &
          &                       id_niproc, id_njproc, id_nproc,&
@@ -907,9 +956,9 @@
    !>    - DOMAIN_halo_size_end
    !>  or the file is assume to be no mpp file.
-   !>  
-   !> 
    !>
    !> @author J.Paul
    !> @date November, 2013 - Initial Version
+   !> @date January, 2016
+   !> - mismatch with "halo" indices, use mpp__compute_halo
    !
    !> @param[in] td_file   file strcuture
@@ -929,16 +978,16 @@
 
       ! 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
-
+      INTEGER(i4)               :: il_nproc
+      INTEGER(i4)               :: il_attid
       INTEGER(i4), DIMENSION(2) :: il_shape
+
+      TYPE(TDIM)                :: tl_dim
+
+      TYPE(TATT)                :: tl_att
+
+      TYPE(TFILE)               :: tl_file
+
+      TYPE(TMPP)                :: tl_mpp
+
       ! loop indices
       INTEGER(i4) :: ji
@@ -956,5 +1005,4 @@
             ! open file
             CALL iom_open(tl_file)
-
             ! read first file domain decomposition
             tl_mpp=mpp__init_file_cdf(tl_file)
@@ -1029,28 +1077,6 @@
             CALL mpp_move_att(mpp__init_file, tl_att)
 
-            tl_att=att_init( "DOMAIN_I_position_first", mpp__init_file%t_proc(:)%i_impp )
-            CALL mpp_move_att(mpp__init_file, tl_att)
-
-            tl_att=att_init( "DOMAIN_J_position_first", mpp__init_file%t_proc(:)%i_jmpp )
-            CALL mpp_move_att(mpp__init_file, tl_att)
-
-            tl_att=att_init( "DOMAIN_I_position_last", mpp__init_file%t_proc(:)%i_lci )
-            CALL mpp_move_att(mpp__init_file, tl_att)
-
-            tl_att=att_init( "DOMAIN_J_position_last", mpp__init_file%t_proc(:)%i_lcj )
-            CALL mpp_move_att(mpp__init_file, tl_att)
-
-            tl_att=att_init( "DOMAIN_I_halo_size_start", mpp__init_file%t_proc(:)%i_ldi )
-            CALL mpp_move_att(mpp__init_file, tl_att)
-
-            tl_att=att_init( "DOMAIN_J_halo_size_start", mpp__init_file%t_proc(:)%i_ldj )
-            CALL mpp_move_att(mpp__init_file, tl_att)
-
-            tl_att=att_init( "DOMAIN_I_halo_size_end", mpp__init_file%t_proc(:)%i_lei )
-            CALL mpp_move_att(mpp__init_file, tl_att)
-
-            tl_att=att_init( "DOMAIN_J_halo_size_end", mpp__init_file%t_proc(:)%i_lej )
-            CALL mpp_move_att(mpp__init_file, tl_att)
-            
+            CALL mpp__compute_halo(mpp__init_file)
+ 
             ! clean
             CALL mpp_clean(tl_mpp)
@@ -1130,5 +1156,8 @@
    !> @author J.Paul
    !> @date November, 2013 - Initial Version
-   !> @date July, 2015 - add only use dimension in MPP structure
+   !> @date July, 2015 
+   !> - add only use dimension in MPP structure
+   !> @date January, 2016
+   !> - mismatch with "halo" indices, use mpp__read_halo
    !>
    !> @param[in] td_file   file strcuture
@@ -1218,55 +1247,5 @@
             tl_proc%t_dim(:)=dim_copy(td_file%t_dim(:))
 
-            ! DOMAIN_position_first
-            il_attid = 0
-            IF( ASSOCIATED(td_file%t_att) )THEN
-               il_attid=att_get_id( td_file%t_att, "DOMAIN_position_first" )
-            ENDIF
-            IF( il_attid /= 0 )THEN
-               tl_proc%i_impp = INT(td_file%t_att(il_attid)%d_value(1))
-               tl_proc%i_jmpp = INT(td_file%t_att(il_attid)%d_value(2))
-            ELSE
-               tl_proc%i_impp = 1
-               tl_proc%i_jmpp = 1
-            ENDIF
-
-            ! DOMAIN_position_last
-            il_attid = 0
-            IF( ASSOCIATED(td_file%t_att) )THEN
-               il_attid=att_get_id( td_file%t_att, "DOMAIN_position_last" )
-            ENDIF
-            IF( il_attid /= 0 )THEN
-               tl_proc%i_lci = INT(td_file%t_att(il_attid)%d_value(1)) + tl_proc%i_impp
-               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_file_cdf%t_dim(1)%i_len
-               tl_proc%i_lcj = mpp__init_file_cdf%t_dim(2)%i_len
-            ENDIF
-
-            ! DOMAIN_halo_size_start
-            il_attid = 0
-            IF( ASSOCIATED(td_file%t_att) )THEN
-               il_attid=att_get_id( td_file%t_att, "DOMAIN_halo_size_start" )
-            ENDIF
-            IF( il_attid /= 0 )THEN
-               tl_proc%i_ldi = INT(td_file%t_att(il_attid)%d_value(1))
-               tl_proc%i_ldj = INT(td_file%t_att(il_attid)%d_value(2))
-            ELSE
-               tl_proc%i_ldi = 1
-               tl_proc%i_ldj = 1
-            ENDIF
-
-            ! DOMAIN_halo_size_end
-            il_attid = 0
-            IF( ASSOCIATED(td_file%t_att) )THEN
-               il_attid=att_get_id( td_file%t_att, "DOMAIN_halo_size_end" )
-            ENDIF
-            IF( il_attid /= 0 )THEN
-               tl_proc%i_lei = INT(td_file%t_att(il_attid)%d_value(1))
-               tl_proc%i_lej = INT(td_file%t_att(il_attid)%d_value(2))
-            ELSE
-               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
+            CALL mpp__read_halo(tl_proc, mpp__init_file_cdf%t_dim(:) )
 
             ! add attributes
@@ -1278,20 +1257,4 @@
             CALL file_move_att(tl_proc, tl_att)
 
-            tl_att=att_init( "DOMAIN_position_first", &
-            &                (/tl_proc%i_impp, tl_proc%i_jmpp /) )
-            CALL file_move_att(tl_proc, tl_att)
-
-            tl_att=att_init( "DOMAIN_position_last", &
-            &                (/tl_proc%i_lci, tl_proc%i_lcj /) )
-            CALL file_move_att(tl_proc, tl_att)
-
-            tl_att=att_init( "DOMAIN_halo_size_start", &
-            &                (/tl_proc%i_ldi, tl_proc%i_ldj /) )
-            CALL file_move_att(tl_proc, tl_att)
-
-            tl_att=att_init( "DOMAIN_halo_size_end", &
-            &                (/tl_proc%i_lei, tl_proc%i_lej /) )
-            CALL file_move_att(tl_proc, tl_att)
-
             ! add processor to mpp structure
             CALL mpp__add_proc(mpp__init_file_cdf, tl_proc)
@@ -1299,4 +1262,5 @@
             ! clean 
             CALL file_clean(tl_proc)
+            CALL dim_clean(tl_dim)
             CALL att_clean(tl_att)
          ENDIF
@@ -1307,5 +1271,6 @@
          &  " do not exist")
 
-      ENDIF      
+      ENDIF
+
    END FUNCTION mpp__init_file_cdf
    !-------------------------------------------------------------------
@@ -1317,5 +1282,7 @@
    !> @author J.Paul
    !> @date November, 2013 - Initial Version
-   !
+   !> @date January, 2016
+   !> - mismatch with "halo" indices, use mpp__compute_halo
+   !>
    !> @param[in] td_file   file strcuture
    !> @return mpp structure
@@ -1336,4 +1303,13 @@
       INTEGER(i4)       :: il_pni, il_pnj, il_pnij          ! domain decomposition
       INTEGER(i4)       :: il_area                          ! domain index
+
+      INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_lci
+      INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_ldi
+      INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_lei
+      INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_impp
+      INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_lcj
+      INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_ldj
+      INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_lej
+      INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_jmpp
 
       LOGICAL           ::  ll_exist
@@ -1389,4 +1365,13 @@
             ALLOCATE( mpp__init_file_rstdimg%t_proc(il_pnij) , stat=il_status )
 
+            ALLOCATE(il_lci (il_pnij))
+            ALLOCATE(il_lcj (il_pnij))
+            ALLOCATE(il_ldi (il_pnij))
+            ALLOCATE(il_ldj (il_pnij))
+            ALLOCATE(il_lei (il_pnij))
+            ALLOCATE(il_lej (il_pnij))
+            ALLOCATE(il_impp(il_pnij))
+            ALLOCATE(il_jmpp(il_pnij))
+
             tl_proc=file_copy(td_file)
             ! remove dimension from file
@@ -1411,12 +1396,12 @@
             &     il_area,                         &
             &     il_iglo, il_jglo,                &
-            &     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
+            &     il_lci(1:il_pnij),    &
+            &     il_lcj(1:il_pnij),    &
+            &     il_ldi(1:il_pnij),    &
+            &     il_ldj(1:il_pnij),    &
+            &     il_lei(1:il_pnij),    &
+            &     il_lej(1:il_pnij),    &
+            &     il_impp(1:il_pnij),   &
+            &     il_jmpp(1:il_pnij)
             CALL fct_err(il_status)
             IF( il_status /= 0 )THEN
@@ -1424,4 +1409,22 @@
                &              TRIM(td_file%c_name))
             ENDIF
+
+            mpp__init_file_rstdimg%t_proc(1:il_pnij)%i_lci = il_lci (1:il_pnij)
+            mpp__init_file_rstdimg%t_proc(1:il_pnij)%i_lcj = il_lcj (1:il_pnij) 
+            mpp__init_file_rstdimg%t_proc(1:il_pnij)%i_ldi = il_ldi (1:il_pnij) 
+            mpp__init_file_rstdimg%t_proc(1:il_pnij)%i_ldj = il_ldj (1:il_pnij) 
+            mpp__init_file_rstdimg%t_proc(1:il_pnij)%i_lei = il_lei (1:il_pnij) 
+            mpp__init_file_rstdimg%t_proc(1:il_pnij)%i_lej = il_lej (1:il_pnij) 
+            mpp__init_file_rstdimg%t_proc(1:il_pnij)%i_impp= il_impp(1:il_pnij)
+            mpp__init_file_rstdimg%t_proc(1:il_pnij)%i_jmpp= il_jmpp(1:il_pnij)
+
+            DEALLOCATE(il_lci) 
+            DEALLOCATE(il_lcj) 
+            DEALLOCATE(il_ldi) 
+            DEALLOCATE(il_ldj) 
+            DEALLOCATE(il_lei) 
+            DEALLOCATE(il_lej) 
+            DEALLOCATE(il_impp)
+            DEALLOCATE(il_jmpp)
 
             ! global domain size
@@ -1435,4 +1438,5 @@
 
             DO ji=1,mpp__init_file_rstdimg%i_nproc
+
                ! get file name
                cl_file =  file_rename(td_file%c_name,ji)
@@ -1445,23 +1449,4 @@
                CALL file_move_att(mpp__init_file_rstdimg%t_proc(ji), tl_att) 
 
-               tl_att=att_init( "DOMAIN_position_first", &
-               &                (/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_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_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_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
  
@@ -1486,35 +1471,7 @@
             CALL mpp_move_att(mpp__init_file_rstdimg, tl_att)
 
-            tl_att=att_init( "DOMAIN_I_position_first", &
-            &                 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_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_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_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_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_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_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_file_rstdimg%t_proc(:)%i_lej )
-            CALL mpp_move_att(mpp__init_file_rstdimg, tl_att)
+            CALL mpp_get_dom( mpp__init_file_rstdimg )
+
+            CALL mpp__compute_halo( mpp__init_file_rstdimg )
 
             ! clean
@@ -1598,5 +1555,5 @@
       ! Argument
       TYPE(TMPP), INTENT(INOUT) :: td_mpp
-      TYPE(TVAR), INTENT(IN)    :: td_var
+      TYPE(TVAR), INTENT(INOUT) :: td_var
 
       ! local variable
@@ -1646,4 +1603,7 @@
                ! check used dimension 
                IF( mpp__check_dim(td_mpp, td_var) )THEN
+         
+                  ! check variable dimension expected
+                  CALL var_check_dim(td_var)
 
                   ! update dimension if need be
@@ -1915,5 +1875,5 @@
       TYPE(TVAR) :: tl_var
       !----------------------------------------------------------------
-      ! copy variable
+      ! copy variablie
       tl_var=var_copy(td_var)
 
@@ -1942,5 +1902,5 @@
    !> - check proc type
    !-------------------------------------------------------------------
-   SUBROUTINE mpp__add_proc( td_mpp, td_proc )
+   SUBROUTINE mpp__add_proc_unit( td_mpp, td_proc )
       IMPLICIT NONE
       ! Argument
@@ -1957,4 +1917,12 @@
       CHARACTER(LEN=lc)                            :: cl_name
       !----------------------------------------------------------------
+
+!      ALLOCATE(tl_proc(1))
+!      tl_proc(1)=file_copy(td_proc)
+!
+!      CALL mpp__add_proc(td_mpp, tl_proc(:))
+!
+!      CALL file_clean(tl_proc(:))
+!      DEALLOCATE(tl_proc)
 
       ! check file name
@@ -2056,5 +2024,6 @@
 
       ENDIF
-   END SUBROUTINE mpp__add_proc
+
+   END SUBROUTINE mpp__add_proc_unit
    !-------------------------------------------------------------------
    !> @brief
@@ -2575,33 +2544,352 @@
    !-------------------------------------------------------------------
    !> @brief
-   !>    This subroutine compute domain decomposition for niproc and njproc 
-   !> processors following I and J.
-   !>
+   !>    This function initialise domain layout
+   !> 
    !> @detail
-   !> To do so, it need to know :
-   !> - global domain dimension
-   !> - overlap region length
-   !> - number of processors following I and J
+   !> Domain layout is first compute, with domain dimension, overlap between subdomain,
+   !> and the number of processors following I and J.
+   !> Then the number of sea/land processors is compute with mask
    !
    !> @author J.Paul
-   !> @date November, 2013 - Initial version
+   !> @date October, 2015 - Initial version
+   !
+   !> @param[in] td_mpp mpp strcuture
+   !> @param[in] id_mask   sub domain mask (sea=1, land=0)
+   !> @pâram[in] id_niproc number of processors following I
+   !> @pâram[in] id_njproc number of processors following J
+   !> @return domain layout structure
+   !-------------------------------------------------------------------
+   FUNCTION layout__init( td_mpp, id_mask, id_niproc, id_njproc ) RESULT(td_lay)
+      IMPLICIT NONE
+      ! Argument
+      TYPE(TMPP)                 , INTENT(IN) :: td_mpp
+      INTEGER(i4), DIMENSION(:,:), INTENT(IN) :: id_mask
+      INTEGER(i4)                , INTENT(IN) :: id_niproc
+      INTEGER(i4)                , INTENT(IN) :: id_njproc
+
+      ! function
+      TYPE(TLAY) :: td_lay
+
+      ! local variable
+      INTEGER(i4) :: ii1, ii2
+      INTEGER(i4) :: ij1, ij2
+
+      INTEGER(i4) :: il_ldi
+      INTEGER(i4) :: il_ldj
+      INTEGER(i4) :: il_lei
+      INTEGER(i4) :: il_lej
+
+      INTEGER(i4) :: il_isize !< i-direction maximum sub domain size 
+      INTEGER(i4) :: il_jsize !< j-direction maximum sub domain size
+      INTEGER(i4) :: il_resti !<  
+      INTEGER(i4) :: il_restj !<  
+
+      ! loop indices
+      INTEGER(i4) :: ji
+      INTEGER(i4) :: jj
+      !----------------------------------------------------------------
+
+      ! intialise
+      td_lay%i_niproc=id_niproc
+      td_lay%i_njproc=id_njproc
+
+      CALL logger_info( "MPP COMPUTE LAYOUT: compute domain layout with "//&
+      &               TRIM(fct_str(td_lay%i_niproc))//" x "//&
+      &               TRIM(fct_str(td_lay%i_njproc))//" processors")
+
+      ! maximum size of sub domain
+      il_isize = ((td_mpp%t_dim(1)%i_len - 2*td_mpp%i_preci + (td_lay%i_niproc-1))/ &
+      &           td_lay%i_niproc) + 2*td_mpp%i_preci
+      il_jsize = ((td_mpp%t_dim(2)%i_len - 2*td_mpp%i_precj + (td_lay%i_njproc-1))/ &
+      &           td_lay%i_njproc) + 2*td_mpp%i_precj
+
+      il_resti = MOD(td_mpp%t_dim(1)%i_len - 2*td_mpp%i_preci, td_lay%i_niproc)
+      il_restj = MOD(td_mpp%t_dim(2)%i_len - 2*td_mpp%i_precj, td_lay%i_njproc)
+      IF( il_resti == 0 ) il_resti = td_lay%i_niproc
+      IF( il_restj == 0 ) il_restj = td_lay%i_njproc
+
+      ! compute dimension of each sub domain
+      ALLOCATE( td_lay%i_lci(td_lay%i_niproc,td_lay%i_njproc) )
+      ALLOCATE( td_lay%i_lcj(td_lay%i_niproc,td_lay%i_njproc) )
+
+      td_lay%i_lci( 1          : il_resti       , : ) = il_isize
+      td_lay%i_lci( il_resti+1 : td_lay%i_niproc, : ) = il_isize-1
+
+      td_lay%i_lcj( : , 1          : il_restj       ) = il_jsize
+      td_lay%i_lcj( : , il_restj+1 : td_lay%i_njproc) = il_jsize-1
+
+      ! compute first index of each sub domain
+      ALLOCATE( td_lay%i_impp(td_lay%i_niproc,td_lay%i_njproc) )
+      ALLOCATE( td_lay%i_jmpp(td_lay%i_niproc,td_lay%i_njproc) )
+
+      td_lay%i_impp(:,:)=1
+      td_lay%i_jmpp(:,:)=1
+
+      IF( td_lay%i_niproc > 1 )THEN
+         DO jj=1,td_lay%i_njproc
+            DO ji=2,td_lay%i_niproc
+               td_lay%i_impp(ji,jj) = td_lay%i_impp(ji-1,jj) + &
+               &                       td_lay%i_lci (ji-1,jj) - 2*td_mpp%i_preci
+            ENDDO
+         ENDDO
+      ENDIF
+
+      IF( td_lay%i_njproc > 1 )THEN
+         DO jj=2,td_lay%i_njproc
+            DO ji=1,td_lay%i_niproc
+               td_lay%i_jmpp(ji,jj) = td_lay%i_jmpp(ji,jj-1) + &
+               &                       td_lay%i_lcj (ji,jj-1) - 2*td_mpp%i_precj
+            ENDDO
+         ENDDO 
+      ENDIF
+
+      ALLOCATE(td_lay%i_msk(td_lay%i_niproc,td_lay%i_njproc))
+      td_lay%i_msk(:,:)=0
+      ! init number of sea/land proc
+      td_lay%i_nsea=0
+      td_lay%i_nland=td_lay%i_njproc*td_lay%i_niproc
+
+      ! check if processor is land or sea
+      DO jj = 1,td_lay%i_njproc
+         DO ji = 1,td_lay%i_niproc
+
+            ! compute first and last indoor indices
+            ! west boundary
+            IF( ji == 1 )THEN
+               il_ldi = 1 
+            ELSE
+               il_ldi = 1 + td_mpp%i_preci
+            ENDIF
+
+            ! south boundary
+            IF( jj == 1 )THEN
+               il_ldj = 1 
+            ELSE
+               il_ldj = 1 + td_mpp%i_precj
+            ENDIF
+
+            ! east boundary
+            IF( ji == td_mpp%i_niproc )THEN
+               il_lei = td_lay%i_lci(ji,jj)
+            ELSE
+               il_lei = td_lay%i_lci(ji,jj) - td_mpp%i_preci
+            ENDIF
+
+            ! north boundary
+            IF( jj == td_mpp%i_njproc )THEN
+               il_lej = td_lay%i_lcj(ji,jj)
+            ELSE
+               il_lej = td_lay%i_lcj(ji,jj) - td_mpp%i_precj
+            ENDIF
+
+            ii1=td_lay%i_impp(ji,jj) + il_ldi - 1
+            ii2=td_lay%i_impp(ji,jj) + il_lei - 1
+
+            ij1=td_lay%i_jmpp(ji,jj) + il_ldj - 1
+            ij2=td_lay%i_jmpp(ji,jj) + il_lej - 1
+
+            td_lay%i_msk(ji,jj)=SUM( id_mask(ii1:ii2,ij1:ij2) )
+            IF( td_lay%i_msk(ji,jj) > 0 )THEN ! sea
+               td_lay%i_nsea =td_lay%i_nsea +1
+               td_lay%i_nland=td_lay%i_nland-1
+            ENDIF
+
+         ENDDO
+      ENDDO
+
+      CALL logger_info( "MPP COMPUTE LAYOUT: sea proc "//TRIM(fct_str(td_lay%i_nsea)))
+      CALL logger_info( "MPP COMPUTE LAYOUT: land proc "//TRIM(fct_str(td_lay%i_nland)))
+      CALL logger_info( "MPP COMPUTE LAYOUT: sum "//TRIM(fct_str( SUM(td_lay%i_msk(:,:)))))
+
+      td_lay%i_mean= SUM(td_lay%i_msk(:,:)) / td_lay%i_nsea
+      td_lay%i_min = MINVAL(td_lay%i_msk(:,:),td_lay%i_msk(:,:)/=0)
+      td_lay%i_max = MAXVAL(td_lay%i_msk(:,:))
+
+      IF( lm_layout )THEN
+         ! print info 
+         WRITE(im_iumout,*) ' '
+         WRITE(im_iumout,*) " jpni=",td_lay%i_niproc ," jpnj=",td_lay%i_njproc
+         WRITE(im_iumout,*) " jpi= ",il_isize," jpj= ",il_jsize
+         WRITE(im_iumout,*) " iresti=",td_mpp%i_preci," irestj=",td_mpp%i_precj
+
+
+         WRITE(im_iumout,*) ' nombre de processeurs       ',td_lay%i_niproc*td_lay%i_njproc
+         WRITE(im_iumout,*) ' nombre de processeurs mer   ',td_lay%i_nsea
+         WRITE(im_iumout,*) ' nombre de processeurs terre ',td_lay%i_nland
+         WRITE(im_iumout,*) ' moyenne de recouvrement     ',td_lay%i_mean
+         WRITE(im_iumout,*) ' minimum de recouvrement     ',td_lay%i_min
+         WRITE(im_iumout,*) ' maximum de recouvrement     ',td_lay%i_max
+      ENDIF
+
+   END FUNCTION layout__init
+   !-------------------------------------------------------------------
+   !> @brief 
+   !>  This subroutine clean domain layout strcuture.
+   !>
+   !> @author J.Paul
+   !> @date October, 2015 - Initial version
+   !>
+   !> @param[inout] td_lay domain layout strcuture
+   !-------------------------------------------------------------------
+   SUBROUTINE layout__clean( td_lay )
+      IMPLICIT NONE
+      ! Argument
+      TYPE(TLAY),  INTENT(INOUT) :: td_lay
+      !----------------------------------------------------------------
+
+      IF( ASSOCIATED(td_lay%i_msk) )THEN
+         DEALLOCATE(td_lay%i_msk)
+      ENDIF
+      IF( ASSOCIATED(td_lay%i_impp) )THEN
+         DEALLOCATE(td_lay%i_impp)
+      ENDIF
+      IF( ASSOCIATED(td_lay%i_jmpp) )THEN
+         DEALLOCATE(td_lay%i_jmpp)
+      ENDIF
+      IF( ASSOCIATED(td_lay%i_lci) )THEN
+         DEALLOCATE(td_lay%i_lci)
+      ENDIF
+      IF( ASSOCIATED(td_lay%i_lcj) )THEN
+         DEALLOCATE(td_lay%i_lcj)
+      ENDIF
+
+      td_lay%i_niproc=0
+      td_lay%i_njproc=0
+      td_lay%i_nland =0
+      td_lay%i_nsea  =0
+
+      td_lay%i_mean  =0
+      td_lay%i_min   =0
+      td_lay%i_max   =0
+
+   END SUBROUTINE layout__clean
+   !-------------------------------------------------------------------
+   !> @brief
+   !> This subroutine copy domain layout structure in another one.
+   !>
+   !> @warning do not use on the output of a function who create or read a
+   !> structure (ex: tl_seg=seg__copy(seg__init()) is forbidden).
+   !> This will create memory leaks.
+   !> @warning to avoid infinite loop, do not use any function inside 
+   !> this subroutine
+   !>
+   !> @author J.Paul
+   !> @date October, 2015 - Initial Version
+   !
+   !> @param[in] td_lay   domain layout structure
+   !> @return copy of input domain layout structure
+   !-------------------------------------------------------------------
+   FUNCTION layout__copy( td_lay )
+      IMPLICIT NONE
+      ! Argument
+      TYPE(TLAY), INTENT(IN)  :: td_lay
+      ! function
+      TYPE(TLAY) :: layout__copy
+
+      ! local variable
+      INTEGER(i4), DIMENSION(2)                :: il_shape
+      INTEGER(i4), DIMENSION(:,:), ALLOCATABLE :: il_tmp
+      ! loop indices
+      !----------------------------------------------------------------
+
+      ! copy scalar 
+      layout__copy%i_niproc   = td_lay%i_niproc
+      layout__copy%i_njproc   = td_lay%i_njproc
+      layout__copy%i_nland    = td_lay%i_nland 
+      layout__copy%i_nsea     = td_lay%i_nsea  
+      layout__copy%i_mean     = td_lay%i_mean  
+      layout__copy%i_min      = td_lay%i_min   
+      layout__copy%i_max      = td_lay%i_max   
+
+      ! copy pointers
+      IF( ASSOCIATED(layout__copy%i_msk) )THEN
+         DEALLOCATE(layout__copy%i_msk)
+      ENDIF
+      IF( ASSOCIATED(td_lay%i_msk) )THEN
+         il_shape(:)=SHAPE(td_lay%i_msk(:,:))
+         ALLOCATE( layout__copy%i_msk(il_shape(jp_I),il_shape(jp_J)) )
+         layout__copy%i_msk(:,:)=td_lay%i_msk(:,:)
+      ENDIF
+
+      IF( ASSOCIATED(layout__copy%i_msk) ) DEALLOCATE(layout__copy%i_msk)
+      IF( ASSOCIATED(td_lay%i_msk) )THEN
+         il_shape(:)=SHAPE(td_lay%i_msk(:,:))
+         ALLOCATE(il_tmp(il_shape(jp_I),il_shape(jp_J)))
+         il_tmp(:,:)=td_lay%i_msk(:,:)
+
+         ALLOCATE( layout__copy%i_msk(il_shape(jp_I),il_shape(jp_J)) )
+         layout__copy%i_msk(:,:)=il_tmp(:,:)
+
+         DEALLOCATE(il_tmp)
+      ENDIF
+
+      IF( ASSOCIATED(layout__copy%i_impp) ) DEALLOCATE(layout__copy%i_impp)
+      IF( ASSOCIATED(td_lay%i_impp) )THEN
+         il_shape(:)=SHAPE(td_lay%i_impp(:,:))
+         ALLOCATE(il_tmp(il_shape(jp_I),il_shape(jp_J)))
+         il_tmp(:,:)=td_lay%i_impp(:,:)
+
+         ALLOCATE( layout__copy%i_impp(il_shape(jp_I),il_shape(jp_J)) )
+         layout__copy%i_impp(:,:)=il_tmp(:,:)
+
+         DEALLOCATE(il_tmp)
+      ENDIF
+
+      IF( ASSOCIATED(layout__copy%i_jmpp) ) DEALLOCATE(layout__copy%i_jmpp)
+      IF( ASSOCIATED(td_lay%i_jmpp) )THEN
+         il_shape(:)=SHAPE(td_lay%i_jmpp(:,:))
+         ALLOCATE(il_tmp(il_shape(jp_I),il_shape(jp_J)))
+         il_tmp(:,:)=td_lay%i_jmpp(:,:)
+
+         ALLOCATE( layout__copy%i_jmpp(il_shape(jp_I),il_shape(jp_J)) )
+         layout__copy%i_jmpp(:,:)=il_tmp(:,:)
+
+         DEALLOCATE(il_tmp)
+      ENDIF
+
+      IF( ASSOCIATED(layout__copy%i_lci) ) DEALLOCATE(layout__copy%i_lci)
+      IF( ASSOCIATED(td_lay%i_lci) )THEN
+         il_shape(:)=SHAPE(td_lay%i_lci(:,:))
+         ALLOCATE(il_tmp(il_shape(jp_I),il_shape(jp_J)))
+         il_tmp(:,:)=td_lay%i_lci(:,:)
+
+         ALLOCATE( layout__copy%i_lci(il_shape(jp_I),il_shape(jp_J)) )
+         layout__copy%i_lci(:,:)=il_tmp(:,:)
+
+         DEALLOCATE(il_tmp)
+      ENDIF
+
+      IF( ASSOCIATED(layout__copy%i_lcj) ) DEALLOCATE(layout__copy%i_lcj)
+      IF( ASSOCIATED(td_lay%i_lcj) )THEN
+         il_shape(:)=SHAPE(td_lay%i_lcj(:,:))
+         ALLOCATE(il_tmp(il_shape(jp_I),il_shape(jp_J)))
+         il_tmp(:,:)=td_lay%i_lcj(:,:)
+
+         ALLOCATE( layout__copy%i_lcj(il_shape(jp_I),il_shape(jp_J)) )
+         layout__copy%i_lcj(:,:)=il_tmp(:,:)
+
+         DEALLOCATE(il_tmp)
+      ENDIF
+
+   END FUNCTION layout__copy
+   !-------------------------------------------------------------------
+   !> @brief
+   !>    This subroutine create mpp structure using domain layout
+   !>
+   !> @detail
+   !
+   !> @author J.Paul
+   !> @date October, 2015 - Initial version
    !
    !> @param[inout] td_mpp mpp strcuture
-   !-------------------------------------------------------------------
-   SUBROUTINE mpp__compute( td_mpp )
+   !> @param[in] td_lay domain layout structure
+   !-------------------------------------------------------------------
+   SUBROUTINE mpp__create_layout( td_mpp, td_lay )
       IMPLICIT NONE
       ! Argument
       TYPE(TMPP), INTENT(INOUT) :: td_mpp
+      TYPE(TLAY), INTENT(IN   ) :: td_lay
 
       ! local variable
-      INTEGER(i4)                              :: il_isize !< i-direction maximum sub domain size 
-      INTEGER(i4)                              :: il_jsize !< j-direction maximum sub domain size
-      INTEGER(i4)                              :: il_resti !<  
-      INTEGER(i4)                              :: il_restj !<  
-      INTEGER(i4), DIMENSION(:,:), ALLOCATABLE :: il_nlci
-      INTEGER(i4), DIMENSION(:,:), ALLOCATABLE :: il_nlcj
-      INTEGER(i4), DIMENSION(:,:), ALLOCATABLE :: il_impp
-      INTEGER(i4), DIMENSION(:,:), ALLOCATABLE :: il_jmpp
-
       CHARACTER(LEN=lc)                        :: cl_file
       TYPE(TFILE)                              :: tl_proc
@@ -2617,195 +2905,154 @@
       td_mpp%i_nproc=0
 
-      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")
-      ! maximum size of sub domain
-      il_isize = ((td_mpp%t_dim(1)%i_len - 2*td_mpp%i_preci + (td_mpp%i_niproc-1))/ &
-      &           td_mpp%i_niproc) + 2*td_mpp%i_preci
-      il_jsize = ((td_mpp%t_dim(2)%i_len - 2*td_mpp%i_precj + (td_mpp%i_njproc-1))/ &
-      &           td_mpp%i_njproc) + 2*td_mpp%i_precj
-
-      il_resti = MOD(td_mpp%t_dim(1)%i_len - 2*td_mpp%i_preci, td_mpp%i_niproc)
-      il_restj = MOD(td_mpp%t_dim(2)%i_len - 2*td_mpp%i_precj, td_mpp%i_njproc)
-      IF( il_resti == 0 ) il_resti = td_mpp%i_niproc
-      IF( il_restj == 0 ) il_restj = td_mpp%i_njproc
-
-      ! compute dimension of each sub domain
-      ALLOCATE( il_nlci(td_mpp%i_niproc,td_mpp%i_njproc) )
-      ALLOCATE( il_nlcj(td_mpp%i_niproc,td_mpp%i_njproc) )
-
-      il_nlci( 1 : il_resti                , : ) = il_isize
-      il_nlci( il_resti+1 : td_mpp%i_niproc, : ) = il_isize-1
-
-      il_nlcj( : , 1 : il_restj                ) = il_jsize
-      il_nlcj( : , il_restj+1 : td_mpp%i_njproc) = il_jsize-1
-
-      ! compute first index of each sub domain
-      ALLOCATE( il_impp(td_mpp%i_niproc,td_mpp%i_njproc) )
-      ALLOCATE( il_jmpp(td_mpp%i_niproc,td_mpp%i_njproc) )
-
-      il_impp(:,:)=1
-      il_jmpp(:,:)=1
-
-      DO jj=1,td_mpp%i_njproc
-         DO ji=2,td_mpp%i_niproc
-            il_impp(ji,jj)=il_impp(ji-1,jj)+il_nlci(ji-1,jj)-2*td_mpp%i_preci
+      CALL logger_debug( "MPP CREATE LAYOUT: create domain decomposition with "//&
+      &               TRIM(fct_str(td_lay%i_niproc))//" x "//&
+      &               TRIM(fct_str(td_lay%i_njproc))//" = "//&
+      &               TRIM(fct_str(td_lay%i_nsea))//" processors")
+
+      IF( lm_layout )THEN
+         WRITE(im_iumout,*) ' choix optimum'
+         WRITE(im_iumout,*) ' ============='
+         WRITE(im_iumout,*)
+         ! print info 
+         WRITE(im_iumout,*) ' '
+         WRITE(im_iumout,*) " jpni=",td_lay%i_niproc ," jpnj=",td_lay%i_njproc
+         WRITE(im_iumout,*) " iresti=",td_mpp%i_preci," irestj=",td_mpp%i_precj
+
+
+         WRITE(im_iumout,*) ' nombre de processeurs       ',td_lay%i_niproc*td_lay%i_njproc
+         WRITE(im_iumout,*) ' nombre de processeurs mer   ',td_lay%i_nsea
+         WRITE(im_iumout,*) ' nombre de processeurs terre ',td_lay%i_nland
+         WRITE(im_iumout,*) ' moyenne de recouvrement     ',td_lay%i_mean
+         WRITE(im_iumout,*) ' minimum de recouvrement     ',td_lay%i_min
+         WRITE(im_iumout,*) ' maximum de recouvrement     ',td_lay%i_max
+      ENDIF
+
+      td_mpp%i_niproc=td_lay%i_niproc
+      td_mpp%i_njproc=td_lay%i_njproc
+      !td_mpp%i_nproc =td_lay%i_nsea
+
+      IF( td_mpp%i_niproc*td_mpp%i_njproc == td_lay%i_nsea )THEN
+         IF( td_lay%i_nsea == 1 )THEN
+            td_mpp%c_dom='full'
+         ELSE
+            td_mpp%c_dom='nooverlap'
+         ENDIF
+      ELSE
+            td_mpp%c_dom='noextra'
+      ENDIF
+      
+      jk=0
+      DO jj=1,td_lay%i_njproc
+         DO ji=1,td_lay%i_niproc
+
+            IF( td_lay%i_msk(ji,jj) >= 1 )THEN
+
+               ! get processor file name
+               cl_file=file_rename(td_mpp%c_name,jk)
+               ! initialise file structure
+               tl_proc=file_init(cl_file,td_mpp%c_type)
+
+               ! procesor id
+               tl_proc%i_pid=jk
+
+               tl_att=att_init("DOMAIN_number",tl_proc%i_pid)
+               CALL file_add_att(tl_proc, tl_att)
+
+               ! processor indices
+               tl_proc%i_iind=ji
+               tl_proc%i_jind=jj
+
+               ! fill processor dimension and first indices
+               tl_proc%i_impp = td_lay%i_impp(ji,jj)
+               tl_proc%i_jmpp = td_lay%i_jmpp(ji,jj)
+
+               tl_proc%i_lci  = td_lay%i_lci(ji,jj)
+               tl_proc%i_lcj  = td_lay%i_lcj(ji,jj)
+
+               ! compute first and last indoor indices
+               
+               ! west boundary
+               IF( ji == 1 )THEN
+                  tl_proc%i_ldi = 1 
+                  tl_proc%l_ctr = .TRUE.
+               ELSE
+                  tl_proc%i_ldi = 1 + td_mpp%i_preci
+               ENDIF
+
+               ! south boundary
+               IF( jj == 1 )THEN
+                  tl_proc%i_ldj = 1 
+                  tl_proc%l_ctr = .TRUE.
+               ELSE
+                  tl_proc%i_ldj = 1 + td_mpp%i_precj
+               ENDIF
+
+               ! east boundary
+               IF( ji == td_mpp%i_niproc )THEN
+                  tl_proc%i_lei = td_lay%i_lci(ji,jj)
+                  tl_proc%l_ctr = .TRUE.
+               ELSE
+                  tl_proc%i_lei = td_lay%i_lci(ji,jj) - td_mpp%i_preci
+               ENDIF
+
+               ! north boundary
+               IF( jj == td_mpp%i_njproc )THEN
+                  tl_proc%i_lej = td_lay%i_lcj(ji,jj)
+                  tl_proc%l_ctr = .TRUE.
+               ELSE
+                  tl_proc%i_lej = td_lay%i_lcj(ji,jj) - td_mpp%i_precj
+               ENDIF
+
+               ! add processor to mpp structure
+               CALL mpp__add_proc(td_mpp, tl_proc)
+
+               ! clean
+               CALL att_clean(tl_att)
+               CALL file_clean(tl_proc)
+
+               ! update proc number
+               jk=jk+1 !ji+(jj-1)*td_lay%i_niproc
+
+            ENDIF
          ENDDO
       ENDDO
 
-      DO jj=2,td_mpp%i_njproc
-         DO ji=1,td_mpp%i_niproc
-            il_jmpp(ji,jj)=il_jmpp(ji,jj-1)+il_nlcj(ji,jj-1)-2*td_mpp%i_precj
-         ENDDO
-      ENDDO 
-
-      DO jj=1,td_mpp%i_njproc
-         DO ji=1,td_mpp%i_niproc
-
-            jk=ji+(jj-1)*td_mpp%i_niproc
-
-            ! get processor file name
-            cl_file=file_rename(td_mpp%c_name,jk)
-            ! initialise file structure
-            tl_proc=file_init(cl_file,td_mpp%c_type)
-
-            ! procesor id
-            tl_proc%i_pid=jk
-
-            tl_att=att_init("DOMAIN_number",tl_proc%i_pid)
-            CALL file_add_att(tl_proc, tl_att)
-
-            ! processor indices
-            tl_proc%i_iind=ji
-            tl_proc%i_jind=jj
-
-            ! fill processor dimension and first indices
-            tl_proc%i_impp = il_impp(ji,jj)
-            tl_proc%i_jmpp = il_jmpp(ji,jj)
-
-            tl_att=att_init( "DOMAIN_poistion_first", &
-            &                (/tl_proc%i_impp, tl_proc%i_jmpp/) )
-            CALL file_add_att(tl_proc, tl_att)
-
-            tl_proc%i_lci  = il_nlci(ji,jj)
-            tl_proc%i_lcj  = il_nlcj(ji,jj)
-
-            tl_att=att_init( "DOMAIN_poistion_last", &
-            &                (/tl_proc%i_lci, tl_proc%i_lcj/) )
-            CALL file_add_att(tl_proc, tl_att)
-
-            ! compute first and last indoor indices
-            
-            ! west boundary
-            IF( ji == 1 )THEN
-               tl_proc%i_ldi = 1 
-               tl_proc%l_ctr = .TRUE.
-            ELSE
-               tl_proc%i_ldi = 1 + td_mpp%i_preci
-            ENDIF
-
-            ! south boundary
-            IF( jj == 1 )THEN
-               tl_proc%i_ldj = 1 
-               tl_proc%l_ctr = .TRUE.
-            ELSE
-               tl_proc%i_ldj = 1 + td_mpp%i_precj
-            ENDIF
-
-            ! east boundary
-            IF( ji == td_mpp%i_niproc )THEN
-               tl_proc%i_lei = il_nlci(ji,jj)
-               tl_proc%l_ctr = .TRUE.
-            ELSE
-               tl_proc%i_lei = il_nlci(ji,jj) - td_mpp%i_preci
-            ENDIF
-
-            ! north boundary
-            IF( jj == td_mpp%i_njproc )THEN
-               tl_proc%i_lej = il_nlcj(ji,jj)
-               tl_proc%l_ctr = .TRUE.
-            ELSE
-               tl_proc%i_lej = il_nlcj(ji,jj) - td_mpp%i_precj
-            ENDIF
-
-            tl_att=att_init( "DOMAIN_halo_size_start", &
-            &                (/tl_proc%i_ldi, tl_proc%i_ldj/) )
-            CALL file_add_att(tl_proc, tl_att)
-            tl_att=att_init( "DOMAIN_halo_size_end", &
-            &                (/tl_proc%i_ldi, tl_proc%i_ldj/) )
-            CALL file_add_att(tl_proc, tl_att)
-
-            ! add processor to mpp structure
-            CALL mpp__add_proc(td_mpp, tl_proc)
-
-            ! clean
-            CALL att_clean(tl_att)
-            CALL file_clean(tl_proc)
-
-         ENDDO
-      ENDDO
-
-      DEALLOCATE( il_impp, il_jmpp )
-      DEALLOCATE( il_nlci, il_nlcj )
-
-   END SUBROUTINE mpp__compute
+   END SUBROUTINE mpp__create_layout
    !-------------------------------------------------------------------
    !> @brief 
-   !>  This subroutine remove land processor from domain decomposition.
-   !>
+   !>  This subroutine optimize the number of sub domain to be used, given mask.
+   !> @details
+   !>  Actually it get the domain decomposition with the most land 
+   !>  processors removed.
+   !>  If no land processor could be removed, it get the decomposition with the
+   !>  most sea processors.
+   !
    !> @author J.Paul
    !> @date November, 2013 - Initial version
-   !>
+   !> @date October, 2015
+   !> - improve way to compute domain layout 
+   !> @date February, 2016
+   !> - new criteria for domain layout in case no land proc
+   !
    !> @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 )
+   !> @param[in] id_mask   sub domain mask (sea=1, land=0) 
+   !> @pram[in] id_nproc maximum number of processor to be used
+   !-------------------------------------------------------------------
+   SUBROUTINE mpp__optimiz( td_mpp, id_mask, id_nproc )
       IMPLICIT NONE
       ! Argument
       TYPE(TMPP),                  INTENT(INOUT) :: td_mpp
       INTEGER(i4), DIMENSION(:,:), INTENT(IN)    :: id_mask
-
-      ! loop indices
-      INTEGER(i4) :: jk
-      !----------------------------------------------------------------
-
-      IF( ASSOCIATED(td_mpp%t_proc) )THEN
-         jk=1
-         DO WHILE( jk <= td_mpp%i_nproc )
-            IF( mpp__land_proc(td_mpp, jk, id_mask(:,:)) )THEN
-               CALL mpp__del_proc(td_mpp, jk)
-            ELSE
-               jk=jk+1
-            ENDIF
-         ENDDO
-      ELSE
-         CALL logger_error("MPP DEL LAND: domain decomposition not define.")
-      ENDIF
-
-   END SUBROUTINE mpp__del_land
-   !-------------------------------------------------------------------
-   !> @brief 
-   !>  This subroutine optimize the number of sub domain to be used, given mask.
-   !> @details
-   !>  Actually it get the domain decomposition with the most land 
-   !>  processor removed.
-   !
-   !> @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__optimiz( td_mpp, id_mask )
-      IMPLICIT NONE
-      ! Argument
-      TYPE(TMPP),                  INTENT(INOUT) :: td_mpp
-      INTEGER(i4), DIMENSION(:,:), INTENT(IN)    :: id_mask
+      INTEGER(i4)                , INTENT(IN)    :: id_nproc
 
       ! local variable
-      TYPE(TMPP)  :: tl_mpp
-      INTEGER(i4) :: il_maxproc
-
-      TYPE(TFILE), DIMENSION(:), ALLOCATABLE :: tl_proc
+      TYPE(TLAY) :: tl_lay
+      TYPE(TLAY) :: tl_sav
+
+      REAL(dp)   :: dl_min
+      REAL(dp)   :: dl_max
+      REAL(dp)   :: dl_ratio
+      REAL(dp)   :: dl_sav
+
       ! loop indices
       INTEGER(i4) :: ji
@@ -2814,129 +3061,68 @@
 
       CALL logger_trace("MPP OPTIMIZ: look for best domain decomposition")
-      tl_mpp=mpp_copy(td_mpp)
-
-      ! save maximum number of processor to be used
-      il_maxproc=td_mpp%i_nproc
+      dl_sav=0
       ! 
-      td_mpp%i_nproc=0
-      DO ji=1,il_maxproc
-         DO jj=1,il_maxproc
-
-            ! clean mpp processor
-            IF( ASSOCIATED(tl_mpp%t_proc) )THEN
-               CALL file_clean(tl_mpp%t_proc(:))
-               DEALLOCATE(tl_mpp%t_proc)
-            ENDIF
-
-            ! compute domain decomposition
-            tl_mpp%i_niproc=ji
-            tl_mpp%i_njproc=jj
-            
-            CALL mpp__compute( tl_mpp )
-            
-            ! remove land sub domain
-            CALL mpp__del_land( tl_mpp, id_mask )
-
-            CALL logger_info("MPP OPTIMIZ: number of processor "//&
-            &   TRIM(fct_str(ji))//"x"//TRIM(fct_str(jj))//"="//&
-            &   TRIM(fct_str(tl_mpp%i_nproc)) )
-            IF( tl_mpp%i_nproc > td_mpp%i_nproc .AND. &
-            &   tl_mpp%i_nproc <= il_maxproc )THEN
-               ! save optimiz decomposition 
-
-               CALL logger_info("MPP OPTIMIZ:save this decomposition "//&
-               &   TRIM(fct_str(ji))//"x"//TRIM(fct_str(jj))//"="//&
-               &   TRIM(fct_str(tl_mpp%i_nproc)) )
-
-               ! clean mpp
-               CALL mpp_clean(td_mpp)
-
-               ! save processor array
-               ALLOCATE( tl_proc(tl_mpp%i_nproc) )
-               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 array
-               td_mpp=mpp_copy(tl_mpp)
-
-               ! save processor array
-               ALLOCATE( td_mpp%t_proc(td_mpp%i_nproc) )
-               td_mpp%t_proc(:)=file_copy(tl_proc(:))
-
-               ! clean
-               CALL file_clean( tl_proc(:) )
-               DEALLOCATE(tl_proc)
-
-            ENDIF
-            
+      DO ji=1,id_nproc
+         DO jj=1,id_nproc
+
+            ! compute domain layout
+            tl_lay=layout__init( td_mpp, id_mask, ji,jj )
+            IF( tl_lay%i_nsea <= id_nproc )THEN
+
+               IF( ASSOCIATED(tl_sav%i_lci) )THEN
+                  IF( tl_sav%i_nland /= 0 )THEN
+                     ! look for layout with most land proc
+                     IF( tl_lay%i_nland > tl_sav%i_nland    .OR. &
+                     &   ( tl_lay%i_nland == tl_sav%i_nland .AND. &
+                     &     tl_lay%i_min   >  tl_sav%i_min   ) )THEN
+                        ! save optimiz layout
+                        CALL logger_info("MPP OPTIMIZ:save this decomposition "//&
+                        &   TRIM(fct_str(ji))//"x"//TRIM(fct_str(jj))//"="//&
+                        &   TRIM(fct_str(tl_lay%i_nsea)) )
+
+                        tl_sav=layout__copy(tl_lay)
+                     ENDIF
+                  ELSE ! tl_sav%i_nland == 0
+                     ! look for layout with most sea proc 
+                     ! and "square" cell 
+                     dl_min=MIN(tl_lay%i_lci(1,1),tl_lay%i_lcj(1,1))
+                     dl_max=MAX(tl_lay%i_lci(1,1),tl_lay%i_lcj(1,1))
+                     dl_ratio=dl_min/dl_max
+                     IF( tl_lay%i_nsea > tl_sav%i_nsea    .OR. &
+                     &   ( tl_lay%i_nsea == tl_sav%i_nsea .AND. &
+                     &     dl_ratio   >  dl_sav ) )THEN
+                        ! save optimiz layout
+                        CALL logger_info("MPP OPTIMIZ:save this decomposition "//&
+                        &   TRIM(fct_str(ji))//"x"//TRIM(fct_str(jj))//"="//&
+                        &   TRIM(fct_str(tl_lay%i_nsea)) )
+
+                        tl_sav=layout__copy(tl_lay)
+                        dl_sav=dl_ratio
+                     ENDIF
+                  ENDIF
+               ELSE
+                  ! init tl_sav
+                  tl_sav=layout__copy(tl_lay)
+
+                  dl_min=MIN(tl_sav%i_lci(1,1),tl_sav%i_lcj(1,1))
+                  dl_max=MAX(tl_sav%i_lci(1,1),tl_sav%i_lcj(1,1))
+                  dl_sav=dl_min/dl_max
+               ENDIF
+
+            ENDIF
+
+            ! clean
+            CALL layout__clean( tl_lay )
+
          ENDDO
       ENDDO
 
+      ! create mpp domain layout
+      CALL mpp__create_layout(td_mpp, tl_sav)
+
       ! clean
-      CALL mpp_clean(tl_mpp)
+      CALL layout__clean( tl_sav )
 
    END SUBROUTINE mpp__optimiz
-   !-------------------------------------------------------------------
-   !> @brief
-   !>    This function check if processor is a land processor.
-   !>
-   !> @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
-      ! Argument
-      TYPE(TMPP),                  INTENT(IN) :: td_mpp
-      INTEGER(i4),                 INTENT(IN) :: id_proc
-      INTEGER(i4), DIMENSION(:,:), INTENT(IN) :: id_mask
-
-      ! local variable
-      INTEGER(i4), DIMENSION(2) :: il_shape
-      !----------------------------------------------------------------
-
-      CALL logger_trace("MPP LAND PROC: check processor "//TRIM(fct_str(id_proc))//&
-      &  " of mpp "//TRIM(td_mpp%c_name) )
-      mpp__land_proc=.FALSE.
-      IF( ASSOCIATED(td_mpp%t_proc) )THEN
-
-         il_shape(:)=SHAPE(id_mask)
-         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_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 +            &
-            &                       td_mpp%t_proc(id_proc)%i_ldi - 1 : &
-            &                td_mpp%t_proc(id_proc)%i_impp +            &
-            &                       td_mpp%t_proc(id_proc)%i_lei - 1,  &
-            &                td_mpp%t_proc(id_proc)%i_jmpp +            &
-            &                       td_mpp%t_proc(id_proc)%i_ldj - 1 : &
-            &                td_mpp%t_proc(id_proc)%i_jmpp +            &
-            &                       td_mpp%t_proc(id_proc)%i_lej - 1)  &
-            &      /= 1 ) )THEN
-               ! land domain
-               CALL logger_info("MPP LAND PROC: processor "//TRIM(fct_str(id_proc))//&
-               &             " is land processor")
-               mpp__land_proc=.TRUE.
-            ENDIF
-         ENDIF
-
-      ELSE
-         CALL logger_error("MPP LAND PROC: domain decomposition not define.")
-      ENDIF
-
-   END FUNCTION mpp__land_proc
    !-------------------------------------------------------------------
    !> @brief 
@@ -3195,12 +3381,15 @@
          SELECT CASE(TRIM(td_mpp%c_dom))
             CASE('full')
-               il_i1 = 1 ; il_i2 = td_mpp%t_dim(1)%i_len
-               il_j1 = 1 ; il_j2 = td_mpp%t_dim(2)%i_len
-            CASE('overlap')
-                il_i1 = td_mpp%t_proc(id_procid)%i_impp
-                il_j1 = td_mpp%t_proc(id_procid)%i_jmpp
-
-                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 
+               il_i1 = 1 
+               il_j1 = 1 
+
+               il_i2 = td_mpp%t_dim(1)%i_len
+               il_j2 = td_mpp%t_dim(2)%i_len
+            CASE('noextra')
+               il_i1 = td_mpp%t_proc(id_procid)%i_impp
+               il_j1 = td_mpp%t_proc(id_procid)%i_jmpp
+
+               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')
                il_i1 = td_mpp%t_proc(id_procid)%i_impp + &
@@ -3214,5 +3403,6 @@
                &        td_mpp%t_proc(id_procid)%i_lej - 1
             CASE DEFAULT
-               CALL logger_error("MPP GET PROC INDEX: invalid decomposition type.")
+               CALL logger_error("MPP GET PROC INDEX: invalid "//&
+                  &              "decomposition type.")
          END SELECT
 
@@ -3264,5 +3454,5 @@
                il_jsize = td_mpp%t_dim(2)%i_len
 
-            CASE('overlap')
+            CASE('noextra')
 
                 il_isize = td_mpp%t_proc(id_procid)%i_lci
@@ -3308,5 +3498,5 @@
       IF( ASSOCIATED(td_mpp%t_proc) )THEN
 
-         IF( td_mpp%i_niproc == 0 .AND. td_mpp%i_niproc == 0 )THEN
+         IF( td_mpp%i_niproc == 0 .AND. td_mpp%i_njproc == 0 )THEN
             CALL logger_info("MPP GET DOM: use indoor indices to get domain "//&
             &             "decomposition type.")
@@ -3323,5 +3513,5 @@
             &       td_mpp%t_proc(1)%i_lcj                     )     )THEN
 
-               td_mpp%c_dom='overlap'
+               td_mpp%c_dom='noextra'
 
             ELSEIF((td_mpp%t_proc(1)%t_dim(1)%i_len ==                     &
@@ -3368,5 +3558,5 @@
                td_mpp%c_dom='nooverlap'
             ELSE
-               td_mpp%c_dom='overlap'
+               td_mpp%c_dom='noextra'
             ENDIF
 
@@ -3386,4 +3576,6 @@
    !> @author J.Paul
    !> @date November, 2013 - Initial Version
+   !> @date September 2015
+   !> - do not check used dimension here
    !>
    !> @param[in] td_mpp mpp structure
@@ -3398,4 +3590,9 @@
 
       ! local variable
+      CHARACTER(LEN=lc) :: cl_dim
+      LOGICAL :: ll_error
+      LOGICAL :: ll_warn
+
+      INTEGER(i4)       :: il_ind
 
       ! loop indices
@@ -3403,28 +3600,70 @@
       !----------------------------------------------------------------
       mpp__check_var_dim=.TRUE.
+
       ! check used dimension 
-      IF( ANY( td_var%t_dim(:)%l_use .AND. &
-      &        td_var%t_dim(:)%i_len /= td_mpp%t_dim(:)%i_len) )THEN
+      ll_error=.FALSE.
+      ll_warn=.FALSE.
+      DO ji=1,ip_maxdim
+         il_ind=dim_get_index( td_mpp%t_dim(:), &
+         &                     TRIM(td_var%t_dim(ji)%c_name), &
+         &                     TRIM(td_var%t_dim(ji)%c_sname))
+         IF( il_ind /= 0 )THEN
+            IF( td_var%t_dim(ji)%l_use  .AND. &
+            &   td_mpp%t_dim(il_ind)%l_use .AND. &
+            &   td_var%t_dim(ji)%i_len /= td_mpp%t_dim(il_ind)%i_len )THEN
+               IF( INDEX( TRIM(td_var%c_axis), &
+               &          TRIM(fct_upper(td_var%t_dim(ji)%c_name))) == 0 )THEN
+                  ll_warn=.TRUE.
+               ELSE
+                  ll_error=.TRUE.
+               ENDIF
+            ENDIF
+         ENDIF
+      ENDDO
+
+      IF( ll_error )THEN
+
+         cl_dim='(/'
+         DO ji = 1, td_mpp%i_ndim
+            IF( td_mpp%t_dim(ji)%l_use )THEN
+               cl_dim=TRIM(cl_dim)//&
+               &  TRIM(fct_upper(td_mpp%t_dim(ji)%c_sname))//':'//&
+               &  TRIM(fct_str(td_mpp%t_dim(ji)%i_len))//','
+            ENDIF
+         ENDDO
+         cl_dim=TRIM(cl_dim)//'/)'
+         CALL logger_debug( " mpp dimension: "//TRIM(cl_dim) )
+
+         cl_dim='(/'
+         DO ji = 1, td_var%i_ndim
+            IF( td_var%t_dim(ji)%l_use )THEN
+               cl_dim=TRIM(cl_dim)//&
+               &  TRIM(fct_upper(td_var%t_dim(ji)%c_sname))//':'//&
+               &  TRIM(fct_str(td_var%t_dim(ji)%i_len))//','
+            ENDIF
+         ENDDO
+         cl_dim=TRIM(cl_dim)//'/)'
+         CALL logger_debug( " variable dimension: "//TRIM(cl_dim) )
 
          mpp__check_var_dim=.FALSE.
 
-         CALL logger_debug( &
-         &  " mpp dimension: "//TRIM(fct_str(td_mpp%i_ndim))//&
-         &  " variable dimension: "//TRIM(fct_str(td_var%i_ndim)) )
-         DO ji = 1, ip_maxdim
-            CALL logger_debug( &
-            &  "MPP CHECK DIM: for dimension "//&
-            &  TRIM(td_mpp%t_dim(ji)%c_name)//&
-            &  ", mpp length: "//&
-            &  TRIM(fct_str(td_mpp%t_dim(ji)%i_len))//&
-            &  ", variable length: "//&
-            &  TRIM(fct_str(td_var%t_dim(ji)%i_len))//&
-            &  ", variable used "//TRIM(fct_str(td_var%t_dim(ji)%l_use)))
-         ENDDO
-
          CALL logger_error( &
-         &  "MPP CHECK DIM: variable and mpp dimension differ"//&
+         &  " MPP CHECK VAR DIM: variable and file dimension differ"//&
          &  " for variable "//TRIM(td_var%c_name)//&
-         &  " and mpp "//TRIM(td_mpp%c_name))
+         &  " and file "//TRIM(td_mpp%c_name))
+
+      ELSEIF( ll_warn )THEN
+         CALL logger_warn( &
+         &  " MPP CHECK VAR DIM: variable and file dimension differ"//&
+         &  " for variable "//TRIM(td_var%c_name)//&
+         &  " and file "//TRIM(td_mpp%c_name)//". you should use"//&
+         &  " var_check_dim to remove useless dimension.")
+      ELSE
+
+         IF( td_var%i_ndim >  td_mpp%i_ndim )THEN
+            CALL logger_info("MPP CHECK VAR DIM: variable "//&
+            &  TRIM(td_var%c_name)//" use more dimension than file "//&
+            &  TRIM(td_mpp%c_name)//" do until now.")
+         ENDIF
 
       ENDIF
@@ -3583,4 +3822,278 @@
       ENDIF
    END FUNCTION mpp_recombine_var
+   !-------------------------------------------------------------------
+   !> @brief This subroutine read subdomain indices defined with halo
+   !> (NEMO netcdf way)
+   !>
+   !> @author J.Paul
+   !> @date January, 2016 - Initial Version
+   !>
+   !> @param[inout] td_file   mpp structure
+   !-------------------------------------------------------------------
+   SUBROUTINE mpp__read_halo(td_file, td_dimglo) 
+   IMPLICIT NONE
+      ! Argument      
+      TYPE(TFILE)              , INTENT(INOUT) :: td_file
+      TYPE(TDIM) , DIMENSION(:), INTENT(IN   ) :: td_dimglo
+
+      ! local variable
+      INTEGER(i4)       :: il_attid
+      INTEGER(i4)       :: il_ifirst
+      INTEGER(i4)       :: il_jfirst
+      INTEGER(i4)       :: il_ilast
+      INTEGER(i4)       :: il_jlast
+      INTEGER(i4)       :: il_ihalostart
+      INTEGER(i4)       :: il_jhalostart
+      INTEGER(i4)       :: il_ihaloend
+      INTEGER(i4)       :: il_jhaloend
+
+      CHARACTER(LEN=lc) :: cl_dom
+      !----------------------------------------------------------------
+
+      ! DOMAIN_position_first
+      il_attid = 0
+      IF( ASSOCIATED(td_file%t_att) )THEN
+         il_attid=att_get_id( td_file%t_att, "DOMAIN_position_first" )
+      ENDIF
+      IF( il_attid /= 0 )THEN
+         il_ifirst = INT(td_file%t_att(il_attid)%d_value(1))
+         il_jfirst = INT(td_file%t_att(il_attid)%d_value(2))
+      ELSE
+         il_ifirst = 1
+         il_jfirst = 1
+      ENDIF
+
+      ! DOMAIN_position_last
+      il_attid = 0
+      IF( ASSOCIATED(td_file%t_att) )THEN
+         il_attid=att_get_id( td_file%t_att, "DOMAIN_position_last" )
+      ENDIF
+      IF( il_attid /= 0 )THEN
+         il_ilast = INT(td_file%t_att(il_attid)%d_value(1))
+         il_jlast = INT(td_file%t_att(il_attid)%d_value(2))
+      ELSE
+         il_ilast = td_file%t_dim(1)%i_len
+         il_jlast = td_file%t_dim(2)%i_len
+      ENDIF
+
+      ! DOMAIN_halo_size_start
+      il_attid = 0
+      IF( ASSOCIATED(td_file%t_att) )THEN
+         il_attid=att_get_id( td_file%t_att, "DOMAIN_halo_size_start" )
+      ENDIF
+      IF( il_attid /= 0 )THEN
+         il_ihalostart = INT(td_file%t_att(il_attid)%d_value(1))
+         il_jhalostart = INT(td_file%t_att(il_attid)%d_value(2))
+      ELSE
+         il_ihalostart = 0
+         il_jhalostart = 0
+      ENDIF
+
+      ! DOMAIN_halo_size_end
+      il_attid = 0
+      IF( ASSOCIATED(td_file%t_att) )THEN
+         il_attid=att_get_id( td_file%t_att, "DOMAIN_halo_size_end" )
+      ENDIF
+      IF( il_attid /= 0 )THEN
+         il_ihaloend = INT(td_file%t_att(il_attid)%d_value(1))
+         il_jhaloend = INT(td_file%t_att(il_attid)%d_value(2))
+      ELSE
+         il_ihaloend = 0
+         il_jhaloend = 0
+      ENDIF
+
+      IF( (td_dimglo(jp_I)%i_len == td_file%t_dim(jp_I)%i_len) .AND. &
+        & (td_dimglo(jp_J)%i_len == td_file%t_dim(jp_J)%i_len) )THEN
+         cl_dom='full'
+      ELSEIF( il_ihalostart == 0 .AND. il_jhalostart == 0 .AND. &
+           &  il_ihaloend == 0 .AND. il_jhaloend == 0 )THEN
+         cl_dom='nooverlap'
+      ELSE
+         cl_dom='noextra'
+      ENDIF
+
+      SELECT CASE(TRIM(cl_dom))
+         CASE('full')
+            td_file%i_impp = il_ifirst 
+            td_file%i_jmpp = il_jfirst
+            td_file%i_lci  = td_file%t_dim(jp_I)%i_len 
+            td_file%i_lcj  = td_file%t_dim(jp_J)%i_len
+            td_file%i_ldi  = il_ihalostart + 1
+            td_file%i_ldj  = il_jhalostart + 1
+            td_file%i_lei  = td_file%t_dim(jp_I)%i_len - il_ihaloend
+            td_file%i_lej  = td_file%t_dim(jp_J)%i_len - il_jhaloend
+         CASE('noextra')
+            td_file%i_impp = il_ifirst
+            td_file%i_jmpp = il_jfirst
+            td_file%i_lci  = td_file%t_dim(jp_I)%i_len
+            td_file%i_lcj  = td_file%t_dim(jp_J)%i_len
+            td_file%i_ldi  = il_ihalostart + 1
+            td_file%i_ldj  = il_jhalostart + 1
+            td_file%i_lei  = td_file%i_lci - il_ihaloend
+            td_file%i_lej  = td_file%i_lcj - il_jhaloend
+         CASE('nooverlap') !!!?????
+            td_file%i_impp = il_ifirst
+            td_file%i_jmpp = il_jfirst
+            td_file%i_lci  = td_file%t_dim(jp_I)%i_len
+            td_file%i_lcj  = td_file%t_dim(jp_J)%i_len
+            td_file%i_ldi  = 1
+            td_file%i_ldj  = 1 
+            td_file%i_lei  = td_file%t_dim(jp_I)%i_len
+            td_file%i_lej  = td_file%t_dim(jp_J)%i_len
+      END SELECT
+
+   END SUBROUTINE mpp__read_halo
+   !-------------------------------------------------------------------
+   !> @brief This subroutine compute subdomain indices defined with halo
+   !> (NEMO netcdf way)
+   !>
+   !> @author J.Paul
+   !> @date January, 2016 - Initial Version
+   !>
+   !> @param[inout] td_mpp   mpp structure
+   !-------------------------------------------------------------------
+   SUBROUTINE mpp__compute_halo(td_mpp) 
+   IMPLICIT NONE
+      ! Argument      
+      TYPE(TMPP)      , INTENT(INOUT) :: td_mpp
+
+      ! local variable
+      INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_ifirst
+      INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_jfirst
+      INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_ilast
+      INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_jlast
+      INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_ihalostart
+      INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_jhalostart
+      INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_ihaloend
+      INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_jhaloend
+
+      TYPE(TATT)                             :: tl_att
+
+      ! loop indices
+      INTEGER(i4) :: ji
+      !----------------------------------------------------------------
+
+      ALLOCATE( il_ifirst    (td_mpp%i_nproc) )
+      ALLOCATE( il_jfirst    (td_mpp%i_nproc) )
+
+      ALLOCATE( il_ilast     (td_mpp%i_nproc) )
+      ALLOCATE( il_jlast     (td_mpp%i_nproc) )
+
+      ALLOCATE( il_ihalostart(td_mpp%i_nproc) )
+      ALLOCATE( il_jhalostart(td_mpp%i_nproc) )
+
+      ALLOCATE( il_ihaloend  (td_mpp%i_nproc) )
+      ALLOCATE( il_jhaloend  (td_mpp%i_nproc) )
+
+      SELECT CASE(TRIM(td_mpp%c_dom))
+         CASE('full')
+            
+            il_ifirst(:)=td_mpp%t_proc(:)%i_impp
+            il_jfirst(:)=td_mpp%t_proc(:)%i_jmpp
+            
+            il_ilast(:)=td_mpp%t_proc(:)%i_impp + td_mpp%t_proc(:)%t_dim(jp_I)%i_len - 1
+            il_jlast(:)=td_mpp%t_proc(:)%i_jmpp + td_mpp%t_proc(:)%t_dim(jp_J)%i_len - 1
+
+            il_ihalostart(:)=td_mpp%t_proc(:)%i_ldi-1
+            il_jhalostart(:)=td_mpp%t_proc(:)%i_ldj-1
+            
+            il_ihaloend(:)=td_mpp%t_proc(:)%t_dim(jp_I)%i_len - td_mpp%t_proc(:)%i_lei
+            il_jhaloend(:)=td_mpp%t_proc(:)%t_dim(jp_J)%i_len - td_mpp%t_proc(:)%i_lej
+
+         CASE('noextra')
+            
+            il_ifirst(:)=td_mpp%t_proc(:)%i_impp
+            il_jfirst(:)=td_mpp%t_proc(:)%i_jmpp
+
+            il_ilast(:) =td_mpp%t_proc(:)%i_impp + td_mpp%t_proc(:)%i_lci - 1
+            il_jlast(:) =td_mpp%t_proc(:)%i_jmpp + td_mpp%t_proc(:)%i_lcj - 1
+            
+            il_ihalostart(:)=td_mpp%t_proc(:)%i_ldi-1
+            il_jhalostart(:)=td_mpp%t_proc(:)%i_ldj-1
+            
+            il_ihaloend(:)=td_mpp%t_proc(:)%i_lci - td_mpp%t_proc(:)%i_lei
+            il_jhaloend(:)=td_mpp%t_proc(:)%i_lcj - td_mpp%t_proc(:)%i_lej
+
+         CASE('nooverlap')
+
+            il_ifirst(:)=td_mpp%t_proc(:)%i_impp + td_mpp%t_proc(:)%i_ldi - 1
+            il_jfirst(:)=td_mpp%t_proc(:)%i_jmpp + td_mpp%t_proc(:)%i_ldj - 1
+
+            il_ilast(:)=td_mpp%t_proc(:)%i_impp + td_mpp%t_proc(:)%i_lei - 1
+            il_jlast(:)=td_mpp%t_proc(:)%i_jmpp + td_mpp%t_proc(:)%i_lej - 1
+
+            il_ihalostart(:)=0
+            il_jhalostart(:)=0
+
+            il_ihaloend(:)=0
+            il_jhaloend(:)=0
+
+         CASE DEFAULT
+            CALL logger_fatal("MPP INIT: invalid "//&
+            &              "decomposition type.")                     
+      END SELECT
+
+      DO ji=1,td_mpp%i_nproc
+         tl_att=att_init( "DOMAIN_position_first", &
+         &                (/ il_ifirst(ji), il_jfirst(ji) /) )
+         CALL file_move_att(td_mpp%t_proc(ji), tl_att)      
+
+         tl_att=att_init( "DOMAIN_position_last", &
+         &                (/ il_ilast(ji), il_jlast(ji) /) )
+         CALL file_move_att(td_mpp%t_proc(ji), tl_att)
+
+         tl_att=att_init( "DOMAIN_halo_size_start", &
+         &                (/ il_ihalostart(ji), il_jhalostart(ji) /) )
+         CALL file_move_att( td_mpp%t_proc(ji), tl_att)               
+
+         tl_att=att_init( "DOMAIN_halo_size_end", &
+         &                (/ il_ihaloend(ji), il_jhaloend(ji) /) )
+         CALL file_move_att( td_mpp%t_proc(ji), tl_att)
+      ENDDO
+
+      DEALLOCATE( il_ifirst    )
+      DEALLOCATE( il_jfirst    )
+ 
+      DEALLOCATE( il_ilast     )
+      DEALLOCATE( il_jlast     )
+ 
+      DEALLOCATE( il_ihalostart)
+      DEALLOCATE( il_jhalostart)
+
+      DEALLOCATE( il_ihaloend  )
+      DEALLOCATE( il_jhaloend  )
+
+      !impp
+      tl_att=att_init( "SUBDOMAIN_I_left_bottom_indices", td_mpp%t_proc(:)%i_impp)
+      CALL mpp_move_att(td_mpp, tl_att)
+
+      tl_att=att_init( "SUBDOMAIN_J_left_bottom_indices", td_mpp%t_proc(:)%i_jmpp)
+      CALL mpp_move_att(td_mpp, tl_att)
+
+      ! lci
+      tl_att=att_init( "SUBDOMAIN_I_dimensions", td_mpp%t_proc(:)%i_lci)
+      CALL mpp_move_att(td_mpp, tl_att)
+
+      tl_att=att_init( "SUBDOMAIN_J_dimensions", td_mpp%t_proc(:)%i_lcj)
+      CALL mpp_move_att(td_mpp, tl_att)
+
+      ! ldi
+      tl_att=att_init( "SUBDOMAIN_I_first_indoor_indices", td_mpp%t_proc(:)%i_ldi)
+      CALL mpp_move_att(td_mpp, tl_att)
+
+      tl_att=att_init( "SUBDOMAIN_J_first_indoor_indices", td_mpp%t_proc(:)%i_ldj)
+      CALL mpp_move_att(td_mpp, tl_att)
+
+      ! lei
+      tl_att=att_init( "SUBDOMAIN_I_last_indoor_indices", td_mpp%t_proc(:)%i_lei)
+      CALL mpp_move_att(td_mpp, tl_att)
+
+      tl_att=att_init( "SUBDOMAIN_J_last_indoor_indices", td_mpp%t_proc(:)%i_lej)
+      CALL mpp_move_att(td_mpp, tl_att)         
+
+      ! clean
+      CALL att_clean(tl_att)
+
+   END SUBROUTINE mpp__compute_halo
 END MODULE mpp
 
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/multi.f90
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/multi.f90	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/multi.f90	(revision 6392)
@@ -173,4 +173,6 @@
    !> @date July, 2015 
    !> - check if variable to be read is in file
+   !> @date January, 2016
+   !> - read variable dimensions
    !>
    !> @param[in] cd_varfile   variable location information (from namelist) 
@@ -187,17 +189,19 @@
 
       ! local variable
-      CHARACTER(LEN=lc) :: cl_name
-      CHARACTER(LEN=lc) :: cl_lower
-      CHARACTER(LEN=lc) :: cl_file
-      CHARACTER(LEN=lc) :: cl_matrix
-
-      INTEGER(i4)       :: il_nvar
-      INTEGER(i4)       :: il_varid
-
-      LOGICAL           :: ll_dim
-
-      TYPE(TVAR)        :: tl_var
-
-      TYPE(TMPP)        :: tl_mpp
+      CHARACTER(LEN=lc)                :: cl_name
+      CHARACTER(LEN=lc)                :: cl_lower
+      CHARACTER(LEN=lc)                :: cl_file
+      CHARACTER(LEN=lc)                :: cl_matrix
+
+      INTEGER(i4)                      :: il_nvar
+      INTEGER(i4)                      :: il_varid
+
+      LOGICAL                          :: ll_dim
+
+      TYPE(TDIM), DIMENSION(ip_maxdim) :: tl_dim
+
+      TYPE(TVAR)                       :: tl_var
+
+      TYPE(TMPP)                       :: tl_mpp
 
       ! loop indices
@@ -216,6 +220,6 @@
 
          IF( LEN(TRIM(cl_file)) == lc )THEN
-            CALL logger_fatal("MULTI INIT: file name too long (==256)."//&
-            &  " check namelist.")
+            CALL logger_fatal("MULTI INIT: file name too long (>"//&
+            &          TRIM(fct_str(lc))//"). check namelist.")
          ENDIF
 
@@ -243,5 +247,4 @@
                   ! 
                   tl_mpp=mpp_init( file_init(TRIM(cl_file)) )
-
                   ! define variable
                   IF( TRIM(fct_lower(cl_lower)) /= 'all' )THEN
@@ -255,8 +258,14 @@
                      ENDIF
 
-                     ! clean var
+                     ! get (global) variable dimension
+                     tl_dim(jp_I)=dim_copy(tl_mpp%t_dim(jp_I))
+                     tl_dim(jp_J)=dim_copy(tl_mpp%t_dim(jp_J))
+                     tl_dim(jp_K)=dim_copy(tl_mpp%t_proc(1)%t_var(il_varid)%t_dim(jp_K))
+                     tl_dim(jp_L)=dim_copy(tl_mpp%t_proc(1)%t_var(il_varid)%t_dim(jp_L))
+
+                     ! clean all varible
                      CALL mpp_del_var(tl_mpp)
 
-                     tl_var=var_init(TRIM(cl_lower))
+                     tl_var=var_init(TRIM(cl_lower), td_dim=tl_dim(:))
 
                      ! add variable
@@ -272,5 +281,5 @@
 
                      DO jk=tl_mpp%t_proc(1)%i_nvar,1,-1
-                        
+
                         ! check if variable is dimension
                         ll_dim=.FALSE.
@@ -379,10 +388,10 @@
       ! print file
       IF( td_multi%i_nmpp /= 0 .AND. ASSOCIATED(td_multi%t_mpp) )THEN
-         WRITE(*,'(/a,i3)') 'MULTI: total number of mpp: ',&
+         WRITE(*,'(/a,i3)') 'MULTI: total number of file(s): ',&
          &  td_multi%i_nmpp
-         WRITE(*,'(6x,a,i3)') ' total number of variable: ',&
+         WRITE(*,'(6x,a,i3)') ' total number of variable(s): ',&
          &  td_multi%i_nvar
          DO ji=1,td_multi%i_nmpp
-            WRITE(*,'(3x,3a)') 'MPP FILE ',TRIM(td_multi%t_mpp(ji)%c_name),&
+            WRITE(*,'(3x,3a)') 'FILE ',TRIM(td_multi%t_mpp(ji)%c_name),&
             & ' CONTAINS'
             DO jj=1,td_multi%t_mpp(ji)%t_proc(1)%i_nvar
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/phycst.f90
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/phycst.f90	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/phycst.f90	(revision 6392)
@@ -12,4 +12,6 @@
 ! REVISION HISTORY:
 !> @date November, 2013 - Initial Version
+!> @date September, 2015
+!> - add physical constant to compute meshmask
 !
 !> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -23,16 +25,30 @@
    PUBLIC :: dp_pi      !< pi
    PUBLIC :: dp_eps     !< epsilon value
-   PUBLIC :: dp_rearth  !< earth radius (km)
+   PUBLIC :: dp_rearth  !< earth radius [m]
    PUBLIC :: dp_deg2rad !< degree to radian ratio 
    PUBLIC :: dp_rad2deg !< radian to degree ratio 
    PUBLIC :: dp_delta   !<  
+   PUBLIC :: dp_omega   !< earth rotation parameter [s-1] 
+   PUBLIC :: dp_day     !< day                                [s]
+   PUBLIC :: dp_siyea   !< sideral year                       [s]
+   PUBLIC :: dp_siday   !< sideral day                        [s]
+
+   REAL(wp), PUBLIC ::   rday = 24.*60.*60.     !: day                                [s]
+   REAL(wp), PUBLIC ::   rsiyea                 !: sideral year                       [s]
+   REAL(wp), PUBLIC ::   rsiday                 !: sideral day                        [s]
 
    REAL(dp), PARAMETER :: dp_pi = 3.14159274101257_dp
    REAL(dp), PARAMETER :: dp_eps = EPSILON(1._dp)
-   REAL(dp), PARAMETER :: dp_rearth = 6871._dp
+   REAL(dp), PARAMETER :: dp_rearth = 6371229._dp
    REAL(dp), PARAMETER :: dp_deg2rad = dp_pi/180.0
    REAL(dp), PARAMETER :: dp_rad2deg = 180.0/dp_pi
 
+   REAL(dp), PARAMETER :: dp_day = 24.*60.*60.     
+   REAL(dp), PARAMETER :: dp_siyea = 365.25_wp * dp_day * &
+      &  2._wp * dp_pi / 6.283076_dp
+   REAL(dp), PARAMETER :: dp_siday = dp_day / ( 1._wp + dp_day / dp_siyea )
+
    REAL(dp), PARAMETER :: dp_delta=1.e-6
+   REAL(dp), PARAMETER :: dp_omega= 2._dp * dp_pi / dp_siday
 END MODULE phycst
 
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/variable.f90
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/variable.f90	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/variable.f90	(revision 6392)
@@ -285,4 +285,6 @@
 !> @date July, 2015 
 !> - add subroutine var_chg_unit to change unit of output variable
+!> @date Spetember, 2015
+!> - manage useless (dummy) variable
 !
 !> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -305,4 +307,6 @@
 
    PUBLIC :: tg_varextra !< array of variable structure with extra information.
+
+   PRIVATE :: cm_dumvar  !< dummy variable array
 
    ! function and subroutine
@@ -334,4 +338,6 @@
    PUBLIC :: var_chg_extra     !< read variable namelist information, and modify extra information.
    PUBLIC :: var_check_dim     !< check variable dimension expected
+   PUBLIC :: var_get_dummy     !< fill dummy variable array
+   PUBLIC :: var_is_dummy      !< check if variable is defined as dummy variable
 
    PRIVATE :: var__init          ! initialize variable structure without array of value
@@ -445,4 +451,6 @@
                                                         !< fill when running var_def_extra() 
 
+   CHARACTER(LEN=lc), DIMENSION(ip_maxdum), SAVE :: cm_dumvar !< dummy variable
+
    INTERFACE var_init
       MODULE PROCEDURE var__init       ! initialize variable structure without array of value
@@ -6698,8 +6706,8 @@
    !> given variable name or standard name. 
    !>
-   !> @warning only variable read from file, have an id.
-   !>
    !> @author J.Paul
    !> @date November, 2013 - Initial Version
+   !> @date July, 2015
+   !> - check long name
    !
    !> @param[in] td_var       array of variable structure
@@ -6735,4 +6743,11 @@
          ELSE IF( fct_lower(td_var(ji)%c_stdname) == fct_lower(cd_name) .AND.&
          &    TRIM(fct_lower(td_var(ji)%c_stdname)) /= '' )THEN
+            
+            var_get_id=td_var(ji)%i_id
+            EXIT
+
+         ! look for variable long name
+         ELSE IF( fct_lower(td_var(ji)%c_longname) == fct_lower(cd_name) .AND.&
+         &    TRIM(fct_lower(td_var(ji)%c_longname)) /= '' )THEN
             
             var_get_id=td_var(ji)%i_id
@@ -6775,6 +6790,7 @@
       IF( ASSOCIATED(td_var%d_value) )THEN
 
-         CALL logger_trace( "VAR GET MASK: create mask from variable "//&
-         &               TRIM(td_var%c_name) )
+         CALL logger_debug( "VAR GET MASK: create mask from variable "//&
+         &               TRIM(td_var%c_name)//", FillValue ="//&
+         &               TRIM(fct_str(td_var%d_fill)))
          var_get_mask(:,:,:)=1
          WHERE( td_var%d_value(:,:,:,1) == td_var%d_fill )
@@ -7279,8 +7295,12 @@
 
       ! local variable
+      CHARACTER(LEN=lc) :: cl_tmp
+
       INTEGER(i4)       :: il_ind
+      
       TYPE(TATT)        :: tl_att
 
       ! loop indices
+      INTEGER(i4)       :: ji
       !----------------------------------------------------------------
 
@@ -7335,6 +7355,14 @@
                td_var%c_axis=TRIM(tg_varextra(il_ind)%c_axis)
                ! create attibute
-               tl_att=att_init('axis',TRIM(td_var%c_axis))
-               CALL var_move_att(td_var, tl_att)               
+               IF( TRIM(fct_upper(td_var%c_name)) == TRIM(td_var%c_axis) )THEN
+                  tl_att=att_init('axis',TRIM(td_var%c_axis))
+               ELSE
+                  cl_tmp=""
+                  DO ji=LEN(TRIM(td_var%c_axis)),1,-1
+                     cl_tmp=TRIM(cl_tmp)//" "//TRIM(td_var%c_axis(ji:ji))
+                  ENDDO
+                  tl_att=att_init('associate',TRIM(ADJUSTL(cl_tmp)))
+               ENDIF
+               CALL var_move_att(td_var, tl_att)
             ENDIF
 
@@ -7402,4 +7430,8 @@
             ENDIF
 
+         ELSE
+            CALL logger_warn("VAR GET EXTRA: no extra information on "//&
+               &  "variable "//TRIM(td_var%c_name)//". you should define it"//&
+               &  " (see variable.cfg).")
          ENDIF
 
@@ -7425,4 +7457,6 @@
    !> - change way to get information in namelist, 
    !> value follows string "min ="
+   !> @date Feb, 2016
+   !> - check character just after keyword
    !
    !> @param[in] cd_name      variable name
@@ -7447,4 +7481,5 @@
       ! loop indices
       INTEGER(i4) :: ji
+      INTEGER(i4) :: jj
       !----------------------------------------------------------------
       ! init
@@ -7457,6 +7492,11 @@
          il_ind=INDEX(TRIM(cl_tmp),'min')
          IF( il_ind /= 0 )THEN
-            cl_min=fct_split(cl_tmp,2,'=')
-            EXIT
+            ! check character just after
+            jj=il_ind+LEN('min')
+            IF(  TRIM(cl_tmp(jj:jj)) == ' ' .OR. &
+            &    TRIM(cl_tmp(jj:jj)) == '=' )THEN
+               cl_min=fct_split(cl_tmp,2,'=')
+               EXIT
+            ENDIF
          ENDIF
          ji=ji+1
@@ -7470,6 +7510,7 @@
             &  TRIM(fct_str(var__get_min))//" for variable "//TRIM(cd_name) )
          ELSE
-            CALL logger_error("VAR GET MIN: invalid minimum value for "//&
-            &  "variable "//TRIM(cd_name)//". check namelist." )
+            CALL logger_error("VAR GET MIN: invalid minimum value ("//&
+               & TRIM(cl_min)//") for variable "//TRIM(cd_name)//&
+               & ". check namelist." )
          ENDIF
       ENDIF
@@ -7489,4 +7530,6 @@
    !> - change way to get information in namelist, 
    !> value follows string "max ="
+   !> @date Feb, 2016
+   !> - check character just after keyword
    !
    !> @param[in] cd_name      variable name
@@ -7511,4 +7554,5 @@
       ! loop indices
       INTEGER(i4) :: ji
+      INTEGER(i4) :: jj
       !----------------------------------------------------------------
       ! init
@@ -7521,6 +7565,11 @@
          il_ind=INDEX(TRIM(cl_tmp),'max')
          IF( il_ind /= 0 )THEN
-            cl_max=fct_split(cl_tmp,2,'=')
-            EXIT
+            ! check character just after
+            jj=il_ind+LEN('max')
+            IF(  TRIM(cl_tmp(jj:jj)) == ' ' .OR. &
+            &    TRIM(cl_tmp(jj:jj)) == '=' )THEN
+               cl_max=fct_split(cl_tmp,2,'=')
+               EXIT
+            ENDIF
          ENDIF
          ji=ji+1
@@ -7550,4 +7599,6 @@
    !> @author J.Paul
    !> @date June, 2015 - Initial Version
+   !> @date Feb, 2016
+   !> - check character just after keyword
    !
    !> @param[in] cd_name      variable name
@@ -7574,4 +7625,5 @@
       ! loop indices
       INTEGER(i4) :: ji
+      INTEGER(i4) :: jj
       !----------------------------------------------------------------
       ! init
@@ -7584,6 +7636,11 @@
          il_ind=INDEX(TRIM(cl_tmp),'unf')
          IF( il_ind /= 0 )THEN
-            cl_unf=fct_split(cl_tmp,2,'=')
-            EXIT
+            ! check character just after
+            jj=il_ind+LEN('unf')
+            IF(  TRIM(cl_tmp(jj:jj)) == ' ' .OR. &
+            &    TRIM(cl_tmp(jj:jj)) == '=' )THEN
+               cl_unf=fct_split(cl_tmp,2,'=')
+               EXIT
+            ENDIF
          ENDIF
          ji=ji+1
@@ -7626,4 +7683,6 @@
    !> - change way to get information in namelist, 
    !> value follows string "int ="
+   !> @date Feb, 2016
+   !> - check character just after keyword
    !
    !> @param[in] cd_name      variable name
@@ -7663,6 +7722,11 @@
          il_ind=INDEX(TRIM(cl_tmp),'int')
          IF( il_ind /= 0 )THEN
-            cl_int=fct_split(cl_tmp,2,'=')
-            EXIT
+            ! check character just after
+            jj=il_ind+LEN('int')
+            IF(  TRIM(cl_tmp(jj:jj)) == ' ' .OR. &
+            &    TRIM(cl_tmp(jj:jj)) == '=' )THEN
+               cl_int=fct_split(cl_tmp,2,'=')
+               EXIT
+            ENDIF
          ENDIF
          ji=ji+1
@@ -7746,4 +7810,6 @@
    !> - change way to get information in namelist, 
    !> value follows string "ext ="
+   !> @date Feb, 2016
+   !> - check character just after keyword
    !
    !> @param[in] cd_name      variable name
@@ -7778,6 +7844,11 @@
          il_ind=INDEX(TRIM(cl_tmp),'ext')
          IF( il_ind /= 0 )THEN
-            cl_ext=fct_split(cl_tmp,2,'=')
-            EXIT
+            ! check character just after
+            jj=il_ind+LEN('ext')
+            IF(  TRIM(cl_tmp(jj:jj)) == ' ' .OR. &
+            &    TRIM(cl_tmp(jj:jj)) == '=' )THEN
+               cl_ext=fct_split(cl_tmp,2,'=')
+               EXIT
+            ENDIF
          ENDIF
          ji=ji+1
@@ -7822,4 +7893,6 @@
    !> - change way to get information in namelist, 
    !> value follows string "flt ="
+   !> @date Feb, 2016
+   !> - check character just after keyword
    !>
    !> @param[in] cd_name      variable name
@@ -7852,6 +7925,11 @@
          il_ind=INDEX(TRIM(cl_tmp),'flt')
          IF( il_ind /= 0 )THEN
-            cl_flt=fct_split(cl_tmp,2,'=')
-            EXIT
+            ! check character just after
+            jj=il_ind+LEN('flt')
+            IF(  TRIM(cl_tmp(jj:jj)) == ' ' .OR. &
+            &    TRIM(cl_tmp(jj:jj)) == '=' )THEN
+               cl_flt=fct_split(cl_tmp,2,'=')
+               EXIT
+            ENDIF
          ENDIF
          ji=ji+1
@@ -7925,4 +8003,6 @@
    !> @author J.Paul
    !> @date June, 2015 - Initial Version
+   !> @date Feb, 2016
+   !> - check character just after keyword
    !
    !> @param[in] cd_name      variable name
@@ -7946,4 +8026,5 @@
       ! loop indices
       INTEGER(i4) :: ji
+      INTEGER(i4) :: jj
       !----------------------------------------------------------------
 
@@ -7955,6 +8036,11 @@
          il_ind=INDEX(TRIM(cl_tmp),'unt')
          IF( il_ind /= 0 )THEN
-            var__get_unt=fct_split(cl_tmp,2,'=')
-            EXIT
+            ! check character just after
+            jj=il_ind+LEN('unt')
+            IF(  TRIM(cl_tmp(jj:jj)) == ' ' .OR. &
+            &    TRIM(cl_tmp(jj:jj)) == '=' )THEN
+               var__get_unt=fct_split(cl_tmp,2,'=')
+               EXIT
+            ENDIF
          ENDIF
          ji=ji+1
@@ -8101,8 +8187,8 @@
 
             !- change scale factor and offset to avoid mistake
-            tl_att=att_init('scale_factor',1)
+            tl_att=att_init('scale_factor',1._dp)
             CALL var_move_att(td_var, tl_att)
 
-            tl_att=att_init('add_offset',0)
+            tl_att=att_init('add_offset',0._dp)
             CALL var_move_att(td_var, tl_att)
          ENDIF
@@ -8356,4 +8442,96 @@
 
    END FUNCTION var_to_date
+   !-------------------------------------------------------------------
+   !> @brief This subroutine fill dummy variable array
+   !
+   !> @author J.Paul
+   !> @date September, 2015 - Initial Version
+   !
+   !> @param[in] cd_dummy dummy configuration file
+   !-------------------------------------------------------------------
+   SUBROUTINE var_get_dummy( cd_dummy )
+      IMPLICIT NONE
+      ! Argument
+      CHARACTER(LEN=*), INTENT(IN) :: cd_dummy
+
+      ! local variable
+      INTEGER(i4)   :: il_fileid
+      INTEGER(i4)   :: il_status
+
+      LOGICAL       :: ll_exist
+
+      ! loop indices
+      ! namelist
+      CHARACTER(LEN=lc), DIMENSION(ip_maxdum) :: cn_dumvar
+      CHARACTER(LEN=lc), DIMENSION(ip_maxdum) :: cn_dumdim
+      CHARACTER(LEN=lc), DIMENSION(ip_maxdum) :: cn_dumatt
+
+      !----------------------------------------------------------------
+      NAMELIST /namdum/ &   !< dummy namelist
+      &  cn_dumvar, &       !< variable  name
+      &  cn_dumdim, &       !< dimension name
+      &  cn_dumatt          !< attribute name
+      !----------------------------------------------------------------
+
+      ! init
+      cm_dumvar(:)=''
+
+      ! read namelist
+      INQUIRE(FILE=TRIM(cd_dummy), EXIST=ll_exist)
+      IF( ll_exist )THEN
+    
+         il_fileid=fct_getunit()
+   
+         OPEN( il_fileid, FILE=TRIM(cd_dummy), &
+         &                FORM='FORMATTED',       &
+         &                ACCESS='SEQUENTIAL',    &
+         &                STATUS='OLD',           &
+         &                ACTION='READ',          &
+         &                IOSTAT=il_status)
+         CALL fct_err(il_status)
+         IF( il_status /= 0 )THEN
+            CALL logger_fatal("DIM GET DUMMY: opening "//TRIM(cd_dummy))
+         ENDIF
+   
+         READ( il_fileid, NML = namdum )
+         cm_dumvar(:)=cn_dumvar(:)
+
+         CLOSE( il_fileid )
+
+      ENDIF
+   
+   END SUBROUTINE var_get_dummy
+   !-------------------------------------------------------------------
+   !> @brief This function check if variable is defined as dummy variable
+   !> in configuraton file
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - Initial Version
+   !
+   !> @param[in] td_var variable structure
+   !> @return true if variable is dummy variable 
+   !-------------------------------------------------------------------
+   FUNCTION var_is_dummy(td_var)
+      IMPLICIT NONE
+
+      ! Argument      
+      TYPE(TVAR), INTENT(IN) :: td_var
+      
+      ! function
+      LOGICAL :: var_is_dummy
+      
+      ! loop indices
+      INTEGER(i4) :: ji
+      !----------------------------------------------------------------
+
+      var_is_dummy=.FALSE.
+      DO ji=1,ip_maxdum
+         IF( fct_lower(td_var%c_name) == fct_lower(cm_dumvar(ji)) )THEN
+            var_is_dummy=.TRUE.
+            EXIT
+         ENDIF
+      ENDDO
+
+   END FUNCTION var_is_dummy
 END MODULE var
 
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/vgrid.f90
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/vgrid.f90	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/src/vgrid.f90	(revision 6392)
@@ -291,4 +291,12 @@
    END SUBROUTINE vgrid_zgr_z
    !-------------------------------------------------------------------
+   !> @brief This subroutine
+   !>
+   !> @todo add subroutine description
+   !>
+   !> @param[inout] dd_bathy
+   !> @param[in] dd_gdepw
+   !> @param[in] dd_hmin
+   !> @param[in] dd_fill
    !-------------------------------------------------------------------
    SUBROUTINE vgrid_zgr_bat( dd_bathy, dd_gdepw, dd_hmin, dd_fill )
@@ -371,5 +379,5 @@
    !>         - gdept, gdepw and e3 are positives
    !>         - gdept_ps, gdepw_ps and e3_ps are positives
-   !
+   !>
    !> @author A. Bozec, G. Madec
    !> @date February, 2009 - F90: Free form and module
@@ -386,4 +394,5 @@
    !> @param[in] dd_e3zps_min
    !> @param[in] dd_e3zps_rat
+   !> @param[in] dd_fill
    !-------------------------------------------------------------------
    SUBROUTINE vgrid_zgr_zps( id_mbathy, dd_bathy, id_jpkmax, &
@@ -495,5 +504,5 @@
    !> ** Action  : - update mbathy: level bathymetry (in level index)
    !>              - update bathy : meter bathymetry (in meters)
-
+   !>
    !> @author G.Madec
    !> @date Marsh, 2008 - Original code
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/templates/create_bathy.nam
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/templates/create_bathy.nam	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/templates/create_bathy.nam	(revision 6392)
@@ -1,4 +1,4 @@
 &namlog
-   cn_logfile="bathy_out.log"
+   cn_logfile=
    cn_verbosity=
    in_maxerror=
@@ -6,5 +6,6 @@
 
 &namcfg
-   cn_varcfg="./cfg/variable.cfg"
+   cn_varcfg=
+   cn_dumcfg=
 /
 
@@ -16,4 +17,6 @@
 &namfin
    cn_coord1=
+   in_perio1=
+   ln_fillclosed=
 /
 
@@ -29,4 +32,4 @@
 
 &namout
-   cn_fileout="bathy_out.nc"      
+   cn_fileout=
 /
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/templates/create_boundary.nam
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/templates/create_boundary.nam	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/templates/create_boundary.nam	(revision 6392)
@@ -1,4 +1,4 @@
 &namlog
-   cn_logfile="boundary.log"
+   cn_logfile=
    cn_verbosity=
    in_maxerror =
@@ -6,5 +6,6 @@
 
 &namcfg
-   cn_varcfg="./cfg/variable.cfg"
+   cn_varcfg=
+   cn_dumcfg=
 /
 
@@ -41,6 +42,6 @@
 
 &namvar
+   cn_varfile=
    cn_varinfo=
-   cn_varfile=
 /
 
@@ -63,5 +64,5 @@
 
 &namout
-   cn_fileout="boundary_out.nc"      
+   cn_fileout=
    dn_dayofs=
    ln_extrap=
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/templates/create_coord.nam
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/templates/create_coord.nam	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/templates/create_coord.nam	(revision 6392)
@@ -1,4 +1,4 @@
 &namlog
-   cn_logfile="coord_out.log"
+   cn_logfile=
    cn_verbosity=
    in_maxerror=
@@ -6,5 +6,6 @@
 
 &namcfg
-   cn_varcfg="./cfg/variable.cfg"
+   cn_varcfg=
+   cn_dumcfg=
 /
 
@@ -29,5 +30,5 @@
 
 &namout
-   cn_fileout="coord_out.nc"
+   cn_fileout=
 /
 
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/templates/create_restart.nam
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/templates/create_restart.nam	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/templates/create_restart.nam	(revision 6392)
@@ -1,10 +1,11 @@
 &namlog
-   cn_logfile="restart_out.log"
+   cn_logfile=
    cn_verbosity=
-   in_maxerror =
+   in_maxerror=
 /
 
 &namcfg
-   cn_varcfg="./cfg/variable.cfg"
+   cn_varcfg=
+   cn_dumcfg=
 /
 
@@ -41,6 +42,6 @@
 
 &namvar
+   cn_varfile=
    cn_varinfo=
-   cn_varfile=
 /
 
@@ -51,7 +52,7 @@
 
 &namout
-   cn_fileout="restart_out.nc"      
+   cn_fileout=
    ln_extrap=
-   in_nipro=
+   in_niproc=
    in_njproc=
    in_nproc=
Index: branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/templates/merge_bathy.nam
===================================================================
--- branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/templates/merge_bathy.nam	(revision 6384)
+++ branches/2015/nemo_v3_6_STABLE/NEMOGCM/TOOLS/SIREN/templates/merge_bathy.nam	(revision 6392)
@@ -1,10 +1,11 @@
 &namlog
-   cn_logfile="merge_out.log"
+   cn_logfile=
    cn_verbosity=
-   in_maxerror =
+   in_maxerror=
 /
 
 &namcfg
-   cn_varcfg="./cfg/variable.cfg"
+   cn_varcfg=
+   cn_dumcfg=
 /
 
@@ -17,8 +18,4 @@
    cn_bathy1=
    in_perio1=
-/
-
-&namvar
-   cn_varinfo=
 /
 
@@ -41,4 +38,4 @@
 
 &namout
-   cn_fileout="merge_out.nc"      
+   cn_fileout=
 /
