Index: /XMLIO_SERVER/trunk/src/IOSERVER/mod_interface_ioipsl.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/IOSERVER/mod_interface_ioipsl.f90	(revision 28)
+++ /XMLIO_SERVER/trunk/src/IOSERVER/mod_interface_ioipsl.f90	(revision 29)
@@ -38,4 +38,5 @@
     TYPE(field),POINTER    :: pt_field
     TYPE(grid),POINTER     :: pt_grid
+    TYPE(zoom),POINTER     :: pt_zoom
     TYPE(axis),POINTER     :: pt_axis
     TYPE(domain),POINTER   :: pt_domain
@@ -48,4 +49,5 @@
     INTEGER :: ioipsl_domain_id
     INTEGER :: i,j
+    CHARACTER(LEN=20) :: direction
      
     CALL xmlio__close_definition 
@@ -61,40 +63,72 @@
       pt_grid=>pt_file_dep%grids%at(1)%pt
       pt_domain=>pt_grid%domain
-      CALL set_ioipsl_domain_id(pt_grid,nb_server,server_rank,ioipsl_domain_id)
-      CALL histbeg(TRIM(pt_file%name),pt_domain%ni,pt_domain%lon, pt_domain%nj, pt_domain%lat,  &
-                    1, pt_domain%ni, 1, pt_domain%nj,initial_timestep, initial_date, timestep_value,  &
-                   ioipsl_hori_id, ioipsl_file_id,domain_id=ioipsl_domain_id)                                              
-      
-      DO j=1,pt_file_dep%axis%size
-        pt_axis=>pt_file_dep%axis%at(j)%pt
-        CALL sorted_list__find(axis_id,hash(Pt_axis%name),ioipsl_axis_id,found)
-        IF (.NOT. found) THEN
-          IF (TRIM(pt_axis%name) /= "none") THEN
-            CALL histvert(ioipsl_file_id, TRIM(pt_axis%name),TRIM(pt_axis%description),    &
-                         TRIM(pt_axis%unit), pt_axis%size,pt_axis%values, ioipsl_axis_id)
-            CALL sorted_list__add(axis_id,hash(Pt_axis%name),ioipsl_axis_id)
+      pt_zoom=>pt_file_dep%zooms%at(1)%pt
+!      print *,TRIM(pt_file%name),' ',TRIM(pt_zoom%id)
+!      print*,'Global --->',pt_zoom%ni_glo,pt_zoom%nj_glo,pt_zoom%ibegin_glo,pt_zoom%jbegin_glo
+!      print*,'Local  --->',pt_zoom%ni_loc,pt_zoom%nj_loc,pt_zoom%ibegin_loc,pt_zoom%jbegin_loc
+      
+      IF (pt_zoom%ni_loc*pt_zoom%nj_loc > 0) THEN
+        
+        IF ( (pt_zoom%ni_loc == pt_zoom%ni_glo) .AND. (pt_zoom%nj_loc == pt_zoom%nj_glo) ) THEN 
+
+          CALL histbeg(TRIM(pt_file%name),pt_domain%ni,pt_domain%lon, pt_domain%nj, pt_domain%lat,  &
+                     pt_zoom%ibegin_loc, pt_zoom%ni_loc,pt_zoom%jbegin_loc,pt_zoom%nj_loc,        &                                            &
+                     initial_timestep, initial_date, timestep_value,                              &
+                     ioipsl_hori_id, ioipsl_file_id)
+         ELSE                                              
+
+          CALL set_ioipsl_domain_id(pt_grid,nb_server,server_rank,ioipsl_domain_id)
+          CALL histbeg(TRIM(pt_file%name),pt_domain%ni,pt_domain%lon, pt_domain%nj, pt_domain%lat,  &
+                     pt_zoom%ibegin_loc, pt_zoom%ni_loc,pt_zoom%jbegin_loc,pt_zoom%nj_loc,        &                                            &
+                     initial_timestep, initial_date, timestep_value,                              &
+                     ioipsl_hori_id, ioipsl_file_id,domain_id=ioipsl_domain_id)                                              
+       
+         ENDIF
+        
+      
+        DO j=1,pt_file_dep%axis%size
+          pt_axis=>pt_file_dep%axis%at(j)%pt
+          CALL sorted_list__find(axis_id,hash(Pt_axis%name),ioipsl_axis_id,found)
+          IF (.NOT. found) THEN
+            IF (TRIM(pt_axis%name) /= "none") THEN
+              
+              IF (pt_axis%has_positive) THEN 
+                IF (pt_axis%positive) THEN
+                  direction="up"
+                ELSE
+                  direction="down"
+                ENDIF
+              ELSE
+                direction='unknown'
+              ENDIF
+
+              CALL histvert(ioipsl_file_id, TRIM(pt_axis%name),TRIM(pt_axis%description),    &
+                           TRIM(pt_axis%unit), pt_axis%size,pt_axis%values, ioipsl_axis_id,  &
+                           pdirect=direction)
+              CALL sorted_list__add(axis_id,hash(Pt_axis%name),ioipsl_axis_id)
+            ENDIF
           ENDIF
