Index: /XMLIO_SERVER/trunk/src/IOSERVER/mod_event_client.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/IOSERVER/mod_event_client.f90	(revision 25)
+++ /XMLIO_SERVER/trunk/src/IOSERVER/mod_event_client.f90	(revision 26)
@@ -3,9 +3,25 @@
   USE mod_mpi_buffer_client, ONLY : create_request, finalize_request
   USE mod_event_parameters 
-
-  LOGICAL, SAVE :: using_server
+  USE mod_ioserver_namelist
       
 CONTAINS
 
+  SUBROUTINE event__swap_context(id)
+  USE iomanager
+  IMPLICIT NONE
+    CHARACTER(LEN=*),INTENT(IN) :: id
+    
+    IF (using_server) THEN
+      CALL create_request(event_id_swap_context)
+      CALL pack(LEN(TRIM(id)))
+      CALL pack(TRIM(id))
+      CALL Finalize_request
+    ELSE
+      CALL iom__swap_context(TRIM(id))
+    ENDIF
+    
+  END SUBROUTINE  event__swap_context
+  
+  
   SUBROUTINE event__parse_xml_file(filename)
   USE iomanager
@@ -109,4 +125,23 @@
   END SUBROUTINE event__set_grid_type_nemo
   
+  SUBROUTINE event__set_grid_type_lmdz(name,nbp,offset)
+  USE iomanager
+  IMPLICIT NONE
+    CHARACTER(LEN=*),INTENT(IN) :: name
+    INTEGER,INTENT(IN)          :: nbp
+    INTEGER,INTENT(IN)          :: offset
+        
+    IF (using_server) THEN
+      CALL create_request(event_id_set_grid_type_lmdz)
+      CALL pack(LEN(TRIM(name)))
+      CALL pack(TRIM(name))
+      CALL pack(nbp)
+      CALL pack(offset)
+      CALL Finalize_request
+    ELSE
+     CALL iom__set_grid_type_lmdz(name,nbp,offset)
+    ENDIF
+      
+  END SUBROUTINE event__set_grid_type_lmdz
   
   SUBROUTINE event__set_time_parameters(itau0,zjulian,zdt)
@@ -162,4 +197,23 @@
   END SUBROUTINE event__disable_field
   
+  SUBROUTINE event__write_field1d(varname,var)
+  USE iomanager
+  IMPLICIT NONE
+    CHARACTER(len=*),INTENT(IN)     :: varname
+    REAL, DIMENSION(:),INTENT(IN) :: var
+
+    IF (using_server) THEN
+      CALL create_request(event_id_write_field1d)
+      CALL pack(len(varname))
+      CALL pack(size(var,1))
+      CALL pack(varname)
+      CALL pack_field(var)
+      CALL Finalize_request 
+    ELSE
+      CALL iom__write_field1d(varname,var)
+    ENDIF
+    
+  END SUBROUTINE event__write_field1d
+
   SUBROUTINE event__write_field2d(varname,var)
   USE iomanager
Index: /XMLIO_SERVER/trunk/src/IOSERVER/mod_event_parameters.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/IOSERVER/mod_event_parameters.f90	(revision 25)
+++ /XMLIO_SERVER/trunk/src/IOSERVER/mod_event_parameters.f90	(revision 26)
@@ -13,4 +13,7 @@
   INTEGER, PARAMETER :: event_id_enable_field          = 111
   INTEGER, PARAMETER :: event_id_disable_field         = 112
+  INTEGER, PARAMETER :: event_id_swap_context          = 113
+  INTEGER, PARAMETER :: event_id_set_grid_type_lmdz    = 114
+  INTEGER, PARAMETER :: event_id_write_field1d         = 115
   INTEGER, PARAMETER :: event_id_stop_ioserver         = 999
 END MODULE mod_event_parameters
Index: /XMLIO_SERVER/trunk/src/IOSERVER/mod_event_server.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/IOSERVER/mod_event_server.f90	(revision 25)
+++ /XMLIO_SERVER/trunk/src/IOSERVER/mod_event_server.f90	(revision 26)
@@ -20,4 +20,7 @@
     SELECT CASE (event_id)
     
+      CASE (event_id_swap_context)
+        CALL event__swap_context
+        
       CASE (event_id_parse_xml_file)
         CALL event__parse_xml_file 
@@ -35,4 +38,7 @@
         CALL event__set_grid_type_nemo
 
+      CASE (event_id_set_grid_type_lmdz)
+        CALL event__set_grid_type_lmdz
+
       CASE (event_id_set_time_parameters)
         CALL event__set_time_parameters
@@ -49,4 +55,7 @@
       CASE (event_id_disable_field)
         CALL event__disable_field
+
+      CASE (event_id_write_Field1d)
+        CALL event__write_Field1d
 
       CASE (event_id_write_Field2d)
@@ -67,4 +76,25 @@
    END SUBROUTINE Process_event
    
+  SUBROUTINE event__swap_context
+  IMPLICIT NONE
+    INTEGER :: id_size
+   
+    CALL unpack(id_size)
+    CALL sub_internal(id_size)
+     
+  CONTAINS
+    
+    SUBROUTINE sub_internal(id_size)
+      INTEGER :: id_size
+      CHARACTER(LEN=id_size) :: id     
+     
+       CALL unpack(id)
+     
+       CALL iom__swap_context(id)
+       
+     END SUBROUTINE sub_internal
+  
+  END SUBROUTINE event__swap_context
+  
 
   SUBROUTINE event__parse_xml_file
@@ -172,4 +202,27 @@
   END SUBROUTINE event__set_grid_type_nemo   
 
+  SUBROUTINE event__set_grid_type_lmdz 
+  IMPLICIT NONE    
+    INTEGER :: name_size
+
+    CALL unpack(name_size)
+    CALL sub_internal(name_size)
+     
+  CONTAINS
+    
+    SUBROUTINE sub_internal(name_size)
+      INTEGER :: name_size
+      CHARACTER(LEN=name_size) :: name     
+      INTEGER                  :: nbp
+      INTEGER                  :: offset
+      
+       CALL unpack(name)
+       CALL unpack(nbp)
+       CALL unpack(offset)
+       CALL iom__set_grid_type_lmdz(name,nbp,offset)
+
+     END SUBROUTINE sub_internal
+   
+  END SUBROUTINE event__set_grid_type_lmdz   
 
   SUBROUTINE event__set_vert_axis
