Index: dynamico_lmdz/aquaplanet/ICOSAGCM/src/write_field.f90
===================================================================
--- dynamico_lmdz/aquaplanet/ICOSAGCM/src/write_field.f90	(revision 3853)
+++ dynamico_lmdz/aquaplanet/ICOSAGCM/src/write_field.f90	(revision 3861)
@@ -1171,5 +1171,5 @@
       INTEGER :: nij
       CHARACTER(LEN=255) :: name
-      
+      INTEGER :: l,level_size, levId, dimlevId
             
       name=TRIM(ADJUSTL(name_in))
@@ -1223,5 +1223,5 @@
         status = NF90_DEF_DIM(ncid,'cell_i',ncell,ncellId)
         status = NF90_DEF_DIM(ncid,'nvert_i',nvert,nvertid)
-
+        level_size=0
         IF (Field(ind_b)%ndim==2)  THEN
           FieldVarId(NbField)%size=1
@@ -1231,13 +1231,20 @@
           ALLOCATE(FieldVarId(NbField)%nc_id(1))
           status = NF90_DEF_DIM(ncid,'lev',size(field(ind_b)%rval3d,2),dim3id)
+          level_size=size(field(ind_b)%rval3d,2)
         ELSE IF (Field(1)%ndim==4) THEN
           FieldVarId(NbField)%size=size(field(ind_b)%rval4d,3)
           ALLOCATE(FieldVarId(NbField)%nc_id(FieldVarId(NbField)%size))
           status = NF90_DEF_DIM(ncid,'lev',size(field(ind_b)%rval4d,2),dim3id)
+          level_size=size(field(ind_b)%rval4d,2)
 !          status = NF90_DEF_DIM(ncid,'Q',size(field(ind_b)%rval4d,3),dim4id)
         ENDIF
-      
+        PRINT*,"LEVEL_SIZE=",level_size
+
         status = NF90_DEF_DIM(ncid,'time_counter',NF90_UNLIMITED,timeId)
-      
+        IF (level_size>0) THEN
+          status = NF90_DEF_VAR(ncid,'lev',NF90_DOUBLE,(/ dim3id /),levId)
+          status = NF90_PUT_ATT(ncid,levId,"axis","Z")
+        ENDIF
+        
         status = NF90_DEF_VAR(ncid,'lon_i',NF90_DOUBLE,(/ ncellId /),lonId)
         status = NF90_PUT_ATT(ncid,lonId,"long_name","longitude")
@@ -1280,4 +1287,6 @@
       
         status = NF90_ENDDEF(ncid)      
+
+        if (level_size>0) status = NF90_PUT_VAR(ncid,levId,(/ (l,l=1,level_size) /))
          
          ALLOCATE(lon(ncell),lat(ncell),bounds_lon(0:nvert-1,ncell),bounds_lat(0:nvert-1,ncell))
Index: dynamico_lmdz/aquaplanet/ICOSAGCM/src/xios_mod.F90
===================================================================
--- dynamico_lmdz/aquaplanet/ICOSAGCM/src/xios_mod.F90	(revision 3853)
+++ dynamico_lmdz/aquaplanet/ICOSAGCM/src/xios_mod.F90	(revision 3861)
@@ -41,5 +41,5 @@
  IMPLICIT NONE
   TYPE(xios_context) :: ctx_hdl
-  TYPE(xios_time)      :: dtime
+  TYPE(xios_duration)      :: dtime
   REAL(rstd) :: lev_value(llm)
   REAL(rstd) :: lev_valuep1(llm+1)
@@ -56,6 +56,6 @@
    lev_value(:) = (/ (l,l=1,llm) /)     
    lev_valuep1(:) = (/ (l,l=1,llm+1) /)     
-   CALL xios_set_axis_attr("lev",size=llm ,value=lev_value) ;
-   CALL xios_set_axis_attr("levp1",size=llm+1 ,value=lev_value) ;
+   CALL xios_set_axis_attr("lev",n_glo=llm ,value=lev_value) ;
+   CALL xios_set_axis_attr("levp1",n_glo=llm+1 ,value=lev_value) ;
    
    ncell=0
@@ -104,7 +104,7 @@
 
   
-   CALL xios_set_domain_attr("i",ni_glo=ncell_tot, ibegin=displ+1, ni=ncell)
-   CALL xios_set_domain_attr("i", data_dim=1, type='unstructured' , nvertex=6)
-   CALL xios_set_domain_attr("i",lonvalue=lon, latvalue=lat, bounds_lon=bounds_lon, bounds_lat=bounds_lat)
+   CALL xios_set_domaingroup_attr("i",ni_glo=ncell_tot, ibegin=displ, ni=ncell)
+   CALL xios_set_domaingroup_attr("i", data_dim=1, type='unstructured' , nvertex=6)
+   CALL xios_set_domaingroup_attr("i",lonvalue_1d=lon, latvalue_1d=lat, bounds_lon_1d=bounds_lon, bounds_lat_1d=bounds_lat)
    
    DEALLOCATE(lon, lat, bounds_lon, bounds_lat) 