-        ENDIF
-      ENDDO
-      
-      DO j=1,pt_file_dep%fields%size
-        pt_field=>pt_file_dep%fields%at(j)%pt
-        IF (pt_field%axis%name=="none") THEN
-          pt_field%internal(id_file)=ioipsl_file_id
-          CALL histdef(ioipsl_file_id, TRIM(pt_field%name), pt_field%description,            &
-                    &  pt_field%unit, pt_field%grid%domain%ni, pt_field%grid%domain%nj,      &
-                    &  ioipsl_hori_id, 1, 1, 1, -99, 32, pt_field%operation,                 &
-                    &  real(pt_field%freq_op), real(pt_file%output_freq) )
-        ELSE
-          pt_field%internal(id_file)=ioipsl_file_id
-          CALL sorted_list__find(axis_id,hash(Pt_field%axis%name),ioipsl_axis_id,found)
-          CALL histdef(ioipsl_file_id, TRIM(pt_field%name), pt_field%description,          &
-                     & pt_field%unit, pt_field%grid%domain%ni, pt_field%grid%domain%nj,    &
-                     & ioipsl_hori_id, pt_field%axis%size, 1, pt_field%axis%size,          &
-                     & ioipsl_axis_id, 32, pt_field%operation, real(pt_field%freq_op),     &
-                     & real(pt_file%output_freq) )
-        ENDIF
-      ENDDO
-      CALL histend(ioipsl_file_id)
+        ENDDO
+        
+        DO j=1,pt_file_dep%fields%size
+          pt_field=>pt_file_dep%fields%at(j)%pt
+          IF (pt_field%axis%name=="none") THEN
+            pt_field%internal(id_file)=ioipsl_file_id
+            CALL histdef(ioipsl_file_id, TRIM(pt_field%name), pt_field%description,            &
+                      &  pt_field%unit, pt_field%grid%domain%ni, pt_field%grid%domain%nj,      &
+                      &  ioipsl_hori_id, 1, 1, 1, -99, 32, pt_field%operation,                 &
+                      &  real(pt_field%freq_op), real(pt_file%output_freq) )
+          ELSE
+            pt_field%internal(id_file)=ioipsl_file_id
+            CALL sorted_list__find(axis_id,hash(Pt_field%axis%name),ioipsl_axis_id,found)
+            CALL histdef(ioipsl_file_id, TRIM(pt_field%name), pt_field%description,          &
+                       & pt_field%unit, pt_field%grid%domain%ni, pt_field%grid%domain%nj,    &
+                       & ioipsl_hori_id, pt_field%axis%size, 1, pt_field%axis%size,          &
+                       & ioipsl_axis_id, 32, pt_field%operation, real(pt_field%freq_op),     &
+                       & real(pt_file%output_freq) )
+          ENDIF
+        ENDDO
+        CALL histend(ioipsl_file_id)
+      ENDIF
       CALL sorted_list__delete(axis_id)
     ENDDO
@@ -128,6 +162,8 @@
        DO i=1,pt_field_base%field_out%size
          pt_field=>pt_field_base%field_out%at(i)%pt%field
-         ioipsl_file_id=pt_field%internal(id_file)
-         CALL histwrite(ioipsl_file_id, TRIM(pt_field%name), timestep_number, var, size(var), nindex)
+         IF ( pt_field%zoom%ni_loc * pt_field%zoom%nj_loc > 0) THEN           
+           ioipsl_file_id=pt_field%internal(id_file)
+           CALL histwrite(ioipsl_file_id, TRIM(pt_field%name), timestep_number, var, size(var), nindex)
+         ENDIF
        ENDDO
      ENDIF
@@ -158,6 +194,8 @@
        DO i=1,pt_field_base%field_out%size
          pt_field=>pt_field_base%field_out%at(i)%pt%field
-         ioipsl_file_id=pt_field%internal(id_file)
-         CALL histwrite(ioipsl_file_id, TRIM(pt_field%name), timestep_number, var, size(var), nindex)
+         IF ( pt_field%zoom%ni_loc * pt_field%zoom%nj_loc > 0) THEN           
+           ioipsl_file_id=pt_field%internal(id_file)
+           CALL histwrite(ioipsl_file_id, TRIM(pt_field%name), timestep_number, var, size(var), nindex)
+         ENDIF
        ENDDO
      ENDIF
Index: /XMLIO_SERVER/trunk/src/XMLIO/create_template
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/create_template	(revision 28)
+++ /XMLIO_SERVER/trunk/src/XMLIO/create_template	(revision 29)
@@ -23,2 +23,3 @@
 template field_out
 template context
+template zoom
Index: /XMLIO_SERVER/trunk/src/XMLIO/mod_axis.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/mod_axis.f90	(revision 28)
+++ /XMLIO_SERVER/trunk/src/XMLIO/mod_axis.f90	(revision 29)
@@ -18,4 +18,6 @@
     CHARACTER(len=str_len)      :: unit
     LOGICAL                     :: has_unit
+    LOGICAL                     :: positive
+    LOGICAL                     :: has_positive
     REAL, DIMENSION(:), POINTER :: values
     LOGICAL                     :: has_values
@@ -74,5 +76,5 @@
    INTEGER                       :: Pos
    
-   pt_axis%has_id         = .FALSE.
+   pt_axis%has_id          = .FALSE.
    pt_axis%has_name        = .FALSE.
    pt_axis%has_size        = .FALSE.
@@ -80,5 +82,6 @@
    pt_axis%has_unit        = .FALSE.
    pt_axis%has_values      = .FALSE.
-   
+   pt_axis%has_positive    = .FALSE. 
+     
    IF (PRESENT(Id)) THEN
      Pt_axis%id=TRIM(ADJUSTL(Id))
@@ -90,5 +93,5 @@
  END SUBROUTINE axis__new
 
-  SUBROUTINE axis__set(pt_axis, name, description, unit, a_size, values)
+  SUBROUTINE axis__set(pt_axis, name, description, unit, a_size, values, positive)
   IMPLICIT NONE
     TYPE(axis), POINTER         :: pt_axis
@@ -98,4 +101,5 @@
     INTEGER           ,OPTIONAL :: a_size
     REAL, DIMENSION(:),OPTIONAL :: values
+    LOGICAL           ,OPTIONAL :: positive
 
     IF (PRESENT(name)) THEN
@@ -126,4 +130,9 @@
     ENDIF
 
+    IF (PRESENT(positive)) then
+        pt_axis%positive=positive
+        pt_axis%has_positive = .TRUE.
+    ENDIF
+
   END SUBROUTINE axis__set
 