@@ -256,4 +309,29 @@
   
       
+  SUBROUTINE event__write_field1D
+  IMPLICIT NONE
+    INTEGER :: lenc
+    INTEGER :: dim1
+      
+    CALL unpack(lenc)
+    CALL unpack(dim1)
+    CALL sub_internal(lenc,dim1)
+  
+  CONTAINS
+    SUBROUTINE sub_internal(lenc,dim1)
+    IMPLICIT NONE
+      INTEGER :: lenc
+      INTEGER :: dim1
+      CHARACTER(len=lenc) :: varname
+      REAL                :: var(dim1)
+      
+      CALL unpack(varname)
+      CALL unpack_field(var)
+      
+      CALL iom__write_Field1d(varname,var)
+
+    END SUBROUTINE sub_internal
+  END SUBROUTINE event__write_field1d
+
   SUBROUTINE event__write_field2D
   IMPLICIT NONE
Index: /XMLIO_SERVER/trunk/src/IOSERVER/mod_ioclient.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/IOSERVER/mod_ioclient.f90	(revision 25)
+++ /XMLIO_SERVER/trunk/src/IOSERVER/mod_ioclient.f90	(revision 26)
@@ -8,12 +8,54 @@
   USE mod_mpi_buffer_client
   USE mod_wait
+  USE mod_ioserver_namelist
+  USE mod_event_client
+  USE iomanager
+
   IMPLICIT NONE
-    INTEGER, INTENT(OUT) :: NEW_COMM
-    
-    CALL Init_parallel
-    CALL Init_mpi_buffer
-    CALL Init_wait
-    
-    NEW_COMM=intracomm
+    INTEGER, INTENT(INOUT),OPTIONAL :: NEW_COMM
+
+    INTEGER :: Comm
+    INTEGER :: nb_server
+    INTEGER :: rank
+    INTEGER :: ierr
+    LOGICAL :: init
+    INCLUDE 'mpif.h'
+ 
+    CALL read_namelist
+
+    IF (using_server) THEN
+      IF (using_oasis) THEN
+      ELSE
+        CALL Init_parallel
+        CALL Init_mpi_buffer
+        CALL Init_wait
+        NEW_COMM=intracomm
+      ENDIF
+    ELSE
+      IF (using_oasis) THEN
+      
+      ELSE
+        CALL MPI_INITIALIZED(init,ierr)
+        IF (init) THEN
+          IF (.NOT. PRESENT(NEW_COMM)) THEN
+             Comm=MPI_COMM_WORLD
+          ELSE
+            Comm=New_Comm
+          ENDIF
+        ELSE
+          CALL MPI_INIT(ierr)
+          Comm=MPI_COMM_WORLD
+          
+          IF (PRESENT(NEW_COMM)) THEN
+            New_Comm=MPI_COMM_WORLD
+          ENDIF
+        ENDIF  
+        CALL MPI_COMM_SIZE(Comm,nb_server,ierr)     
+        CALL MPI_COMM_RANK(Comm,rank,ierr)
+        CALL iom__init(1,nb_server,rank)
+        CALL iom__set_current_rank(1)
+        
+      ENDIF
+    ENDIF
     
   END SUBROUTINE init_ioclient
Index: /XMLIO_SERVER/trunk/src/IOSERVER/mod_iomanager.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/IOSERVER/mod_iomanager.f90	(revision 25)
+++ /XMLIO_SERVER/trunk/src/IOSERVER/mod_iomanager.f90	(revision 26)
@@ -28,4 +28,13 @@
   END SUBROUTINE iom__parse_xml_file
    
+  SUBROUTINE iom__swap_context(id)
+  USE xmlio
+  IMPLICIT NONE
+    CHARACTER(LEN=*) :: id
+    
+    IF (current_rank==nb_client) CALL context__swap(id)
+     
+  END SUBROUTINE iom__swap_context
+
   SUBROUTINE iom__set_current_rank(rank)
   IMPLICIT NONE
@@ -99,4 +108,25 @@
 
   END SUBROUTINE iom__set_grid_type_nemo
+
+  SUBROUTINE iom__set_grid_type_lmdz(name,nbp,offset)
+  USE xmlio
+  IMPLICIT NONE
+    CHARACTER(LEN=*),INTENT(IN) :: name
+    INTEGER,INTENT(IN)          :: nbp
+    INTEGER,INTENT(IN)          :: offset
+
+    TYPE(grid),   POINTER :: pt_grid
+    TYPE(domain), POINTER :: pt_domain
+    LOGICAL,ALLOCATABLE   :: mask(:,:)
+      
+      CALL grid__get(name,pt_grid)
+      CALL grid__get_subdomain(pt_grid,current_rank,pt_domain)
+      ALLOCATE(mask(pt_domain%ni,pt_domain%nj))
+      mask(:,:)=.TRUE.
+      mask(1:offset,1)=.FALSE.
+      mask(MOD(offset+nbp-1,pt_domain%ni)+2:pt_domain%ni,pt_domain%nj)=.FALSE.
+      CALL domain__set_type_box(pt_domain,mask)
+
+  END SUBROUTINE iom__set_grid_type_lmdz
       
   SUBROUTINE iom__set_time_parameters(itau0,zjulian,zdt)
@@ -273,5 +303,5 @@
       nj=local_domain%nj
       
-      IF (pt_field%axis%name/="none") THEN
+      IF (pt_field%axis%name=="none") THEN
         CALL write_ioipsl_3d(varname,Field_buffer(1:ni,1:nj,1:nk))
       ELSE 