@@ -183,7 +183,7 @@
 
   
-   CALL xios_set_domain_attr("v",ni_glo=ncell_tot, ibegin=displ+1, ni=ncell)
+   CALL xios_set_domain_attr("v",ni_glo=ncell_tot, ibegin=displ, ni=ncell)
    CALL xios_set_domain_attr("v", data_dim=1, type='unstructured' , nvertex=3)
-   CALL xios_set_domain_attr("v",lonvalue=lon, latvalue=lat, bounds_lon=bounds_lon, bounds_lat=bounds_lat)
+   CALL xios_set_domain_attr("v",lonvalue_1d=lon, latvalue_1d=lat, bounds_lon_1d=bounds_lon, bounds_lat_1d=bounds_lat)
 
 
@@ -239,4 +239,49 @@
       
  END SUBROUTINE xios_write_field
+
+ SUBROUTINE xios_read_field(name,field)
+ USE field_mod
+ IMPLICIT NONE 
+   CHARACTER(LEN=*),INTENT(IN) :: name
+   TYPE(t_field), POINTER :: field(:)
+   CHARACTER(LEN=10) :: str_number
+   INTEGER :: iq
+
+!$OMP BARRIER
+!$OMP MASTER
+   
+   IF (Field(1)%field_type==field_T) THEN
+     IF (field(1)%ndim==2) THEN
+        CALL xios_read_field_scalar(name,field,1)
+      ELSE IF (field(1)%ndim==3) THEN
+        CALL xios_read_field_scalar(name,field,size(field(1)%rval3d,2))
+      ELSE IF (field(1)%ndim==4) THEN
+        DO iq=1,size(field(1)%rval4d,3)
+          WRITE(str_number,'(i10)') iq
+          CALL xios_read_field_scalar(name//TRIM(ADJUSTL(str_number)),field,size(field(1)%rval4d,2),iq)
+        ENDDO
+      ELSE
+        PRINT *, "xios_write_field : dimension > 4 are not supported for now"
+      ENDIF
+    ELSE IF (Field(1)%field_type==field_Z) THEN
+     IF (field(1)%ndim==2) THEN
+        CALL xios_read_field_vort(name,field,1)
+      ELSE IF (field(1)%ndim==3) THEN
+        CALL xios_read_field_vort(name,field,size(field(1)%rval3d,2))
+      ELSE IF (field(1)%ndim==4) THEN
+        DO iq=1,size(field(1)%rval4d,3)
+          WRITE(str_number,'(i10)') iq
+          CALL xios_read_field_vort(name//TRIM(ADJUSTL(str_number)),field,size(field(1)%rval4d,2),iq)
+        ENDDO
+      ELSE
+        PRINT *, "xios_write_field : dimension > 4 are not supported for now"
+      ENDIF
+    ENDIF
+!$OMP END MASTER
+!$OMP BARRIER
+      
+ END SUBROUTINE xios_read_field
+
+
  
  SUBROUTINE xios_write_field_scalar(name,field,nlev,iq)
@@ -311,4 +356,79 @@
  
  END SUBROUTINE xios_write_field_scalar  
+
+
+ SUBROUTINE xios_read_field_scalar(name,field,nlev,iq)
+ USE genmod
+ USE mpipara
+ USE xios
+ USE grid_param
+ USE domain_mod
+ USE dimensions
+ USE spherical_geom_mod
+ USE geometry
+ USE mpi_mod
+ IMPLICIT NONE 
+   CHARACTER(LEN=*),INTENT(IN) :: name
+   TYPE(t_field), POINTER :: field(:)
+   INTEGER,INTENT(IN) :: nlev
+   INTEGER,INTENT(IN),OPTIONAL :: iq
+   
+   REAL(rstd) :: field_tmp(ncell_i,nlev)
+   TYPE(t_domain),POINTER :: d
+   INTEGER :: n,i,j,ij,ind
+
+   CALL xios_recv_field(name,field_tmp)
+   
+   IF (field(1)%ndim==2) THEN
+     n=0
+     DO ind=1,ndomain
+       
+       d=>domain(ind)
+        
+       DO j=d%jj_begin,d%jj_end
+         DO i=d%ii_begin,d%ii_end
+           IF (d%own(i,j)) THEN
+             n=n+1
+             ij=d%iim*(j-1)+i
+             field(ind)%rval2d(ij)=field_tmp(n,1)
+           ENDIF
+         ENDDO
+       ENDDO
+     ENDDO
+   ELSE IF (field(1)%ndim==3) THEN
+     n=0
+     DO ind=1,ndomain
+       d=>domain(ind)
+        
+       DO j=d%jj_begin,d%jj_end
+         DO i=d%ii_begin,d%ii_end
+           IF (d%own(i,j)) THEN
+             n=n+1
+             ij=d%iim*(j-1)+i
+             field(ind)%rval3d(ij,:)=field_tmp(n,:)
+           ENDIF
+         ENDDO
+       ENDDO
+     ENDDO
+   ELSE IF (field(1)%ndim==4) THEN
+     n=0
+     DO ind=1,ndomain
+       d=>domain(ind)
+        
+       DO j=d%jj_begin,d%jj_end
+         DO i=d%ii_begin,d%ii_end
+           IF (d%own(i,j)) THEN
+             n=n+1
+             ij=d%iim*(j-1)+i
+             field(ind)%rval4d(ij,:,iq)=field_tmp(n,:)
+           ENDIF
+         ENDDO
+       ENDDO
+     ENDDO     
+   ENDIF
+ 
+ END SUBROUTINE xios_read_field_scalar
+
+
       
  SUBROUTINE xios_write_field_vort(name,field,nlev,iq)
@@ -409,4 +529,108 @@
  
  END SUBROUTINE xios_write_field_vort 
+
+ SUBROUTINE xios_read_field_vort(name,field,nlev,iq)
+ USE genmod
+ USE mpipara
+ USE xios
+ USE grid_param
+ USE domain_mod
+ USE dimensions
+ USE spherical_geom_mod
+ USE geometry
+ USE mpi_mod
+ IMPLICIT NONE 
+   CHARACTER(LEN=*),INTENT(IN) :: name
+   TYPE(t_field), POINTER :: field(:)
+   INTEGER,INTENT(IN) :: nlev
+   INTEGER,INTENT(IN),OPTIONAL :: iq
+   
+   REAL(rstd) :: field_tmp(ncell_v,nlev)
+   TYPE(t_domain),POINTER :: d
+   INTEGER :: n,i,j,ij,ind
+
+   CALL xios_recv_field(name,field_tmp)
+
+   
+   IF (field(1)%ndim==2) THEN
+     n=0
+     DO ind=1,ndomain
+       d=>domain(ind)
+       CALL swap_dimensions(ind)  
+       
+       DO j=d%jj_begin+1,d%jj_end
+         DO i=d%ii_begin,d%ii_end-1
+           n=n+1
+           ij=iim*(j-1)+i
+           field(ind)%rval2d(ij+z_down)=Field_tmp(n,1)
+         ENDDO
+       ENDDO
+
+       DO j=d%jj_begin,d%jj_end-1
+         DO i=d%ii_begin+1,d%ii_end
+           n=n+1
+           ij=iim*(j-1)+i
+           Field_tmp(n,1)=field(ind)%rval2d(ij+z_up)
+           field(ind)%rval2d(ij+z_up)=Field_tmp(n,1)
+          ENDDO
+       ENDDO
+          
+     ENDDO
+
+   ELSE IF (field(1)%ndim==3) THEN
+     n=0
+     DO ind=1,ndomain
+       d=>domain(ind)
+       CALL swap_dimensions(ind)    
+             
+       DO j=d%jj_begin+1,d%jj_end
+         DO i=d%ii_begin,d%ii_end-1
+           n=n+1
+           ij=iim*(j-1)+i
+           field(ind)%rval3d(ij+z_down,:)=Field_tmp(n,:)
+         ENDDO
+       ENDDO
+
+       DO j=d%jj_begin,d%jj_end-1
+         DO i=d%ii_begin+1,d%ii_end
+           n=n+1
+           ij=iim*(j-1)+i
+           field(ind)%rval3d(ij+z_up,:)=Field_tmp(n,:)
+          ENDDO
+       ENDDO
+          
+     ENDDO
+
+   ELSE IF (field(1)%ndim==4) THEN
+     n=0
+     DO ind=1,ndomain
+       d=>domain(ind)
+       CALL swap_dimensions(ind) 
+               
+       DO j=d%jj_begin+1,d%jj_end
+         DO i=d%ii_begin,d%ii_end-1
+           n=n+1
+           ij=iim*(j-1)+i
+           field(ind)%rval4d(ij+z_down,:,iq)=Field_tmp(n,:)
+         ENDDO
+       ENDDO
+
+       DO j=d%jj_begin,d%jj_end-1
+         DO i=d%ii_begin+1,d%ii_end
+           n=n+1
+           ij=iim*(j-1)+i
+           field(ind)%rval4d(ij+z_up,:,iq)=Field_tmp(n,:)
+          ENDDO
+       ENDDO
+          
+     ENDDO
+
+   ENDIF
+ 
+ END SUBROUTINE xios_read_field_vort 
+
+
+
+
   
  SUBROUTINE xios_write_field_finalize