@@ -167,4 +176,10 @@
     ELSE
       PRINT *,"values undefined"
+    ENDIF
+
+    IF (pt_axis%has_positive) THEN
+      PRINT *,"positive = ",pt_axis%positive
+    ELSE
+      PRINT *,"positive undefined"
     ENDIF
 
@@ -224,4 +239,14 @@
     ELSE
         pt_axis_out%has_values=.FALSE.
+    ENDIF
+
+    IF (pt_axis_in%has_positive) THEN
+        pt_axis_out%positive=pt_axis_in%positive
+        pt_axis_out%has_positive=.TRUE.
+    ELSE IF ( pt_axis_default%has_positive ) THEN
+        pt_axis_out%positive=pt_axis_default%positive
+        pt_axis_out%has_positive=.TRUE.
+    ELSE
+        pt_axis_out%has_positive=.FALSE.
     ENDIF
     
Index: /XMLIO_SERVER/trunk/src/XMLIO/mod_context.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/mod_context.f90	(revision 28)
+++ /XMLIO_SERVER/trunk/src/XMLIO/mod_context.f90	(revision 29)
@@ -9,4 +9,5 @@
   USE mod_file_definition
   USE mod_grid
+  USE mod_zoom
   USE mod_grid_group
   USE mod_grid_definition
@@ -38,4 +39,6 @@
     TYPE(vector_grid),POINTER         :: grid__grid_Ids
     TYPE(sorted_list),POINTER         :: grid__Ids 
+    TYPE(vector_zoom),POINTER         :: zoom__zoom_Ids
+    TYPE(sorted_list),POINTER         :: zoom__Ids 
     TYPE(vector_grid_group),POINTER   :: grid_group__grid_group_Ids
     TYPE(sorted_list),POINTER         :: grid_group__Ids 
@@ -125,4 +128,6 @@
         ALLOCATE(pt_context%grid__grid_Ids)
         ALLOCATE(pt_context%grid__Ids) 
+        ALLOCATE(pt_context%zoom__zoom_Ids)
+        ALLOCATE(pt_context%zoom__Ids) 
         ALLOCATE(pt_context%grid_group__grid_group_Ids)
         ALLOCATE(pt_context%grid_group__Ids) 
@@ -156,4 +161,6 @@
         CALL grid_definition__Init
 
+        CALL zoom__init
+
         CALL file__init
         CALL file_group__Init
@@ -210,4 +217,5 @@
       CALL file_definition__swap_context(Pt_context%file_definition__file_definition) 
       CALL grid__swap_context(pt_context%grid__grid_Ids,pt_context%grid__Ids) 
+      CALL zoom__swap_context(pt_context%zoom__zoom_Ids,pt_context%zoom__Ids) 
       CALL grid_group__swap_context(pt_context%grid_group__grid_group_Ids,pt_context%grid_group__Ids) 
       CALL grid_definition__swap_context(pt_context%grid_definition__grid_definition)
Index: /XMLIO_SERVER/trunk/src/XMLIO/mod_dependency.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/mod_dependency.f90	(revision 28)
+++ /XMLIO_SERVER/trunk/src/XMLIO/mod_dependency.f90	(revision 29)
@@ -5,4 +5,5 @@
 USE mod_axis
 USE mod_sorted_list
+USE mod_zoom
 
 TYPE file_dep
@@ -11,4 +12,5 @@
   TYPE(vector_field),POINTER   :: fields
   TYPE(vector_grid),POINTER    :: grids
+  TYPE(vector_zoom),POINTER    :: zooms
   TYPE(vector_axis),POINTER    :: axis
 END TYPE file_dep
@@ -26,4 +28,5 @@
   TYPE(axis),  POINTER  :: axis
   TYPE(grid),  POINTER  :: grid
+  TYPE(zoom),  POINTER  :: zoom
 END TYPE field_out
 
@@ -82,4 +85,5 @@
     TYPE (sorted_list),POINTER         :: sorted_axis
     TYPE (sorted_list),POINTER         :: sorted_grid
+    TYPE (sorted_list),POINTER         :: sorted_zoom
     INTEGER                            :: i
     INTEGER                            :: j
@@ -87,4 +91,5 @@
     ALLOCATE(sorted_axis)
     ALLOCATE(sorted_grid)
+    ALLOCATE(sorted_zoom)
     
     IF (PRESENT(Pt_file_group)) THEN
@@ -106,4 +111,5 @@
         ALLOCATE(Pt_file_dep%fields)
         ALLOCATE(Pt_file_dep%grids)
+        ALLOCATE(Pt_file_dep%zooms)
         ALLOCATE(Pt_file_dep%axis)
         pt_file_dep%file=>pt_file
@@ -111,7 +117,9 @@
         CALL vector_field__new(Pt_file_dep%fields)
         CALL vector_grid__new(Pt_file_dep%grids)
+        CALL vector_zoom__new(Pt_file_dep%zooms)
         CALL vector_axis__new(Pt_file_dep%axis)
         CALL sorted_list__new(sorted_axis)
         CALL sorted_list__new(sorted_grid)
+        CALL sorted_list__new(sorted_zoom)
         
         CALL Treat_field_group(pt_file%field_list)
@@ -119,4 +127,5 @@
         CALL sorted_list__delete(sorted_axis)
         CALL sorted_list__delete(sorted_grid)
+        CALL sorted_list__delete(sorted_zoom)
       ENDIF
     ENDDO
@@ -152,4 +161,12 @@
               CALL vector_grid__set_new(pt_file_dep%grids,Pt_field%grid,pos)
               CALL sorted_list__add(sorted_grid,hash(Pt_field%grid%id),pos)