Index: /XMLIO_SERVER/trunk/src/IOSERVER/mod_ioserver_namelist.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/IOSERVER/mod_ioserver_namelist.f90	(revision 26)
+++ /XMLIO_SERVER/trunk/src/IOSERVER/mod_ioserver_namelist.f90	(revision 26)
@@ -0,0 +1,55 @@
+MODULE mod_ioserver_namelist
+
+  LOGICAL :: using_server
+  LOGICAL :: using_oasis
+  CHARACTER(LEN=100) :: client_id
+  CHARACTER(LEN=100) :: server_id
+  
+  NAMELIST /coupling_param/ using_server,using_oasis,client_id,server_id  
+
+  INTEGER,PARAMETER,PRIVATE :: starting_unit=356
+  
+CONTAINS
+
+  SUBROUTINE set_default_namelist
+  IMPLICIT NONE
+  
+    using_server=.FALSE.
+    using_oasis=.FALSE.
+    client_id='unknown'
+    server_id='unknown'
+  END SUBROUTINE set_default_namelist
+  
+    
+  SUBROUTINE read_namelist
+  IMPLICIT NONE
+    LOGICAL :: opened
+    INTEGER :: unit
+    INTEGER :: ierr
+
+    CALL set_default_namelist   
+    unit=starting_unit
+    opened=.TRUE.
+    DO WHILE (opened) 
+      unit=unit+1
+      INQUIRE(unit,OPENED=opened)
+    ENDDO
+      
+    OPEN(UNIT=unit,FILE='xmlio_server.def',STATUS='old',IOSTAT=ierr)
+    
+    
+    IF (ierr==0) THEN
+      READ(unit,nml=coupling_param)
+      CLOSE(unit)
+    ELSE
+      PRINT *,'WARNING : mod_ioserver::read_namelist : file xmlio_server.def is absent', &
+              ' ---> using default parameter'
+    ENDIF 
+    
+    
+    PRINT *,'namelist read --> ',using_server,using_oasis,client_id,server_id
+    
+  END SUBROUTINE read_namelist
+
+
+END MODULE mod_ioserver_namelist 
Index: /XMLIO_SERVER/trunk/src/IOSERVER/server.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/IOSERVER/server.f90	(revision 25)
+++ /XMLIO_SERVER/trunk/src/IOSERVER/server.f90	(revision 26)
@@ -7,4 +7,5 @@
   USE iomanager
   USE mod_interface_ioipsl
+  USE mod_ioserver_namelist
   IMPLICIT NONE
   INCLUDE 'mpif.h'
@@ -15,4 +16,5 @@
 !  CALL SLEEP(60)
   PRINT *,'je suis un serveur'
+  CALL read_namelist
   CALL init_parallel
   CALL init_mpi_buffer
Index: /XMLIO_SERVER/trunk/src/XMLIO/create_template
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/create_template	(revision 25)
+++ /XMLIO_SERVER/trunk/src/XMLIO/create_template	(revision 26)
@@ -1,38 +1,24 @@
-sed "s/#TYPE#/field/g" vector_def.template > vector_field_def.inc
-sed "s/#TYPE#/field/g" vector_contains.template > vector_field_contains.inc
+#! /bin/bash
 
-sed "s/#TYPE#/field_group/g" vector_def.template > vector_field_group_def.inc
-sed "s/#TYPE#/field_group/g" vector_contains.template > vector_field_group_contains.inc
+function template() 
+{
+  echo ${1}
+  sed "s/#TYPE#/${1}/g" vector_def.template > vector_${1}_def.inc
+  sed "s/#TYPE#/${1}/g" vector_contains.template > vector_${1}_contains.inc
+}
 
-sed "s/#TYPE#/axis/g" vector_def.template > vector_axis_def.inc
-sed "s/#TYPE#/axis/g" vector_contains.template > vector_axis_contains.inc
 
-sed "s/#TYPE#/axis_group/g" vector_def.template > vector_axis_group_def.inc
-sed "s/#TYPE#/axis_group/g" vector_contains.template > vector_axis_group_contains.inc
-
-sed "s/#TYPE#/node/g" vector_def.template > vector_node_def.inc
-sed "s/#TYPE#/node/g" vector_contains.template > vector_node_contains.inc
-
-sed "s/#TYPE#/domain/g" vector_def.template > vector_domain_def.inc
-sed "s/#TYPE#/domain/g" vector_contains.template > vector_domain_contains.inc
-
-sed "s/#TYPE#/grid/g" vector_def.template > vector_grid_def.inc
-sed "s/#TYPE#/grid/g" vector_contains.template > vector_grid_contains.inc
-
-sed "s/#TYPE#/grid_group/g" vector_def.template > vector_grid_group_def.inc
-sed "s/#TYPE#/grid_group/g" vector_contains.template > vector_grid_group_contains.inc
-
-sed "s/#TYPE#/file/g" vector_def.template > vector_file_def.inc
-sed "s/#TYPE#/file/g" vector_contains.template > vector_file_contains.inc
-
-sed "s/#TYPE#/file_group/g" vector_def.template > vector_file_group_def.inc
-sed "s/#TYPE#/file_group/g" vector_contains.template > vector_file_group_contains.inc
-
-sed "s/#TYPE#/file_dep/g" vector_def.template > vector_file_dep_def.inc
-sed "s/#TYPE#/file_dep/g" vector_contains.template > vector_file_dep_contains.inc
-
-sed "s/#TYPE#/field_dep/g" vector_def.template > vector_field_dep_def.inc
-sed "s/#TYPE#/field_dep/g" vector_contains.template > vector_field_dep_contains.inc
-
-sed "s/#TYPE#/field_out/g" vector_def.template > vector_field_out_def.inc
-sed "s/#TYPE#/field_out/g" vector_contains.template > vector_field_out_contains.inc
+template field
+template field_group
+template axis
+template axis_group
+template node
+template domain
+template grid
+template grid_group
+template file
+template file_group
+template field_dep
+template file_dep
+template field_out
+template context
Index: /XMLIO_SERVER/trunk/src/XMLIO/mod_axis.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/mod_axis.f90	(revision 25)
+++ /XMLIO_SERVER/trunk/src/XMLIO/mod_axis.f90	(revision 26)
@@ -31,9 +31,16 @@
   INCLUDE 'vector_axis_contains.inc'
 
+  SUBROUTINE axis__swap_context(saved_axis_Ids,saved_Ids)
+  IMPLICIT NONE
+    TYPE(vector_axis),POINTER          :: saved_axis_Ids
+    TYPE(sorted_list),POINTER          :: saved_Ids 
+    
+    axis_ids=>saved_axis_ids
+    ids=>saved_ids
+    
+  END SUBROUTINE axis__swap_context
+
   SUBROUTINE axis__init
   IMPLICIT NONE
-    
-    ALLOCATE(axis_Ids)
-    ALLOCATE(Ids)
     
     CALL vector_axis__new(axis_Ids)
Index: /XMLIO_SERVER/trunk/src/XMLIO/mod_axis_definition.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/mod_axis_definition.f90	(revision 25)
+++ /XMLIO_SERVER/trunk/src/XMLIO/mod_axis_definition.f90	(revision 26)
@@ -6,9 +6,16 @@
 CONTAINS
 
+  SUBROUTINE axis_definition__swap_context(saved_axis_definition)      
+  IMPLICIT NONE
+    TYPE(axis_group),POINTER :: saved_axis_definition
+    
+    axis_definition=>saved_axis_definition
+    
+  END SUBROUTINE axis_definition__swap_context 
+
   SUBROUTINE axis_definition__Init
   USE mod_axis_group
   IMPLICIT NONE
   