+            ENDIF
+          ENDIF
+
+          IF (Pt_field%has_zoom) THEN
+            CALL sorted_list__find(sorted_zoom,hash(Pt_field%zoom%id),pos,found)
+            IF (.NOT. found) THEN 
+              CALL vector_zoom__set_new(pt_file_dep%zooms,Pt_field%zoom,pos)
+              CALL sorted_list__add(sorted_zoom,hash(Pt_field%zoom%id),pos)
             ENDIF
           ENDIF
@@ -185,4 +202,5 @@
         pt_field_out%axis=>pt_field_out%field%axis
         pt_field_out%grid=>pt_field_out%field%grid
+        pt_field_out%zoom=>pt_field_out%field%zoom
       ENDDO
     ENDDO
Index: /XMLIO_SERVER/trunk/src/XMLIO/mod_domain.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/mod_domain.f90	(revision 28)
+++ /XMLIO_SERVER/trunk/src/XMLIO/mod_domain.f90	(revision 29)
@@ -1,5 +1,4 @@
 MODULE mod_domain
    USE mod_xmlio_parameters
-
    INTEGER, PARAMETER :: box=1
    INTEGER, PARAMETER :: orange=2
Index: /XMLIO_SERVER/trunk/src/XMLIO/mod_field.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/mod_field.f90	(revision 28)
+++ /XMLIO_SERVER/trunk/src/XMLIO/mod_field.f90	(revision 29)
@@ -5,5 +5,6 @@
   USE mod_axis
   USE mod_grid
-    
+  USE mod_zoom
+   
   IMPLICIT NONE
 
@@ -25,4 +26,6 @@
     CHARACTER(len=str_len)         :: grid_ref
     LOGICAL                        :: has_grid_ref
+    CHARACTER(len=str_len)         :: zoom_ref
+    LOGICAL                        :: has_zoom_ref
     INTEGER                        :: level
     LOGICAL                        :: has_level
@@ -40,4 +43,6 @@
     TYPE(grid),POINTER             :: grid
     LOGICAL                        :: has_grid
+    TYPE(zoom),POINTER             :: zoom
+    LOGICAL                        :: has_zoom
     INTEGER                        :: internal(internal_field)
     
@@ -107,4 +112,5 @@
    pt_field%has_axis_ref = .FALSE.
    pt_field%has_grid_ref = .FALSE.
+   pt_field%has_zoom_ref = .FALSE.
    pt_field%has_prec = .FALSE.
    pt_field%has_level = .FALSE. 
@@ -115,4 +121,5 @@
    Pt_field%has_axis=.FALSE.
    Pt_field%has_grid=.FALSE.
+   Pt_field%has_zoom=.FALSE.
       
    IF (PRESENT(Id)) THEN
@@ -126,5 +133,5 @@
 
 
- SUBROUTINE field__set(p_field, name, ref, description, unit, operation, freq_op, axis_ref, grid_ref, prec, level, enabled)
+ SUBROUTINE field__set(p_field, name, ref, description, unit, operation, freq_op, axis_ref, grid_ref, zoom_ref, prec, level, enabled)
 
     TYPE(field), pointer :: p_field
@@ -137,4 +144,5 @@
     CHARACTER(len=*),OPTIONAL :: axis_ref
     CHARACTER(len=*),OPTIONAL :: grid_ref
+    CHARACTER(len=*),OPTIONAL :: zoom_ref
     INTEGER, OPTIONAL :: prec
     INTEGER, OPTIONAL :: level
@@ -174,4 +182,10 @@
         p_field%has_grid_ref = .TRUE.
     ENDIF
+
+    IF (PRESENT(zoom_ref)) THEN
+        p_field%zoom_ref=TRIM(ADJUSTL(zoom_ref))
+        p_field%has_zoom_ref = .TRUE.
+    ENDIF
+
     IF (PRESENT(prec)) then
         p_field%prec=prec
@@ -240,4 +254,10 @@
     ELSE
         PRINT *, 'grid_ref undefined '
+    ENDIF
+
+    IF (pt_field%has_zoom_ref) THEN
+        PRINT *, 'zoom_ref : ',TRIM(pt_field%zoom_ref)
+    ELSE
+        PRINT *, 'zoom_ref undefined '
     ENDIF
     
@@ -378,4 +398,14 @@
     ELSE
         pt_field_out%has_grid_ref=.FALSE.
+    ENDIF
+
+    IF (pt_field_in%has_zoom_ref) THEN
+        pt_field_out%zoom_ref=pt_field_in%zoom_ref
+        pt_field_out%has_zoom_ref=.TRUE.
+    ELSE IF ( pt_field_default%has_zoom_ref ) THEN
+        pt_field_out%zoom_ref=pt_field_default%zoom_ref
+        pt_field_out%has_zoom_ref=.TRUE.
+    ELSE
+        pt_field_out%has_zoom_ref=.FALSE.
     ENDIF
 
@@ -526,4 +556,28 @@
  END SUBROUTINE field__solve_grid_ref
    
+ SUBROUTINE field__solve_zoom_ref(pt_field)
+ USE error_msg
+ IMPLICIT NONE
+   TYPE(field), POINTER :: pt_field
+   
+   IF (.NOT. pt_field%has_zoom_ref) THEN
+     IF (pt_field%has_grid_ref) THEN
+       pt_field%has_zoom_ref=.TRUE.
+       pt_field%zoom_ref=pt_field%grid_ref
+     ENDIF
+   ENDIF
+    
+   IF (pt_field%has_zoom_ref) THEN
+     CALL zoom__get(pt_field%zoom_ref,pt_field%zoom)
+     IF (ASSOCIATED(pt_field%zoom)) THEN
+       pt_field%has_zoom=.TRUE.
+     ELSE
+       WRITE (message,*) "The field : id = ",pt_field%id,"  name = ",Pt_field%name,   &
+                        " has a unknown reference to zoom : id =",pt_field%zoom_ref
+       CALL error("mod_field::field__solve_zoom_ref")
+     ENDIF
+   ENDIF
+   
+ END SUBROUTINE field__solve_zoom_ref
 
    
Index: /XMLIO_SERVER/trunk/src/XMLIO/mod_field_group.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/mod_field_group.f90	(revision 28)
+++ /XMLIO_SERVER/trunk/src/XMLIO/mod_field_group.f90	(revision 29)
@@ -158,4 +158,5 @@
     CALL field_group__solve_axis_ref(Pt_fg)
     CALL field_group__solve_grid_ref(Pt_fg)