-    ALLOCATE(axis_definition)
     CALL axis_group__new(axis_definition,"axis_definition")
     
Index: /XMLIO_SERVER/trunk/src/XMLIO/mod_axis_group.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/mod_axis_group.f90	(revision 25)
+++ /XMLIO_SERVER/trunk/src/XMLIO/mod_axis_group.f90	(revision 26)
@@ -22,9 +22,16 @@
   INCLUDE "vector_axis_group_contains.inc"
 
+  SUBROUTINE axis_group__swap_context(saved_axis_group_Ids,saved_ids)
+  IMPLICIT NONE
+  TYPE(vector_axis_group),POINTER       :: saved_axis_group_Ids
+  TYPE(sorted_list),POINTER             :: saved_Ids 
+   
+   axis_group_ids=>saved_axis_group_ids
+   ids=>saved_ids
+   
+  END SUBROUTINE axis_group__swap_context
+
   SUBROUTINE axis_group__init
   IMPLICIT NONE
-    
-    ALLOCATE(axis_group_Ids)
-    ALLOCATE(Ids)
     
     CALL vector_axis_group__new(axis_group_Ids)
Index: /XMLIO_SERVER/trunk/src/XMLIO/mod_context.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/mod_context.f90	(revision 26)
+++ /XMLIO_SERVER/trunk/src/XMLIO/mod_context.f90	(revision 26)
@@ -0,0 +1,213 @@
+MODULE mod_context
+  USE mod_xmlio_parameters
+  USE mod_sorted_list
+  USE mod_field
+  USE mod_field_group
+  USE mod_field_definition
+  USE mod_file
+  USE mod_file_group
+  USE mod_file_definition
+  USE mod_grid
+  USE mod_grid_group
+  USE mod_grid_definition
+  USE mod_axis
+  USE mod_axis_group
+  USE mod_axis_definition
+  USE mod_dependency
+
+
+  INTERFACE context__swap
+    MODULE PROCEDURE context__swap_id,context__swap_pt
+  END INTERFACE  
+  
+  TYPE, PUBLIC :: context
+    CHARACTER(len=str_len)         :: id
+    INTEGER                        :: number
+  
+    TYPE(vector_field),POINTER        :: field__field_Ids
+    TYPE(sorted_list),POINTER         :: field__Ids
+    TYPE(vector_field_group),POINTER  :: field_group__field_group_ids
+    TYPE(sorted_list),POINTER         :: field_group__Ids
+    TYPE(field_group),POINTER         :: field_definition__field_definition
+    TYPE(vector_file),POINTER         :: file__file_Ids
+    TYPE(sorted_list),POINTER         :: file__Ids
+    TYPE(vector_file_group),POINTER   :: file_group__file_group_Ids
+    TYPE(sorted_list),POINTER         :: file_group__Ids 
+    TYPE(file_group),POINTER          :: file_definition__file_definition 
+    TYPE(vector_grid),POINTER         :: grid__grid_Ids
+    TYPE(sorted_list),POINTER         :: grid__Ids 
+    TYPE(vector_grid_group),POINTER   :: grid_group__grid_group_Ids
+    TYPE(sorted_list),POINTER         :: grid_group__Ids 
+    TYPE(grid_group),POINTER          :: grid_definition__grid_definition
+    TYPE(vector_axis),POINTER         :: axis__axis_Ids
+    TYPE(sorted_list),POINTER         :: axis__Ids 
+    TYPE(vector_axis_group),POINTER   :: axis_group__axis_group_Ids
+    TYPE(sorted_list),POINTER         :: axis_group__Ids 
+    TYPE(axis_group),POINTER          :: axis_definition__axis_definition
+    TYPE(vector_file_dep),POINTER     :: dependency__file_enabled
+    TYPE(vector_field_out),POINTER    :: dependency__field_enabled 
+    TYPE(vector_field_dep),POINTER    :: dependency__field_id
+    TYPE(sorted_list),POINTER         :: dependency__sorted_id  
+  
+  END TYPE context
+  
+  INCLUDE 'vector_context_def.inc'
+  TYPE(vector_context),SAVE,POINTER  :: context_ids
+  TYPE(sorted_list),POINTER,SAVE,PRIVATE :: Ids
+
+ 
+  CONTAINS
+    INCLUDE 'vector_context_contains.inc'
+    
+    SUBROUTINE context__init
+    IMPLICIT NONE
+
+      ALLOCATE(context_Ids)
+      ALLOCATE(Ids)
+
+      CALL vector_context__new(context_Ids)
+      CALL sorted_list__new(ids)
+
+    END SUBROUTINE context__init
+
+    SUBROUTINE context__get(Id,Pt_context)
+      USE string_function
+      IMPLICIT NONE
+      CHARACTER(LEN=*),INTENT(IN)     :: Id
+      TYPE(context),POINTER              :: Pt_context
+
+      INTEGER                         :: Pos
+      LOGICAL                         :: success
+    
+      CALL sorted_list__find(Ids,hash(Id),Pos,success)
+      IF (success) THEN
+        Pt_context=>context_ids%at(Pos)%Pt
+      ELSE
+        Pt_context=>NULL()
+      ENDIF
+    
+    END SUBROUTINE context__get
+
+    SUBROUTINE context__get_new(Id,pt_context)
+    USE string_function
+    IMPLICIT NONE
+      CHARACTER(LEN=*),INTENT(IN)     :: Id
+      TYPE(context),POINTER              :: Pt_context
+
+      INTEGER                         :: Pos
+      LOGICAL                         :: success
+      
+      CALL sorted_list__find(Ids,hash(Id),Pos,success)
+      IF (success) THEN
+        Pt_context=>context_ids%at(Pos)%Pt
+      ELSE
+        CALL vector_context__get_new(context_ids,pt_context,Pos)
+        pt_context%number=Pos
+        Pt_context%id=Id
+        CALL sorted_list__Add(Ids,hash(Id),Pos)
+        
+        ALLOCATE(pt_context%field__field_Ids )
+        ALLOCATE(pt_context%field__Ids )
+        ALLOCATE(pt_context%field_group__field_group_ids )
+        ALLOCATE(pt_context%field_group__field_group_ids )
+        ALLOCATE(pt_context%field_group__Ids )
+        ALLOCATE(pt_context%field_definition__field_definition )
+        ALLOCATE(pt_context%file__file_Ids)
+        ALLOCATE(pt_context%file__Ids)
+        ALLOCATE(pt_context%file_group__file_group_Ids)
+        ALLOCATE(pt_context%file_group__Ids) 
+        ALLOCATE(pt_context%file_definition__file_definition) 
+        ALLOCATE(pt_context%grid__grid_Ids)
+        ALLOCATE(pt_context%grid__Ids) 
+        ALLOCATE(pt_context%grid_group__grid_group_Ids)
+        ALLOCATE(pt_context%grid_group__Ids) 
+        ALLOCATE(pt_context%grid_definition__grid_definition)
+        ALLOCATE(pt_context%axis__axis_Ids)
+        ALLOCATE(pt_context%axis__Ids) 
+        ALLOCATE(pt_context%axis_group__axis_group_Ids)
+        ALLOCATE(pt_context%axis_group__Ids) 
+        ALLOCATE(pt_context%axis_definition__axis_definition)
+        ALLOCATE(pt_context%dependency__file_enabled)
+        ALLOCATE(pt_context%dependency__field_enabled) 
+        ALLOCATE(pt_context%dependency__field_id)
+        ALLOCATE(pt_context%dependency__sorted_id)  
+
+        CALL context__swap(pt_context)
+        
+        CALL field__init
+        CALL field_group__Init
+        CALL field_definition__Init
+
+        CALL axis__init
+        CALL axis_group__Init
+        CALL axis_definition__Init
+
+        CALL grid__init
+        CALL grid_group__Init
+        CALL grid_definition__Init
+
+        CALL file__init
+        CALL file_group__Init
+        CALL file_definition__Init
+
+      ENDIF
+
+    END SUBROUTINE context__get_new
+
+
+    SUBROUTINE context__create(Id)
+    IMPLICIT NONE
+      CHARACTER(LEN=*),INTENT(IN)     :: Id
+      
+      TYPE(context),POINTER              :: Pt_context
+
+      CALL context__get(Id,Pt_context)
+      IF (.NOT. ASSOCIATED(Pt_context)) CALL context__get_new(Id,Pt_context)
+      
+!      CALL field__init
+!      CALL field_group__init
+!      CALL field_definition__init
+      
+     END SUBROUTINE context__create
+
+     
+    SUBROUTINE context__swap_id(Id)
+    USE mod_field
+      IMPLICIT NONE
+      CHARACTER(LEN=*),INTENT(IN)     :: Id
+      TYPE(context),POINTER       :: Pt_context
+
+      INTEGER :: number
+      
+      CALL context__get(Id,Pt_context)
+      IF (.NOT. ASSOCIATED(Pt_context)) THEN
+!!      error message
+      ENDIF
+      
+      CALL context__swap(pt_context)  
+
+    END SUBROUTINE context__swap_id
+
+    SUBROUTINE context__swap_pt(Pt_context)
+    USE mod_field
+      IMPLICIT NONE
+      TYPE(context),POINTER       :: Pt_context
+
+      CALL field__swap_context(Pt_context%field__field_Ids ,Pt_context%field__Ids)
+      CALL field_group__swap_context(Pt_context%field_group__field_group_ids ,Pt_context%field_group__Ids)
+      CALL field_definition__swap_context(Pt_context%field_definition__field_definition)
+      CALL file__swap_context(Pt_context%file__file_Ids,Pt_context%file__Ids)
+      CALL file_group__swap_context(Pt_context%file_group__file_group_Ids,Pt_context%file_group__Ids)
+      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 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)
+      CALL axis__swap_context(pt_context%axis__axis_Ids,pt_context%axis__Ids) 
+      CALL axis_group__swap_context(pt_context%axis_group__axis_group_Ids,pt_context%axis_group__Ids) 
+      CALL axis_definition__swap_context(pt_context%axis_definition__axis_definition)
+      CALL dependency__swap_context(pt_context%dependency__file_enabled,pt_context%dependency__field_enabled,  &
+                                    pt_context%dependency__field_id,pt_context%dependency__sorted_id)  
+    END SUBROUTINE context__swap_pt
+
+
+END MODULE mod_context
Index: /XMLIO_SERVER/trunk/src/XMLIO/mod_dependency.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/mod_dependency.f90	(revision 25)
+++ /XMLIO_SERVER/trunk/src/XMLIO/mod_dependency.f90	(revision 26)
@@ -32,10 +32,10 @@
 INCLUDE 'vector_field_out_def.inc'
 
-TYPE(vector_file_dep),POINTER      :: file_enabled
-TYPE(vector_field_out),POINTER     :: field_enabled 
-TYPE(vector_field_dep),POINTER     :: field_id
+TYPE(vector_file_dep),POINTER,SAVE      :: file_enabled
+TYPE(vector_field_out),POINTER,SAVE     :: field_enabled 
+TYPE(vector_field_dep),POINTER,SAVE     :: field_id
 
  
-TYPE(sorted_list),POINTER :: sorted_id
+TYPE(sorted_list),POINTER,SAVE :: sorted_id
 
 CONTAINS
@@ -45,4 +45,19 @@
 INCLUDE 'vector_field_out_contains.inc'
 
+  
+  SUBROUTINE dependency__swap_context(saved_file_enabled,saved_field_enabled,save_field_id,saved_sorted_id)  
+  IMPLICIT NONE
+    TYPE(vector_file_dep),POINTER      :: saved_file_enabled
+    TYPE(vector_field_out),POINTER     :: saved_field_enabled 
+    TYPE(vector_field_dep),POINTER     :: save_field_id
+    TYPE(sorted_list),POINTER          :: saved_sorted_id  
+    
+    file_enabled=>saved_file_enabled   
+    field_enabled=>saved_field_enabled
+    field_id=>save_field_id
+    sorted_id=>saved_sorted_id
+      
+  END SUBROUTINE dependency__swap_context
+  
   SUBROUTINE set_dependency
   IMPLICIT NONE
@@ -76,5 +91,4 @@
       Pt_fg=>Pt_file_group
     ELSE
-      ALLOCATE(file_enabled)
       CALL vector_file_dep__new(file_enabled)
       Pt_fg=>file_definition
@@ -161,5 +175,4 @@
   INTEGER                  :: j
   
-    ALLOCATE(field_enabled)
     CALL vector_field_out__new(field_enabled)
     
@@ -189,8 +202,5 @@
   INTEGER :: i
   
-    ALLOCATE(field_id)
     CALL vector_field_dep__new(field_id)
-
-    ALLOCATE(sorted_id)
     CALL sorted_list__new(sorted_id)
     
Index: /XMLIO_SERVER/trunk/src/XMLIO/mod_domain.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/mod_domain.f90	(revision 25)
+++ /XMLIO_SERVER/trunk/src/XMLIO/mod_domain.f90	(revision 26)
@@ -123,10 +123,15 @@
     ENDIF
 