+    CALL field_group__solve_zoom_ref(Pt_fg)
 
   END SUBROUTINE  field_group__solve_ref
@@ -208,4 +209,20 @@
   
   END SUBROUTINE field_group__solve_grid_ref
+
+  RECURSIVE SUBROUTINE field_group__solve_zoom_ref(Pt_fg)
+  IMPLICIT NONE
+    TYPE(field_group),POINTER  :: Pt_fg
+     
+    INTEGER :: i
+ 
+    DO i=1,Pt_fg%groups%size
+      CALL field_group__solve_zoom_ref(Pt_fg%groups%at(i)%pt)
+    ENDDO
+       
+    DO i=1,Pt_fg%fields%size
+      CALL field__solve_zoom_ref(Pt_fg%fields%at(i)%pt)
+    ENDDO
+  
+  END SUBROUTINE field_group__solve_zoom_ref
   
   RECURSIVE SUBROUTINE field_group__print(Pt_fg)
Index: /XMLIO_SERVER/trunk/src/XMLIO/mod_grid.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/mod_grid.f90	(revision 28)
+++ /XMLIO_SERVER/trunk/src/XMLIO/mod_grid.f90	(revision 29)
@@ -3,4 +3,6 @@
   USE mod_sorted_list
   USE mod_domain
+  USE mod_zoom
+
   IMPLICIT NONE
 
@@ -19,4 +21,6 @@
     INTEGER                     :: nj
     LOGICAL                     :: has_dimension
+    TYPE(vector_zoom),POINTER   :: associated_zoom
+    TYPE(zoom),POINTER          :: global_zoom
   END TYPE grid
 
@@ -75,7 +79,10 @@
    ALLOCATE(pt_grid%subdomain)
    ALLOCATE(pt_grid%rank_ids)
+   ALLOCATE(pt_grid%associated_zoom)
+   
    CALL domain__new(pt_grid%domain)
    CALL vector_domain__new(pt_grid%subdomain)
    CALL sorted_list__new(pt_grid%rank_ids)
+   CALL vector_zoom__new(pt_grid%associated_zoom)
    
    pt_grid%has_id          = .FALSE.
@@ -90,4 +97,6 @@
      CALL sorted_list__Add(Ids,hash(id),Pos)
    ENDIF
+   
+   CALL grid__get_new_zoom(pt_grid,pt_grid%global_zoom,id)
 
  END SUBROUTINE grid__new
@@ -160,8 +169,9 @@
     TYPE(grid), POINTER  :: pt_grid
     TYPE(domain),POINTER :: subdomain
+    TYPE(zoom),POINTER :: pt_zoom
     
     REAL,ALLOCATABLE :: lon(:,:)
     REAL,ALLOCATABLE :: lat(:,:)
-    INTEGER :: ib,ie,jb,je,ni,nj,ibegin,jbegin
+    INTEGER :: ib,ie,jb,je,ni,nj,ibegin,jbegin,iend,jend
     INTEGER :: i
     
@@ -203,6 +213,28 @@
       
       CALL domain__set(pt_grid%domain,0,ni,nj,ibegin,jbegin,lon,lat)
-
-      
+      iend=ibegin+ni-1
+      jend=jbegin+nj-1
+      
+      
+      pt_grid%global_zoom%ni_glo=pt_grid%ni
+      pt_grid%global_zoom%nj_glo=pt_grid%nj
+      pt_grid%global_zoom%ibegin_glo=1      
+      pt_grid%global_zoom%jbegin_glo=1
+      
+      DO i=1,pt_grid%associated_zoom%size
+        pt_zoom=>pt_grid%associated_zoom%at(i)%pt
+        
+        ib=MAX(pt_zoom%ibegin_glo-ibegin+1,1)
+        ie=MIN(pt_zoom%ibegin_glo+pt_zoom%ni_glo-ibegin,ni)
+        pt_zoom%ni_loc=MAX(ie-ib+1,0)
+        pt_zoom%ibegin_loc=ib
+
+        jb=MAX(pt_zoom%jbegin_glo-jbegin+1,1)
+        je=MIN(pt_zoom%jbegin_glo+pt_zoom%nj_glo-jbegin,nj)
+        pt_zoom%nj_loc=MAX(je-jb+1,0)
+        pt_zoom%jbegin_loc=jb
+      ENDDO
+                 
+            
       DEALLOCATE(lon)
       DEALLOCATE(lat)
@@ -211,5 +243,17 @@
       
             
-        
+  SUBROUTINE grid__get_new_zoom(pt_grid,pt_zoom,zoom_id)
+  USE string_function
+  IMPLICIT NONE
+    TYPE(grid), POINTER                      :: pt_grid
+    TYPE(zoom),POINTER                       :: pt_zoom
+    CHARACTER(LEN=*),INTENT(IN),OPTIONAL     :: zoom_id
+    LOGICAL                                  :: success
+    
+     CALL vector_zoom__get_new(pt_grid%associated_zoom,Pt_zoom)
+     CALL zoom__new(Pt_zoom,zoom_id)
+    
+   END SUBROUTINE grid__get_new_zoom
+     
   SUBROUTINE grid__print(pt_grid)
   IMPLICIT NONE
Index: /XMLIO_SERVER/trunk/src/XMLIO/mod_parse_xml.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/mod_parse_xml.f90	(revision 28)
+++ /XMLIO_SERVER/trunk/src/XMLIO/mod_parse_xml.f90	(revision 29)
@@ -255,4 +255,9 @@
       CALL axis__set(pt_axis,a_size=string_to_integer(value))
     ENDIF
+
+    IF (is_attribute_exist(node,"positive")) THEN
+      value =  getAttribute(node,"positive")
+      CALL axis__set(pt_axis,positive=string_to_logical(value))
+    ENDIF
    
   END SUBROUTINE parsing_axis_attribute 
@@ -333,6 +338,7 @@
     TYPE(grid_group),POINTER :: parent
     
-    TYPE(grid),POINTER :: pt_grid
-    TYPE(grid),POINTER       :: attribute
+    TYPE(grid),POINTER       :: pt_grid
+    TYPE(fnode), POINTER     :: child_node
+    TYPE(fnodeList), POINTER :: child_list
     INTEGER :: il
     CHARACTER(len=100) :: node_name
@@ -348,8 +354,29 @@
       
     CALL parsing_grid_attribute(node,pt_grid)
+    
+
+   IF (hasChildNodes(node)) THEN
+      child_list => getChildnodes(node)
+
+      DO il=0,getLength(child_list)-1
+        child_node => item(child_list,il)
+        node_name=getNodename(child_node)
+        
+        SELECT CASE (TRIM(node_name)) 
+        
+          CASE ('zoom') 
+            CALL parsing_zoom(child_node,pt_grid)
+             
+          CASE DEFAULT
+            IF (is_bad_node(node_name)) THEN
+              WRITE(message,*) 'Unknown node <<',TRIM(node_name),'>> while parsing grid'
+              CALL Warning("mod_parse_xml:parsing_grid")
+            ENDIF
+        END SELECT
+      ENDDO
+    ENDIF
   
   END SUBROUTINE parsing_grid
 
-  
   SUBROUTINE parsing_grid_attribute(node,pt_grid)
   USE mod_grid
@@ -372,7 +399,68 @@
   END SUBROUTINE parsing_grid_attribute 
 
-
-
-
+  SUBROUTINE parsing_zoom(node,parent)
+  USE mod_zoom
+  USE mod_grid 
+  IMPLICIT NONE  
+    TYPE(fnode), POINTER     :: node
+    TYPE(grid),POINTER       :: parent
+    
+    TYPE(zoom),POINTER       :: pt_zoom
+    INTEGER :: il
+    CHARACTER(len=100) :: node_name
+    CHARACTER(len=100) :: value
+  
+      
+    IF (is_attribute_exist(node,"id")) THEN
+      value=getAttribute(node,"id")
+      CALL grid__get_new_zoom(parent,pt_zoom,TRIM(value))
+    ELSE
+      CALL grid__get_new_zoom(parent,pt_zoom)
+    ENDIF
+      
+    CALL parsing_zoom_attribute(node,pt_zoom)
+    
+  END SUBROUTINE parsing_zoom
+
+
+  SUBROUTINE parsing_zoom_attribute(node,pt_zoom)
+  USE mod_zoom
+  IMPLICIT NONE
+    TYPE(fnode), POINTER     :: node
+    TYPE(zoom),POINTER       :: pt_zoom
+
+    CHARACTER(len=100) :: value
+   
+    IF (is_attribute_exist(node,"name")) THEN
+      value =  getAttribute(node,"name")
+      CALL zoom__set(pt_zoom,name=TRIM(value))
+    ENDIF
+
+    IF (is_attribute_exist(node,"description")) THEN
+      value =  getAttribute(node,"description")
+      CALL zoom__set(pt_zoom,description=TRIM(value))
+    ENDIF
+
+    IF (is_attribute_exist(node,"ni")) THEN
+      value =  getAttribute(node,"ni")
+      CALL zoom__set(pt_zoom,ni_glo=string_to_integer(value))
+    ENDIF
+
+    IF (is_attribute_exist(node,"nj")) THEN
+      value =  getAttribute(node,"nj")
+      CALL zoom__set(pt_zoom,nj_glo=string_to_integer(value))
+    ENDIF
+
+    IF (is_attribute_exist(node,"ibegin")) THEN
+      value =  getAttribute(node,"ibegin")
+      CALL zoom__set(pt_zoom,ibegin_glo=string_to_integer(value))
+    ENDIF
+
+    IF (is_attribute_exist(node,"jbegin")) THEN
+      value =  getAttribute(node,"jbegin")
+      CALL zoom__set(pt_zoom,jbegin_glo=string_to_integer(value))
+    ENDIF
+        
+  END SUBROUTINE parsing_zoom_attribute 
 
 
@@ -508,4 +596,9 @@
     ENDIF
 
+    IF (is_attribute_exist(node,"zoom_ref")) THEN
+      value =  getAttribute(node,"zoom_ref")
+      CALL field__set(pt_field,zoom_ref=TRIM(value))
+    ENDIF
+
     IF (is_attribute_exist(node,"level")) THEN
       value =  getAttribute(node,"level")