+    pt_domain%nbp=nbp
     ALLOCATE(pt_domain%i_index(nbp))
     ALLOCATE(pt_domain%j_index(nbp))
+    ALLOCATE(pt_domain%mask(nbp))
         
     DO i=1,nbp
-      Pt_domain%i_index(i)=(index(i)+offset)/pt_domain%nj+1+pt_domain%ibegin-1
-      Pt_domain%j_index(i)=MOD(index(i)+offset,pt_domain%nj)+1+pt_domain%jbegin-1
+!      Pt_domain%i_index(i)=(index(i)+offset)/pt_domain%ni+1+pt_domain%ibegin-1
+!      Pt_domain%j_index(i)=MOD(index(i)+offset,pt_domain%ni)+1+pt_domain%jbegin-1
+      Pt_domain%i_index(i)=MOD(index(i)+offset-1,pt_domain%ni)+1
+      Pt_domain%j_index(i)=(index(i)+offset-1)/pt_domain%ni+1
+      
     ENDDO
 
Index: /XMLIO_SERVER/trunk/src/XMLIO/mod_field.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/mod_field.f90	(revision 25)
+++ /XMLIO_SERVER/trunk/src/XMLIO/mod_field.f90	(revision 26)
@@ -47,15 +47,23 @@
   INCLUDE 'vector_field_def.inc'
   
-  TYPE(vector_field),POINTER            :: field_Ids
-  TYPE(sorted_list),POINTER,PRIVATE     :: Ids 
+  TYPE(vector_field),POINTER,SAVE            :: field_Ids
+  TYPE(sorted_list),POINTER,SAVE,PRIVATE     :: Ids
+  
 
 CONTAINS
   INCLUDE 'vector_field_contains.inc'
-  
+
+  SUBROUTINE field__swap_context(saved_field_ids,saved_ids)
+  IMPLICIT NONE
+    TYPE(vector_field),POINTER :: saved_field_ids
+    TYPE(sorted_list),POINTER  :: saved_ids
+    
+    field_Ids=>saved_field_ids
+    Ids=>saved_Ids
+
+  END SUBROUTINE field__swap_context
+
   SUBROUTINE field__init
   IMPLICIT NONE
-    
-    ALLOCATE(field_Ids)
-    ALLOCATE(Ids)
     
     CALL vector_field__new(field_Ids)
Index: /XMLIO_SERVER/trunk/src/XMLIO/mod_field_definition.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/mod_field_definition.f90	(revision 25)
+++ /XMLIO_SERVER/trunk/src/XMLIO/mod_field_definition.f90	(revision 26)
@@ -6,12 +6,20 @@
 CONTAINS
 
+  SUBROUTINE field_definition__swap_context(saved_field_definition)
+  IMPLICIT NONE
+    TYPE(field_group),POINTER :: saved_field_definition
+  
+    field_definition=>saved_field_definition
+
+  END SUBROUTINE field_definition__swap_context
+
+
   SUBROUTINE field_definition__Init
-  USE mod_field_group
   IMPLICIT NONE
   
-    ALLOCATE(field_definition)
-    CALL field_group__new(field_definition,"field_definition")
-    
+   CALL field_group__new(field_definition,"field_definition")
+
   END SUBROUTINE field_definition__Init
+  
         
 END MODULE mod_field_definition
Index: /XMLIO_SERVER/trunk/src/XMLIO/mod_field_group.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/mod_field_group.f90	(revision 25)
+++ /XMLIO_SERVER/trunk/src/XMLIO/mod_field_group.f90	(revision 26)
@@ -16,6 +16,6 @@
   INCLUDE "vector_field_group_def.inc"  
 
-  TYPE(vector_field_group),POINTER      :: field_group_Ids
-  TYPE(sorted_list),POINTER,PRIVATE     :: Ids 
+  TYPE(vector_field_group),SAVE,POINTER      :: field_group_Ids
+  TYPE(sorted_list),POINTER,SAVE,PRIVATE     :: Ids 
 
 CONTAINS
@@ -23,9 +23,17 @@
   INCLUDE "vector_field_group_contains.inc"
 
+
+  SUBROUTINE field_group__swap_context(saved_field_group_ids, saved_ids)
+  IMPLICIT NONE
+    TYPE(vector_field_group),POINTER   :: saved_field_group_Ids
+    TYPE(sorted_list),POINTER          :: saved_Ids
+    
+    field_group_ids=>saved_field_group_ids 
+    ids=>saved_ids
+    
+  END SUBROUTINE field_group__swap_context
+
   SUBROUTINE field_group__init
   IMPLICIT NONE
-    
-    ALLOCATE(field_group_Ids)
-    ALLOCATE(Ids)
     
     CALL vector_field_group__new(field_group_Ids)
Index: /XMLIO_SERVER/trunk/src/XMLIO/mod_file.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/mod_file.f90	(revision 25)
+++ /XMLIO_SERVER/trunk/src/XMLIO/mod_file.f90	(revision 26)
@@ -30,9 +30,17 @@
   INCLUDE 'vector_file_contains.inc'
 
+  SUBROUTINE file__swap_context(saved_file_ids,saved_ids)
+  IMPLICIT NONE
+    TYPE(vector_file),POINTER      :: saved_file_Ids
+    TYPE(sorted_list),POINTER      :: saved_Ids
+    
+    file_ids=>saved_file_ids
+    ids=>saved_ids 
+ 
+  END SUBROUTINE file__swap_context
+
+
   SUBROUTINE file__init
   IMPLICIT NONE
-    
-    ALLOCATE(file_Ids)
-    ALLOCATE(Ids)
     
     CALL vector_file__new(file_Ids)
Index: /XMLIO_SERVER/trunk/src/XMLIO/mod_file_definition.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/mod_file_definition.f90	(revision 25)
+++ /XMLIO_SERVER/trunk/src/XMLIO/mod_file_definition.f90	(revision 26)
@@ -6,9 +6,16 @@
 CONTAINS
 
+  SUBROUTINE file_definition__swap_context(saved_file_definition)
+  IMPLICIT NONE
+    TYPE(file_group),POINTER      :: saved_file_definition
+     
+    file_definition=>saved_file_definition
+ 
+  END SUBROUTINE file_definition__swap_context
+
   SUBROUTINE file_definition__Init
   USE mod_file_group
   IMPLICIT NONE
   
-    ALLOCATE(file_definition)
     CALL file_group__new(file_definition,"file_definition")
     