Index: /XMLIO_SERVER/trunk/src/XMLIO/mod_zoom.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/mod_zoom.f90	(revision 29)
+++ /XMLIO_SERVER/trunk/src/XMLIO/mod_zoom.f90	(revision 29)
@@ -0,0 +1,141 @@
+MODULE mod_zoom
+  USE mod_xmlio_parameters
+  USE mod_sorted_list
+
+  IMPLICIT NONE
+
+  TYPE,PUBLIC :: zoom
+    CHARACTER(len=str_len)      :: id
+    LOGICAL                     :: has_id
+    CHARACTER(len=str_len)      :: name
+    LOGICAL                     :: has_name
+    CHARACTER(len=str_len)      :: description
+    LOGICAL                     :: has_description
+    INTEGER                     :: ni_glo
+    LOGICAL                     :: has_ni_glo
+    INTEGER                     :: nj_glo
+    LOGICAL                     :: has_nj_glo
+    INTEGER                     :: ibegin_glo
+    LOGICAL                     :: has_ibegin_glo
+    INTEGER                     :: jbegin_glo
+    LOGICAL                     :: has_jbegin_glo
+    INTEGER                     :: ni_loc
+    INTEGER                     :: nj_loc
+    INTEGER                     :: ibegin_loc
+    INTEGER                     :: jbegin_loc
+  END TYPE zoom    
+
+  INCLUDE 'vector_zoom_def.inc'
+
+  TYPE(vector_zoom),POINTER,SAVE             :: zoom_Ids
+  TYPE(sorted_list),POINTER,SAVE,PRIVATE     :: Ids 
+  
+CONTAINS
+  
+  INCLUDE 'vector_zoom_contains.inc'
+
+  SUBROUTINE zoom__swap_context(saved_zoom_Ids,saved_Ids)
+  IMPLICIT NONE
+    TYPE(vector_zoom),POINTER          :: saved_zoom_Ids
+    TYPE(sorted_list),POINTER          :: saved_Ids 
+    
+    zoom_ids=>saved_zoom_ids
+    ids=>saved_ids
+  END SUBROUTINE zoom__swap_context
+
+
+  SUBROUTINE zoom__init
+  IMPLICIT NONE
+
+    CALL vector_zoom__new(zoom_Ids)
+    CALL sorted_list__new(Ids)
+    
+  END SUBROUTINE zoom__init
+  
+
+  SUBROUTINE zoom__new(pt_zoom,Id)
+  USE string_function
+  IMPLICIT NONE
+    TYPE(zoom),POINTER :: pt_zoom
+    CHARACTER(LEN=*),OPTIONAL     :: Id
+    INTEGER   :: Pos 
+      
+    pt_zoom%has_id=.FALSE.
+    pt_zoom%has_name=.FALSE.
+    pt_zoom%has_description=.FALSE.
+    pt_zoom%has_ni_glo=.FALSE.
+    pt_zoom%has_nj_glo=.FALSE.
+    pt_zoom%has_ibegin_glo=.FALSE.
+    pt_zoom%has_jbegin_glo=.FALSE.
+     
+    IF (PRESENT(Id)) THEN
+      Pt_zoom%id=TRIM(ADJUSTL(Id))
+      Pt_zoom%has_id=.TRUE.
+     CALL vector_zoom__set_new(zoom_Ids,Pt_zoom,Pos)
+     CALL sorted_list__Add(Ids,hash(id),Pos)
+    ENDIF
+   
+  END SUBROUTINE zoom__new
+   
+  SUBROUTINE zoom__set(pt_zoom,name,description,ni_glo,nj_glo,ibegin_glo,jbegin_glo)
+  IMPLICIT NONE
+    TYPE(zoom),POINTER                   :: pt_zoom
+    CHARACTER(len=*),OPTIONAL            :: name
+    CHARACTER(len=*),OPTIONAL            :: description
+    INTEGER,OPTIONAL                     :: ni_glo
+    INTEGER,OPTIONAL                     :: nj_glo
+    INTEGER,OPTIONAL                     :: ibegin_glo
+    INTEGER,OPTIONAL                     :: jbegin_glo
+    
+    IF (PRESENT(name)) THEN
+      pt_zoom%name=TRIM(ADJUSTL(name))
+      pt_zoom%has_name=.TRUE.
+    ENDIF
+    
+    IF (PRESENT(description)) THEN
+      pt_zoom%name=TRIM(ADJUSTL(description))
+      pt_zoom%has_description=.TRUE.
+    ENDIF
+    
+    IF (PRESENT(ni_glo)) THEN
+      pt_zoom%ni_glo=ni_glo
+      pt_zoom%has_ni_glo=.TRUE.
+    ENDIF
+
+    IF (PRESENT(nj_glo)) THEN
+      pt_zoom%nj_glo=nj_glo
+      pt_zoom%has_nj_glo=.TRUE.
+    ENDIF
+
+    IF (PRESENT(ibegin_glo)) THEN
+      pt_zoom%ibegin_glo=ibegin_glo
+      pt_zoom%has_ibegin_glo=.TRUE.
+    ENDIF
+    
+    IF (PRESENT(jbegin_glo)) THEN
+      pt_zoom%jbegin_glo=jbegin_glo
+      pt_zoom%has_ibegin_glo=.TRUE.
+    ENDIF
+               
+   END SUBROUTINE zoom__set   
+
+
+  SUBROUTINE zoom__get(Id,pt_zoom)
+  USE string_function
+  IMPLICIT NONE
+    CHARACTER(LEN=*),INTENT(IN)     :: Id
+    TYPE(zoom),POINTER              :: Pt_zoom
+
+    INTEGER                         :: Pos
+    LOGICAL                         :: success
+    
+    CALL sorted_list__find(Ids,hash(Id),Pos,success)
+    IF (success) THEN
+      Pt_zoom=>zoom_ids%at(Pos)%Pt
+    ELSE
+      Pt_zoom=>NULL()
+    ENDIF
+    
+  END SUBROUTINE zoom__get
+
+END MODULE mod_zoom
Index: /XMLIO_SERVER/trunk/src/XMLIO/vector_context_contains.inc
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/vector_context_contains.inc	(revision 28)
+++ /XMLIO_SERVER/trunk/src/XMLIO/vector_context_contains.inc	(revision 29)
@@ -72,5 +72,5 @@
   SUBROUTINE vector_context__increase(vect)
     TYPE(vector_context), INTENT(INOUT) :: vect