Index: /XMLIO_SERVER/trunk/src/XMLIO/mod_file_group.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/mod_file_group.f90	(revision 25)
+++ /XMLIO_SERVER/trunk/src/XMLIO/mod_file_group.f90	(revision 26)
@@ -15,6 +15,6 @@
   INCLUDE "vector_file_group_def.inc"  
 
-  TYPE(vector_file_group),POINTER       :: file_group_Ids
-  TYPE(sorted_list),POINTER,PRIVATE     :: Ids 
+  TYPE(vector_file_group),POINTER,SAVE       :: file_group_Ids
+  TYPE(sorted_list),POINTER,PRIVATE,SAVE     :: Ids 
 
 CONTAINS
@@ -22,9 +22,16 @@
   INCLUDE "vector_file_group_contains.inc"
 
+  SUBROUTINE file_group__swap_context(saved_file_group_ids,saved_ids)
+  IMPLICIT NONE
+    TYPE(vector_file_group),POINTER      :: saved_file_group_Ids
+    TYPE(sorted_list),POINTER            :: saved_Ids
+    
+    file_group_ids=>saved_file_group_ids
+    ids=>saved_ids 
+ 
+  END SUBROUTINE file_group__swap_context
+
   SUBROUTINE file_group__init
   IMPLICIT NONE
-    
-    ALLOCATE(file_group_Ids)
-    ALLOCATE(Ids)
     
     CALL vector_file_group__new(file_group_Ids)
Index: /XMLIO_SERVER/trunk/src/XMLIO/mod_grid.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/mod_grid.f90	(revision 25)
+++ /XMLIO_SERVER/trunk/src/XMLIO/mod_grid.f90	(revision 26)
@@ -29,9 +29,16 @@
   INCLUDE 'vector_grid_contains.inc'
 
+  SUBROUTINE grid__swap_context(saved_grid_Ids,saved_Ids)
+  IMPLICIT NONE
+    TYPE(vector_grid),POINTER          :: saved_grid_Ids
+    TYPE(sorted_list),POINTER          :: saved_Ids 
+    
+    grid_ids=>saved_grid_ids
+    ids=>saved_ids
+  END SUBROUTINE grid__swap_context
+  
+  
   SUBROUTINE grid__init
   IMPLICIT NONE
-    
-    ALLOCATE(grid_Ids)
-    ALLOCATE(Ids)
     
     CALL vector_grid__new(grid_Ids)
Index: /XMLIO_SERVER/trunk/src/XMLIO/mod_grid_definition.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/mod_grid_definition.f90	(revision 25)
+++ /XMLIO_SERVER/trunk/src/XMLIO/mod_grid_definition.f90	(revision 26)
@@ -6,12 +6,19 @@
 CONTAINS
 
+  SUBROUTINE grid_definition__swap_context(saved_grid_definition)      
+  IMPLICIT NONE
+    TYPE(grid_group),POINTER :: saved_grid_definition
+    
+    grid_definition=>saved_grid_definition
+    
+  END SUBROUTINE grid_definition__swap_context 
+
   SUBROUTINE grid_definition__Init
   USE mod_grid_group
   IMPLICIT NONE
   
-    ALLOCATE(grid_definition)
     CALL grid_group__new(grid_definition,"grid_definition")
     
   END SUBROUTINE grid_definition__Init
-        
+ 
 END MODULE mod_grid_definition
Index: /XMLIO_SERVER/trunk/src/XMLIO/mod_grid_group.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/mod_grid_group.f90	(revision 25)
+++ /XMLIO_SERVER/trunk/src/XMLIO/mod_grid_group.f90	(revision 26)
@@ -15,6 +15,6 @@
   INCLUDE "vector_grid_group_def.inc"  
 
-  TYPE(vector_grid_group),POINTER       :: grid_group_Ids
-  TYPE(sorted_list),POINTER,PRIVATE     :: Ids 
+  TYPE(vector_grid_group),POINTER,SAVE       :: grid_group_Ids
+  TYPE(sorted_list),POINTER,SAVE,PRIVATE     :: Ids 
 
 CONTAINS
@@ -22,9 +22,16 @@
   INCLUDE "vector_grid_group_contains.inc"
 
+  SUBROUTINE grid_group__swap_context(saved_grid_group_Ids,saved_ids)
+  IMPLICIT NONE
+  TYPE(vector_grid_group),POINTER       :: saved_grid_group_Ids
+  TYPE(sorted_list),POINTER             :: saved_Ids 
+   
+   grid_group_ids=>saved_grid_group_ids
+   ids=>saved_ids
+   
+  END SUBROUTINE grid_group__swap_context
+   
   SUBROUTINE grid_group__init
   IMPLICIT NONE
-    
-    ALLOCATE(grid_group_Ids)
-    ALLOCATE(Ids)
     
     CALL vector_grid_group__new(grid_group_Ids)
Index: /XMLIO_SERVER/trunk/src/XMLIO/mod_parse_xml.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/mod_parse_xml.f90	(revision 25)
+++ /XMLIO_SERVER/trunk/src/XMLIO/mod_parse_xml.f90	(revision 26)
@@ -28,5 +28,5 @@
     CHARACTER(len=100) :: node_name
      
-     IF (hasChildNodes(root)) THEN
+    IF (hasChildNodes(root)) THEN
       child_list => getChildnodes(root)
 
@@ -38,5 +38,5 @@
           
            CASE ('simulation') 
-             CALL parsing_definition(child_node)
+             CALL parsing_simulation(child_node)
 
            CASE DEFAULT
@@ -45,4 +45,36 @@
                CALL Warning("mod_parse_xml:parsing_root")
              ENDIF
+        END SELECT
+      ENDDO
+    ENDIF
+             
+  END SUBROUTINE parsing_root
+
+  SUBROUTINE parsing_simulation(root)
+  IMPLICIT NONE
+    TYPE(fnode), POINTER :: root
+    TYPE(fnode), POINTER :: child_node
+    TYPE(fnodeList), POINTER :: child_list
+
+    INTEGER :: il
+    CHARACTER(len=100) :: node_name
+     
+     IF (hasChildNodes(root)) THEN
+      child_list => getChildnodes(root)
+
+      DO il=0,getLength(child_list)-1
+        child_node => item(child_list,il)
+        node_name=getNodename(child_node)
+          
+        SELECT CASE (TRIM(node_name)) 
+          
+           CASE ('context') 
+             CALL parsing_context(child_node)
+
+           CASE DEFAULT
+             IF (is_bad_node(node_name)) THEN
+               WRITE(message,*) 'Unknown node <<',TRIM(node_name),'>> while parsing simulation'
+               CALL Warning("mod_parse_xml:parsing_simulationt")
+             ENDIF
          END SELECT
        
@@ -50,27 +82,36 @@
     ENDIF
              
-  END SUBROUTINE parsing_root
-
-
-  SUBROUTINE parsing_definition(root)
+  END SUBROUTINE parsing_simulation
+
+  SUBROUTINE parsing_context(node)
+  USE mod_context
   USE mod_axis_definition
   USE mod_grid_definition
   USE mod_field_definition
   USE mod_file_definition
-  
-  IMPLICIT NONE
-    TYPE(fnode), POINTER :: root
-    TYPE(fnode), POINTER :: child_node
+  IMPLICIT NONE  
+    TYPE(fnode), POINTER         :: node
+    
+    TYPE(fnode), POINTER     :: child_node
     TYPE(fnodeList), POINTER :: child_list
-
-    INTEGER :: il
-    CHARACTER(len=100) :: node_name
-
-    IF (hasChildNodes(root)) THEN
-      child_list => getChildnodes(root)
+    TYPE(axis),POINTER       :: attribute
+    LOGICAL                  :: is_root
+    INTEGER :: il
+    CHARACTER(len=100) :: node_name
+    CHARACTER(len=100) :: value
+    
+    IF (is_attribute_exist(node,"id")) THEN
+      value=getAttribute(node,"id")
+      CALL context__create(TRIM(value))  
+      CALL context__swap(TRIM(value))
+    ENDIF
+    
+    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)) 
           
@@ -89,19 +130,15 @@
            CASE DEFAULT
              IF (is_bad_node(node_name)) THEN
-               WRITE(message,*) 'Unknown node <<',TRIM(node_name),'>> while parsing definition'
-               CALL Warning("mod_parse_xml:parsing_definition")
+               WRITE(message,*) 'Unknown node <<',TRIM(node_name),'>> while parsing context'
+               CALL Warning("mod_parse_xml:parsing_context")
              ENDIF   
-         END SELECT
-       
-       ENDDO
-    ENDIF
-    
-  END SUBROUTINE parsing_definition
- 
-
-
-
-
-  
+        END SELECT
+      ENDDO
+
+    ENDIF
+
+  END SUBROUTINE parsing_context
+
+
   RECURSIVE SUBROUTINE parsing_axis_group(node,parent,root)
   USE mod_axis_definition
@@ -493,7 +530,4 @@
 
   END SUBROUTINE parsing_field_attribute 
-  
-  
-  
 
 
Index: /XMLIO_SERVER/trunk/src/XMLIO/vector_context_contains.inc
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/vector_context_contains.inc	(revision 26)
+++ /XMLIO_SERVER/trunk/src/XMLIO/vector_context_contains.inc	(revision 26)
@@ -0,0 +1,89 @@
+
+  SUBROUTINE vector_context__new(vect,vect_size)
+  use mod_xmlio_parameters
+  IMPLICIT NONE
+    TYPE(vector_context), INTENT(INOUT) :: vect
+    INTEGER, OPTIONAL, INTENT(IN) :: vect_size
+     
+    IF (ASSOCIATED(vect%at)) CALL vector_context__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_context__new
+  
+  SUBROUTINE vector_context__delete(vect)
+  IMPLICIT NONE
+    TYPE(vector_context), 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 context__delete() ???
+    ENDDO 
+    
+    IF (ASSOCIATED(vect%at)) DEALLOCATE(vect%at)
+    vect%size_max=0
+    
+  END SUBROUTINE vector_context__delete
+  
+  SUBROUTINE vector_context__get_new(vect,pt_value,pos)
+  IMPLICIT NONE
+  
+    TYPE(vector_context), INTENT(INOUT)   :: vect
+    TYPE(context),POINTER                 :: pt_value
+    INTEGER,OPTIONAL,INTENT(OUT)         :: Pos
+    
+    IF (vect%size==vect%size_max) CALL vector_context__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_context__get_new
+
+  SUBROUTINE vector_context__set_new(vect,pt_value,pos)
+  IMPLICIT NONE
+  
+    TYPE(vector_context), INTENT(INOUT)   :: vect
+    TYPE(context),POINTER                 :: pt_value
+    INTEGER,OPTIONAL,INTENT(OUT)         :: Pos
+    
+    IF (vect%size==vect%size_max) CALL vector_context__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_context__set_new
+  
+  SUBROUTINE vector_context__increase(vect)
+    TYPE(vector_context), INTENT(INOUT) :: vect
+    TYPE (Pt_context), 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_context__increase 
+    
Index: /XMLIO_SERVER/trunk/src/XMLIO/vector_context_def.inc
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/vector_context_def.inc	(revision 26)
+++ /XMLIO_SERVER/trunk/src/XMLIO/vector_context_def.inc	(revision 26)
@@ -0,0 +1,17 @@
+
+  TYPE,PRIVATE :: Pt_context 
+    TYPE (context),POINTER :: Pt
+    LOGICAL               :: owned
+  END TYPE Pt_context
+
+  TYPE vector_context
+  
+    TYPE (Pt_context), POINTER, DIMENSION(:) :: at => NULL()
+    INTEGER :: size
+    
+    INTEGER :: size_max
+    REAL    :: grow_factor
+    INTEGER :: chunk
+  
+  END TYPE vector_context
+  
Index: /XMLIO_SERVER/trunk/src/XMLIO/xmlio.f90
===================================================================
--- /XMLIO_SERVER/trunk/src/XMLIO/xmlio.f90	(revision 25)
+++ /XMLIO_SERVER/trunk/src/XMLIO/xmlio.f90	(revision 26)
@@ -16,4 +16,5 @@
   USE string_function
   USE error_msg
+  USE mod_context
   
 CONTAINS
@@ -24,23 +25,9 @@
     CHARACTER(LEN=*),INTENT(IN) :: xml_file
     
-    CALL field__init
-    CALL field_group__Init
-    CALL field_definition__Init
-
-    CALL axis__init
-    CALL axis_group__Init
-    CALL axis_definition__Init
-
-    CALL grid__init
-    CALL grid_group__Init
-    CALL grid_definition__Init
-
-    CALL file__init
-    CALL file_group__Init
-    CALL file_definition__Init
-    
+    CALL context__init
     CALL parsing_xml_file(xml_file)
     
   END SUBROUTINE xmlio__init
+  
   
   SUBROUTINE xmlio__close_definition