-    TYPE (Pt_context), POINTER, DIMENSION(:) :: Pt_tmp
+    TYPE (Pt_context__), POINTER, DIMENSION(:) :: Pt_tmp
     INTEGER :: new_size
     INTEGER :: i
Index: /XMLIO_SERVER/trunk/src/XMLIO/vector_context_def.inc
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/vector_context_def.inc	(revision 28)
+++ /XMLIO_SERVER/trunk/src/XMLIO/vector_context_def.inc	(revision 29)
@@ -1,11 +1,11 @@
 
-  TYPE,PRIVATE :: Pt_context 
+  TYPE Pt_context__ 
     TYPE (context),POINTER :: Pt
     LOGICAL               :: owned
-  END TYPE Pt_context
+  END TYPE Pt_context__
 
   TYPE vector_context
   
-    TYPE (Pt_context), POINTER, DIMENSION(:) :: at => NULL()
+    TYPE (Pt_context__), POINTER, DIMENSION(:) :: at => NULL()
     INTEGER :: size
     
Index: /XMLIO_SERVER/trunk/src/XMLIO/vector_zoom_contains.inc
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/vector_zoom_contains.inc	(revision 29)
+++ /XMLIO_SERVER/trunk/src/XMLIO/vector_zoom_contains.inc	(revision 29)
@@ -0,0 +1,89 @@
+
+  SUBROUTINE vector_zoom__new(vect,vect_size)
+  use mod_xmlio_parameters
+  IMPLICIT NONE
+    TYPE(vector_zoom), INTENT(INOUT) :: vect
+    INTEGER, OPTIONAL, INTENT(IN) :: vect_size
+     
+    IF (ASSOCIATED(vect%at)) CALL vector_zoom__delete(vect)
+    
+    IF (PRESENT(vect_size)) THEN 
+      vect%size_max=MAX(1,vect_size)
+    ELSE
+      vect%size_max=default_vector_size
+    ENDIF
+    
+    ALLOCATE(vect%at(vect%size_max))
+    
+    vect%size=0
+    vect%grow_factor=default_vector_grow_factor
+    
+  END SUBROUTINE vector_zoom__new
+  
+  SUBROUTINE vector_zoom__delete(vect)
+  IMPLICIT NONE
+    TYPE(vector_zoom), INTENT(IN OUT) :: vect
+    
+    INTEGER                             :: i
+    
+    DO i=1,vect%size
+      IF (vect%at(i)%owned) DEALLOCATE(vect%at(i)%Pt)
+! doit-on avoir une subroutine du genre : CALL zoom__delete() ???
+    ENDDO 
+    
+    IF (ASSOCIATED(vect%at)) DEALLOCATE(vect%at)
+    vect%size_max=0
+    
+  END SUBROUTINE vector_zoom__delete
+  
+  SUBROUTINE vector_zoom__get_new(vect,pt_value,pos)
+  IMPLICIT NONE
+  
+    TYPE(vector_zoom), INTENT(INOUT)   :: vect
+    TYPE(zoom),POINTER                 :: pt_value
+    INTEGER,OPTIONAL,INTENT(OUT)         :: Pos
+    
+    IF (vect%size==vect%size_max) CALL vector_zoom__increase(vect)
+    
+    vect%size=vect%size+1
+    ALLOCATE(vect%at(vect%size)%pt)
+    vect%at(vect%size)%owned=.TRUE.
+    pt_value=>vect%at(vect%size)%pt
+    IF (PRESENT(pos)) pos=vect%size
+    
+  END SUBROUTINE vector_zoom__get_new
+
+  SUBROUTINE vector_zoom__set_new(vect,pt_value,pos)
+  IMPLICIT NONE
+  
+    TYPE(vector_zoom), INTENT(INOUT)   :: vect
+    TYPE(zoom),POINTER                 :: pt_value
+    INTEGER,OPTIONAL,INTENT(OUT)         :: Pos
+    
+    IF (vect%size==vect%size_max) CALL vector_zoom__increase(vect)
+    
+    vect%size=vect%size+1
+    vect%at(vect%size)%pt=>pt_value
+    vect%at(vect%size)%owned=.FALSE.
+    IF (PRESENT(pos)) pos=vect%size
+    
+  END SUBROUTINE vector_zoom__set_new
+  
+  SUBROUTINE vector_zoom__increase(vect)
+    TYPE(vector_zoom), INTENT(INOUT) :: vect
+    TYPE (Pt_zoom__), POINTER, DIMENSION(:) :: Pt_tmp
+    INTEGER :: new_size
+    INTEGER :: i
+    
+    vect%size_max=MAX(vect%size_max+1,INT(vect%size_max*vect%grow_factor))
+    ALLOCATE(Pt_tmp(vect%size_max))
+    
+    DO i=1,vect%size
+     Pt_tmp(i)%pt=>vect%at(i)%pt
+    ENDDO
+    
+    DEALLOCATE(vect%at)
+    vect%at=>Pt_tmp
+    
+  END SUBROUTINE vector_zoom__increase 
+    
Index: /XMLIO_SERVER/trunk/src/XMLIO/vector_zoom_def.inc
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/vector_zoom_def.inc	(revision 29)
+++ /XMLIO_SERVER/trunk/src/XMLIO/vector_zoom_def.inc	(revision 29)
@@ -0,0 +1,17 @@
+
+  TYPE Pt_zoom__ 
+    TYPE (zoom),POINTER :: Pt
+    LOGICAL               :: owned
+  END TYPE Pt_zoom__
+
+  TYPE vector_zoom
+  
+    TYPE (Pt_zoom__), POINTER, DIMENSION(:) :: at => NULL()
+    INTEGER :: size
+    
+    INTEGER :: size_max
+    REAL    :: grow_factor
+    INTEGER :: chunk
+  
+  END TYPE vector_zoom
+  
