Index: /codes/icosagcm/trunk/src/etat0.f90
===================================================================
--- /codes/icosagcm/trunk/src/etat0.f90	(revision 482)
+++ /codes/icosagcm/trunk/src/etat0.f90	(revision 483)
@@ -14,5 +14,6 @@
   
   SUBROUTINE init_etat0
-  USE etat0_database_mod
+  USE etat0_database_mod, init_etat0_database => init_etat0 
+  USE etat0_start_file_mod, init_etat0_start_file => init_etat0 
   IMPLICIT NONE
 
@@ -26,4 +27,5 @@
       CASE ('williamson91.6')
       CASE ('start_file')
+        CALL init_etat0_start_file
       CASE ('database')
         CALL init_etat0_database
Index: /codes/icosagcm/trunk/src/etat0_database.f90
===================================================================
--- /codes/icosagcm/trunk/src/etat0_database.f90	(revision 482)
+++ /codes/icosagcm/trunk/src/etat0_database.f90	(revision 483)
@@ -4,12 +4,14 @@
 CONTAINS
 
-  SUBROUTINE init_etat0_database
+  SUBROUTINE init_etat0
   USE xios_mod
+  USE omp_para
   IMPLICIT NONE
   
-    CALL xios_set_fieldgroup_attr("read_fields",enabled=.TRUE.)
-    CALL xios_set_filegroup_attr("read_files",enabled=.TRUE.)
-
-  END SUBROUTINE init_etat0_database
+    IF (is_omp_master) THEN
+      CALL xios_set_fieldgroup_attr("read_fields",enabled=.TRUE.)
+      CALL xios_set_filegroup_attr("read_files",enabled=.TRUE.)
+    ENDIF
+  END SUBROUTINE init_etat0
 
   SUBROUTINE etat0(f_ps,f_phis,f_theta_rhodz,f_u, f_q)
Index: /codes/icosagcm/trunk/src/etat0_start_file.f90
===================================================================
--- /codes/icosagcm/trunk/src/etat0_start_file.f90	(revision 482)
+++ /codes/icosagcm/trunk/src/etat0_start_file.f90	(revision 483)
@@ -6,5 +6,15 @@
 CONTAINS
   
-   
+  SUBROUTINE init_etat0
+  USE xios_mod
+  USE omp_para
+  IMPLICIT NONE
+    
+    IF (is_omp_master) THEN
+      IF (using_xios) CALL xios_set_file_attr("start", enabled=.TRUE.)
+    ENDIF
+    
+  END SUBROUTINE init_etat0 
+  
   SUBROUTINE etat0(f_ps,f_phis,f_theta_rhodz,f_u, f_q)
   USE icosa
Index: /codes/icosagcm/trunk/src/icosagcm.f90
===================================================================
--- /codes/icosagcm/trunk/src/icosagcm.f90	(revision 482)
+++ /codes/icosagcm/trunk/src/icosagcm.f90	(revision 483)
@@ -20,4 +20,6 @@
   USE physics_mod
   USE tracer_mod
+  USE restart_mod
+  USE etat0_mod
   IMPLICIT NONE
   
@@ -31,5 +33,4 @@
     CALL compute_domain
     CALL init_transfert
-    CALL init_etat0
     CALL init_writefield
     CALL init_trace
@@ -48,4 +49,6 @@
     IF (is_mpi_root) CALL write_apbp
     CALL init_time
+    CALL init_restart
+    CALL init_etat0
 
     CALL output_field_init
Index: /codes/icosagcm/trunk/src/restart.f90
===================================================================
--- /codes/icosagcm/trunk/src/restart.f90	(revision 482)
+++ /codes/icosagcm/trunk/src/restart.f90	(revision 483)
@@ -9,4 +9,29 @@
 
 CONTAINS
+  
+  SUBROUTINE init_restart
+  USE xios_mod
+  USE icosa
+  USE time_mod
+  USE omp_para
+  IMPLICIT NONE
+  CHARACTER(LEN=255) :: start_file_name
+  CHARACTER(LEN=255) :: restart_file_name
+    
+    IF (using_xios) THEN
+      start_file_name="start"
+      CALL getin("start_file_name",start_file_name)
+      restart_file_name="restart"
+      CALL getin("restart_file_name",restart_file_name)
+      IF (is_omp_master) THEN
+        CALL xios_set_file_attr("start",name=TRIM(ADJUSTL(start_file_name)),output_freq=(itaumax+1)*xios_timestep)
+        CALL xios_set_file_attr("restart",name=TRIM(ADJUSTL(restart_file_name)),output_freq=itaumax*xios_timestep)
+        CALL xios_set_fieldgroup_attr("group_restart", freq_op=itaumax*xios_timestep)
+        CALL xios_set_axis_attr("lev_read", n_glo=llm)
+      ENDIF
+    ENDIF
+    
+  END SUBROUTINE init_restart
+  
   
   SUBROUTINE write_restart(it,field0 ,field1 ,field2 ,field3 ,field4 ,field5 ,field6 ,field7 ,field8 ,field9,   &
@@ -18,9 +43,10 @@
   USE netcdf_mod
   USE mpipara
+  USE omp_para
   USE getin_mod
   USE spherical_geom_mod
   USE transfert_mod
   USE disvert_mod
- 
+  USE xios_mod
   IMPLICIT NONE 
   INTEGER,INTENT(IN)     :: it
@@ -47,122 +73,150 @@
     CALL getin("restart_file_name",restart_file_name)
 
-!$OMP MASTER
-
-    nfield=0
-    IF (PRESENT(field0))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field0  ; ENDIF
-    IF (PRESENT(field1))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field1  ; ENDIF
-    IF (PRESENT(field2))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field2  ; ENDIF
-    IF (PRESENT(field3))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field3  ; ENDIF
-    IF (PRESENT(field4))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field4  ; ENDIF
-    IF (PRESENT(field5))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field5  ; ENDIF
-    IF (PRESENT(field6))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field6  ; ENDIF
-    IF (PRESENT(field7))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field7  ; ENDIF
-    IF (PRESENT(field8))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field8  ; ENDIF
-    IF (PRESENT(field9))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field9  ; ENDIF
-    IF (PRESENT(field10)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field10 ; ENDIF
-    IF (PRESENT(field11)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field11 ; ENDIF
-    IF (PRESENT(field12)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field12 ; ENDIF
-    IF (PRESENT(field13)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field13 ; ENDIF
-    IF (PRESENT(field14)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field14 ; ENDIF
-    IF (PRESENT(field15)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field15 ; ENDIF
-    IF (PRESENT(field16)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field16 ; ENDIF
-    IF (PRESENT(field17)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field17 ; ENDIF
-    IF (PRESENT(field18)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field18 ; ENDIF
-    IF (PRESENT(field19)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field19 ; ENDIF
-    
-      
-
-    IF (is_mpi_root) THEN
-      status = NF90_CREATE(TRIM(ADJUSTL(restart_file_name))//'.nc', NF90_CLOBBER, ncid)
-      status = NF90_DEF_DIM(ncid,'cell',ncell_glo,cellId)
-      status = NF90_DEF_DIM(ncid,'edge',3*ncell_glo,edgeId)
-      status = NF90_DEF_DIM(ncid,'lev',llm,levId)
-      status = NF90_DEF_DIM(ncid,'nvert',nvert,vertId)
-      status = NF90_DEF_DIM(ncid,'nq',nqtot,nqId)
-      status = NF90_PUT_ATT(ncid,NF90_GLOBAL,"iteration",it)
-      
-      status = NF90_DEF_VAR(ncid,'lon',NF90_DOUBLE,(/ cellId /),lonId)
-      status = NF90_PUT_ATT(ncid,lonId,"long_name","longitude")
-      status = NF90_PUT_ATT(ncid,lonId,"units","degrees_east")
-      status = NF90_PUT_ATT(ncid,lonId,"bounds","bounds_lon")
-      status = NF90_DEF_VAR(ncid,'lat',NF90_DOUBLE,(/ cellId /),latId)
-      status = NF90_PUT_ATT(ncid,latId,"long_name","latitude")
-      status = NF90_PUT_ATT(ncid,latId,"units","degrees_north")
-      status = NF90_PUT_ATT(ncid,latId,"bounds","bounds_lat")
-      status = NF90_DEF_VAR(ncid,'bounds_lon',NF90_DOUBLE,(/ vertId,cellId /),bounds_lonId)
-      status = NF90_DEF_VAR(ncid,'bounds_lat',NF90_DOUBLE,(/ vertId,cellId /),bounds_latId)
-      status = NF90_DEF_VAR(ncid,'lev',NF90_DOUBLE,(/ levId /),levAxisId)
-      status = NF90_PUT_ATT(ncid,levAxisId,"axis","Z")
-      status = NF90_PUT_ATT(ncid,levAxisId,"units","Pa")
-      status = NF90_PUT_ATT(ncid,levAxisId,"positive","down")
-      
+    IF (using_xios) THEN
+      IF (PRESENT(field0))  THEN ; CALL  xios_write_field(TRIM(field0(1)%name)//'_restart',field0)  ; ENDIF
+      IF (PRESENT(field1))  THEN ; CALL  xios_write_field(TRIM(field1(1)%name)//'_restart',field1)  ; ENDIF
+      IF (PRESENT(field2))  THEN ; CALL  xios_write_field(TRIM(field2(1)%name)//'_restart',field2)  ; ENDIF
+      IF (PRESENT(field3))  THEN ; CALL  xios_write_field(TRIM(field3(1)%name)//'_restart',field3)  ; ENDIF
+      IF (PRESENT(field4))  THEN ; CALL  xios_write_field(TRIM(field4(1)%name)//'_restart',field4)  ; ENDIF
+      IF (PRESENT(field5))  THEN ; CALL  xios_write_field(TRIM(field5(1)%name)//'_restart',field5)  ; ENDIF
+      IF (PRESENT(field6))  THEN ; CALL  xios_write_field(TRIM(field6(1)%name)//'_restart',field6)  ; ENDIF
+      IF (PRESENT(field7))  THEN ; CALL  xios_write_field(TRIM(field7(1)%name)//'_restart',field7)  ; ENDIF
+      IF (PRESENT(field8))  THEN ; CALL  xios_write_field(TRIM(field8(1)%name)//'_restart',field8)  ; ENDIF
+      IF (PRESENT(field9))  THEN ; CALL  xios_write_field(TRIM(field9(1)%name)//'_restart',field9)  ; ENDIF
+      IF (PRESENT(field10))  THEN ; CALL  xios_write_field(TRIM(field10(1)%name)//'_restart',field10)  ; ENDIF
+      IF (PRESENT(field11))  THEN ; CALL  xios_write_field(TRIM(field11(1)%name)//'_restart',field11)  ; ENDIF
+      IF (PRESENT(field12))  THEN ; CALL  xios_write_field(TRIM(field12(1)%name)//'_restart',field12)  ; ENDIF
+      IF (PRESENT(field13))  THEN ; CALL  xios_write_field(TRIM(field13(1)%name)//'_restart',field13)  ; ENDIF
+      IF (PRESENT(field14))  THEN ; CALL  xios_write_field(TRIM(field14(1)%name)//'_restart',field14)  ; ENDIF
+      IF (PRESENT(field15))  THEN ; CALL  xios_write_field(TRIM(field15(1)%name)//'_restart',field15)  ; ENDIF
+      IF (PRESENT(field16))  THEN ; CALL  xios_write_field(TRIM(field16(1)%name)//'_restart',field16)  ; ENDIF
+      IF (PRESENT(field17))  THEN ; CALL  xios_write_field(TRIM(field17(1)%name)//'_restart',field17)  ; ENDIF
+      IF (PRESENT(field18))  THEN ; CALL  xios_write_field(TRIM(field18(1)%name)//'_restart',field18)  ; ENDIF
+      IF (PRESENT(field19))  THEN ; CALL  xios_write_field(TRIM(field19(1)%name)//'_restart',field19)  ; ENDIF
+      IF (is_omp_master) CALL xios_send_field("it_restart",it*1.0)
+
+    ELSE
+
+    !$OMP MASTER
+      
+      nfield=0
+      IF (PRESENT(field0))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field0  ; ENDIF
+      IF (PRESENT(field1))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field1  ; ENDIF
+      IF (PRESENT(field2))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field2  ; ENDIF
+      IF (PRESENT(field3))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field3  ; ENDIF
+      IF (PRESENT(field4))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field4  ; ENDIF
+      IF (PRESENT(field5))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field5  ; ENDIF
+      IF (PRESENT(field6))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field6  ; ENDIF
+      IF (PRESENT(field7))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field7  ; ENDIF
+      IF (PRESENT(field8))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field8  ; ENDIF
+      IF (PRESENT(field9))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field9  ; ENDIF
+      IF (PRESENT(field10)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field10 ; ENDIF
+      IF (PRESENT(field11)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field11 ; ENDIF
+      IF (PRESENT(field12)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field12 ; ENDIF
+      IF (PRESENT(field13)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field13 ; ENDIF
+      IF (PRESENT(field14)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field14 ; ENDIF
+      IF (PRESENT(field15)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field15 ; ENDIF
+      IF (PRESENT(field16)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field16 ; ENDIF
+      IF (PRESENT(field17)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field17 ; ENDIF
+      IF (PRESENT(field18)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field18 ; ENDIF
+      IF (PRESENT(field19)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field19 ; ENDIF
+      
+        
+
+      IF (is_mpi_root) THEN
+        status = NF90_CREATE(TRIM(ADJUSTL(restart_file_name))//'.nc', NF90_CLOBBER, ncid)
+        status = NF90_DEF_DIM(ncid,'cell',ncell_glo,cellId)
+        status = NF90_DEF_DIM(ncid,'edge',3*ncell_glo,edgeId)
+        status = NF90_DEF_DIM(ncid,'lev',llm,levId)
+        status = NF90_DEF_DIM(ncid,'nvert',nvert,vertId)
+        status = NF90_DEF_DIM(ncid,'nq',nqtot,nqId)
+        status = NF90_PUT_ATT(ncid,NF90_GLOBAL,"iteration",it)
+        
+        status = NF90_DEF_VAR(ncid,'lon',NF90_DOUBLE,(/ cellId /),lonId)
+        status = NF90_PUT_ATT(ncid,lonId,"long_name","longitude")
+        status = NF90_PUT_ATT(ncid,lonId,"units","degrees_east")
+        status = NF90_PUT_ATT(ncid,lonId,"bounds","bounds_lon")
+        status = NF90_DEF_VAR(ncid,'lat',NF90_DOUBLE,(/ cellId /),latId)
+        status = NF90_PUT_ATT(ncid,latId,"long_name","latitude")
+        status = NF90_PUT_ATT(ncid,latId,"units","degrees_north")
+        status = NF90_PUT_ATT(ncid,latId,"bounds","bounds_lat")
+        status = NF90_DEF_VAR(ncid,'bounds_lon',NF90_DOUBLE,(/ vertId,cellId /),bounds_lonId)
+        status = NF90_DEF_VAR(ncid,'bounds_lat',NF90_DOUBLE,(/ vertId,cellId /),bounds_latId)
+        status = NF90_DEF_VAR(ncid,'lev',NF90_DOUBLE,(/ levId /),levAxisId)
+        status = NF90_PUT_ATT(ncid,levAxisId,"axis","Z")
+        status = NF90_PUT_ATT(ncid,levAxisId,"units","Pa")
+        status = NF90_PUT_ATT(ncid,levAxisId,"positive","down")
+        
+        DO nf=1,nfield
+          field=>field_array(nf)%field
+          IF (field(1)%field_type==field_T) THEN
+            IF (field(1)%ndim==2) THEN
+              status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(field(1)%name)),NF90_DOUBLE,(/ cellId /),fieldId(nf))
+              status = NF90_PUT_ATT(ncid,FieldId(nf),"coordinates","lon lat")
+            ELSE IF (field(1)%ndim==3) THEN
+              status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(field(1)%name)),NF90_DOUBLE,(/ cellId, levId /),fieldId(nf))
+              status = NF90_PUT_ATT(ncid,FieldId(nf),"coordinates","lev lon lat")
+            ELSE IF (field(1)%ndim==4) THEN
+              status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(field(1)%name)),NF90_DOUBLE,(/ cellId, levId,nqId /),fieldId(nf))
+              status = NF90_PUT_ATT(ncid,FieldId(nf),"coordinates","nq lev lon lat")
+            ENDIF
+          ELSE IF (field(1)%field_type==field_U) THEN
+            IF (field(1)%ndim==2) THEN
+              status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(field(1)%name)),NF90_DOUBLE,(/ edgeId /),fieldId(nf))
+            ELSE IF (field(1)%ndim==3) THEN
+              status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(field(1)%name)),NF90_DOUBLE,(/ edgeId, levId /),fieldId(nf))
+            ELSE IF (field(1)%ndim==4) THEN
+              status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(field(1)%name)),NF90_DOUBLE,(/ edgeId, levId, nqId /),fieldId(nf))
+            ENDIF
+          ENDIF
+        ENDDO
+            
+        
+        status = NF90_ENDDEF(ncid)
+        
+        ALLOCATE(lon(ncell_glo),lat(ncell_glo),bounds_lon(0:nvert-1,ncell_glo),bounds_lat(0:nvert-1,ncell_glo))
+        DO ind=1,ndomain_glo
+          d=>domain_glo(ind)
+          DO j=d%jj_begin,d%jj_end
+            DO i=d%ii_begin,d%ii_end
+               ind_glo=d%assign_cell_glo(i,j)
+               CALL xyz2lonlat(d%xyz(:,i,j),lon(ind_glo),lat(ind_glo))
+               lon(ind_glo)=lon(ind_glo)*180/Pi
+               lat(ind_glo)=lat(ind_glo)*180/Pi
+               DO k=0,5
+                   CALL xyz2lonlat(d%vertex(:,k,i,j),bounds_lon(k,ind_glo), bounds_lat(k,ind_glo))
+                   bounds_lat(k,ind_glo)=bounds_lat(k,ind_glo)*180/Pi
+                   bounds_lon(k,ind_glo)=bounds_lon(k,ind_glo)*180/Pi
+               ENDDO
+            ENDDO
+          ENDDO
+        ENDDO
+
+        status=NF90_PUT_VAR(ncid,lonid,REAL(lon,r8),start=(/ 1 /),count=(/ ncell_glo /))
+        status=NF90_PUT_VAR(ncid,latid,REAL(lat,r8),start=(/ 1 /),count=(/ ncell_glo /))
+        status=NF90_PUT_VAR(ncid,bounds_lonId,REAL(bounds_lon,r8),start=(/ 1,1 /),count=(/ nvert,ncell_glo /))
+        status=NF90_PUT_VAR(ncid,bounds_latId,REAL(bounds_lat,r8),start=(/ 1,1 /),count=(/ nvert,ncell_glo /))
+        status=NF90_PUT_VAR(ncid,levAxisId,REAL(presnivs,r8),start=(/ 1 /),count=(/ llm /))
+      ENDIF
+
       DO nf=1,nfield
         field=>field_array(nf)%field
-        IF (field(1)%field_type==field_T) THEN
-          IF (field(1)%ndim==2) THEN
-            status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(field(1)%name)),NF90_DOUBLE,(/ cellId /),fieldId(nf))
-            status = NF90_PUT_ATT(ncid,FieldId(nf),"coordinates","lon lat")
-          ELSE IF (field(1)%ndim==3) THEN
-            status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(field(1)%name)),NF90_DOUBLE,(/ cellId, levId /),fieldId(nf))
-            status = NF90_PUT_ATT(ncid,FieldId(nf),"coordinates","lev lon lat")
-          ELSE IF (field(1)%ndim==4) THEN
-            status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(field(1)%name)),NF90_DOUBLE,(/ cellId, levId,nqId /),fieldId(nf))
-            status = NF90_PUT_ATT(ncid,FieldId(nf),"coordinates","nq lev lon lat")
-          ENDIF
-        ELSE IF (field(1)%field_type==field_U) THEN
-          IF (field(1)%ndim==2) THEN
-            status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(field(1)%name)),NF90_DOUBLE,(/ edgeId /),fieldId(nf))
-          ELSE IF (field(1)%ndim==3) THEN
-            status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(field(1)%name)),NF90_DOUBLE,(/ edgeId, levId /),fieldId(nf))
-          ELSE IF (field(1)%ndim==4) THEN
-            status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(field(1)%name)),NF90_DOUBLE,(/ edgeId, levId, nqId /),fieldId(nf))
-          ENDIF
-        ENDIF
+        CALL write_restart_field(field,fieldId(nf),ncid)
       ENDDO
-          
-      
-      status = NF90_ENDDEF(ncid)
-      
-      ALLOCATE(lon(ncell_glo),lat(ncell_glo),bounds_lon(0:nvert-1,ncell_glo),bounds_lat(0:nvert-1,ncell_glo))
-      DO ind=1,ndomain_glo
-        d=>domain_glo(ind)
-        DO j=d%jj_begin,d%jj_end
-          DO i=d%ii_begin,d%ii_end
-             ind_glo=d%assign_cell_glo(i,j)
-             CALL xyz2lonlat(d%xyz(:,i,j),lon(ind_glo),lat(ind_glo))
-             lon(ind_glo)=lon(ind_glo)*180/Pi
-             lat(ind_glo)=lat(ind_glo)*180/Pi
-             DO k=0,5
-                 CALL xyz2lonlat(d%vertex(:,k,i,j),bounds_lon(k,ind_glo), bounds_lat(k,ind_glo))
-                 bounds_lat(k,ind_glo)=bounds_lat(k,ind_glo)*180/Pi
-                 bounds_lon(k,ind_glo)=bounds_lon(k,ind_glo)*180/Pi
-             ENDDO
-          ENDDO
-        ENDDO
-      ENDDO
-
-      status=NF90_PUT_VAR(ncid,lonid,REAL(lon,r8),start=(/ 1 /),count=(/ ncell_glo /))
-      status=NF90_PUT_VAR(ncid,latid,REAL(lat,r8),start=(/ 1 /),count=(/ ncell_glo /))
-      status=NF90_PUT_VAR(ncid,bounds_lonId,REAL(bounds_lon,r8),start=(/ 1,1 /),count=(/ nvert,ncell_glo /))
-      status=NF90_PUT_VAR(ncid,bounds_latId,REAL(bounds_lat,r8),start=(/ 1,1 /),count=(/ nvert,ncell_glo /))
-      status=NF90_PUT_VAR(ncid,levAxisId,REAL(presnivs,r8),start=(/ 1 /),count=(/ llm /))
+            
+    !          status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(field(1)%name),NF90_DOUBLE,(/ ncellId /),fieldId(nf))
+    !        ELSE IF (field(1)%ndim==3) THEN
+    !          status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(field(1)%name),NF90_DOUBLE,(/ ncellId, levId /),fieldId(nf))
+    !        ENDIF
+    !      ENDDO
+
+
+      IF (is_mpi_root) THEN
+        status = NF90_CLOSE(ncid)      
+      ENDIF
+    
+    !$OMP END MASTER
+    
     ENDIF
-
-    DO nf=1,nfield
-      field=>field_array(nf)%field
-      CALL write_restart_field(field,fieldId(nf),ncid)
-    ENDDO
-          
-!          status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(field(1)%name),NF90_DOUBLE,(/ ncellId /),fieldId(nf))
-!        ELSE IF (field(1)%ndim==3) THEN
-!          status = NF90_DEF_VAR(ncid,TRIM(ADJUSTL(field(1)%name),NF90_DOUBLE,(/ ncellId, levId /),fieldId(nf))
-!        ENDIF
-!      ENDDO
-
-
-    IF (is_mpi_root) THEN
-      status = NF90_CLOSE(ncid)      
-    ENDIF
-!$OMP END MASTER
   
   END SUBROUTINE write_restart
@@ -178,4 +232,5 @@
   USE spherical_geom_mod
   USE transfert_mod
+  USE xios_mod
   IMPLICIT NONE
     TYPE(t_field),POINTER :: field(:)
@@ -274,5 +329,5 @@
                       ind_glo=d%assign_cell_glo(i,j)
                       e=cell_glo(ind_glo)%edge(MOD(k+d%delta(i,j)+6,6))  
-                      global_field2d(ind_glo)=d%edge_assign_sign(k,i,j)*field_glo(ind)%rval2d(ij+d%u_pos(k))
+                      global_field2d(e)=d%edge_assign_sign(k,i,j)*field_glo(ind)%rval2d(ij+d%u_pos(k))
                     ENDIF
                   ENDDO
@@ -342,4 +397,5 @@
   USE spherical_geom_mod
   USE transfert_mod
+  USE xios_mod
  
   IMPLICIT NONE
@@ -362,50 +418,82 @@
   INTEGER    :: status
   REAL(rstd),ALLOCATABLE :: lon(:),lat(:),bounds_lon(:,:),bounds_lat(:,:)
-   
+  REAL(rstd) :: it_temp(1)
     start_file_name="start"
     CALL getin("start_file_name",start_file_name)
 
-!$OMP MASTER
-
-    nfield=0
-    IF (PRESENT(field0))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field0  ; ENDIF
-    IF (PRESENT(field1))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field1  ; ENDIF
-    IF (PRESENT(field2))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field2  ; ENDIF
-    IF (PRESENT(field3))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field3  ; ENDIF
-    IF (PRESENT(field4))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field4  ; ENDIF
-    IF (PRESENT(field5))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field5  ; ENDIF
-    IF (PRESENT(field6))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field6  ; ENDIF
-    IF (PRESENT(field7))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field7  ; ENDIF
-    IF (PRESENT(field8))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field8  ; ENDIF
-    IF (PRESENT(field9))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field9  ; ENDIF
-    IF (PRESENT(field10)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field10 ; ENDIF
-    IF (PRESENT(field11)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field11 ; ENDIF
-    IF (PRESENT(field12)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field12 ; ENDIF
-    IF (PRESENT(field13)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field13 ; ENDIF
-    IF (PRESENT(field14)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field14 ; ENDIF
-    IF (PRESENT(field15)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field15 ; ENDIF
-    IF (PRESENT(field16)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field16 ; ENDIF
-    IF (PRESENT(field17)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field17 ; ENDIF
-    IF (PRESENT(field18)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field18 ; ENDIF
-    IF (PRESENT(field19)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field19 ; ENDIF
-    
-      
-
-    IF (is_mpi_root) THEN
-      status = NF90_OPEN(TRIM(ADJUSTL(start_file_name))//'.nc', NF90_NOWRITE, ncid)
+
+
+    IF (using_xios) THEN
+      IF (PRESENT(field0))  THEN ; CALL  xios_read_field(TRIM(field0(1)%name)//'_start',field0)  ; ENDIF
+      IF (PRESENT(field1))  THEN ; CALL  xios_read_field(TRIM(field1(1)%name)//'_start',field1)  ; ENDIF
+      IF (PRESENT(field2))  THEN ; CALL  xios_read_field(TRIM(field2(1)%name)//'_start',field2)  ; ENDIF
+      IF (PRESENT(field3))  THEN ; CALL  xios_read_field(TRIM(field3(1)%name)//'_start',field3)  ; ENDIF
+      IF (PRESENT(field4))  THEN ; CALL  xios_read_field(TRIM(field4(1)%name)//'_start',field4)  ; ENDIF
+      IF (PRESENT(field5))  THEN ; CALL  xios_read_field(TRIM(field5(1)%name)//'_start',field5)  ; ENDIF
+      IF (PRESENT(field6))  THEN ; CALL  xios_read_field(TRIM(field6(1)%name)//'_start',field6)  ; ENDIF
+      IF (PRESENT(field7))  THEN ; CALL  xios_read_field(TRIM(field7(1)%name)//'_start',field7)  ; ENDIF
+      IF (PRESENT(field8))  THEN ; CALL  xios_read_field(TRIM(field8(1)%name)//'_start',field8)  ; ENDIF
+      IF (PRESENT(field9))  THEN ; CALL  xios_read_field(TRIM(field9(1)%name)//'_start',field9)  ; ENDIF
+      IF (PRESENT(field10))  THEN ; CALL  xios_read_field(TRIM(field10(1)%name)//'_start',field10)  ; ENDIF
+      IF (PRESENT(field11))  THEN ; CALL  xios_read_field(TRIM(field11(1)%name)//'_start',field11)  ; ENDIF
+      IF (PRESENT(field12))  THEN ; CALL  xios_read_field(TRIM(field12(1)%name)//'_start',field12)  ; ENDIF
+      IF (PRESENT(field13))  THEN ; CALL  xios_read_field(TRIM(field13(1)%name)//'_start',field13)  ; ENDIF
+      IF (PRESENT(field14))  THEN ; CALL  xios_read_field(TRIM(field14(1)%name)//'_start',field14)  ; ENDIF
+      IF (PRESENT(field15))  THEN ; CALL  xios_read_field(TRIM(field15(1)%name)//'_start',field15)  ; ENDIF
+      IF (PRESENT(field16))  THEN ; CALL  xios_read_field(TRIM(field16(1)%name)//'_start',field16)  ; ENDIF
+      IF (PRESENT(field17))  THEN ; CALL  xios_read_field(TRIM(field17(1)%name)//'_start',field17)  ; ENDIF
+      IF (PRESENT(field18))  THEN ; CALL  xios_read_field(TRIM(field18(1)%name)//'_start',field18)  ; ENDIF
+      IF (PRESENT(field19))  THEN ; CALL  xios_read_field(TRIM(field19(1)%name)//'_start',field19)  ; ENDIF
+! doesn't work for now, to be decomment when xios is ok
+!      CALL xios_recv_field("it_start",it_temp)
+!      it=it_temp(1)
+      it=0
+    ELSE
+
+    !$OMP MASTER
+
+      nfield=0
+      IF (PRESENT(field0))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field0  ; ENDIF
+      IF (PRESENT(field1))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field1  ; ENDIF
+      IF (PRESENT(field2))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field2  ; ENDIF
+      IF (PRESENT(field3))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field3  ; ENDIF
+      IF (PRESENT(field4))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field4  ; ENDIF
+      IF (PRESENT(field5))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field5  ; ENDIF
+      IF (PRESENT(field6))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field6  ; ENDIF
+      IF (PRESENT(field7))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field7  ; ENDIF
+      IF (PRESENT(field8))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field8  ; ENDIF
+      IF (PRESENT(field9))  THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field9  ; ENDIF
+      IF (PRESENT(field10)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field10 ; ENDIF
+      IF (PRESENT(field11)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field11 ; ENDIF
+      IF (PRESENT(field12)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field12 ; ENDIF
+      IF (PRESENT(field13)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field13 ; ENDIF
+      IF (PRESENT(field14)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field14 ; ENDIF
+      IF (PRESENT(field15)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field15 ; ENDIF
+      IF (PRESENT(field16)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field16 ; ENDIF
+      IF (PRESENT(field17)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field17 ; ENDIF
+      IF (PRESENT(field18)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field18 ; ENDIF
+      IF (PRESENT(field19)) THEN ; nfield=nfield+1 ; field_array(nfield)%field=>field19 ; ENDIF
+      
+        
+
+      IF (is_mpi_root) THEN
+        status = NF90_OPEN(TRIM(ADJUSTL(start_file_name))//'.nc', NF90_NOWRITE, ncid)
+      ENDIF
+     
+      DO nf=1,nfield
+        field=>field_array(nf)%field
+        status = nf90_inq_varid(ncid, TRIM(ADJUSTL(field(1)%name)), fieldId(nf))
+        status = nf90_get_att(ncid, NF90_GLOBAL, "iteration", it)
+        CALL read_start_field(field,fieldId(nf),ncid)
+      ENDDO
+
+
+      IF (is_mpi_root) THEN
+        status = NF90_CLOSE(ncid)      
+      ENDIF
+     
+     !$OMP END MASTER
+    
     ENDIF
-   
-    DO nf=1,nfield
-      field=>field_array(nf)%field
-      status = nf90_inq_varid(ncid, TRIM(ADJUSTL(field(1)%name)), fieldId(nf))
-      status = nf90_get_att(ncid, NF90_GLOBAL, "iteration", it)
-      CALL read_start_field(field,fieldId(nf),ncid)
-    ENDDO
-
-
-    IF (is_mpi_root) THEN
-      status = NF90_CLOSE(ncid)      
-    ENDIF
-!$OMP END MASTER
   
   END SUBROUTINE read_start
Index: /codes/icosagcm/trunk/src/write_etat0.f90
===================================================================
--- /codes/icosagcm/trunk/src/write_etat0.f90	(revision 482)
+++ /codes/icosagcm/trunk/src/write_etat0.f90	(revision 483)
@@ -12,4 +12,5 @@
   USE domain_mod
   USE omp_para
+  USE xios_mod
   IMPLICIT NONE
     INTEGER,INTENT(IN)    :: it
Index: /codes/icosagcm/trunk/src/xios_mod.F90
===================================================================
--- /codes/icosagcm/trunk/src/xios_mod.F90	(revision 482)
+++ /codes/icosagcm/trunk/src/xios_mod.F90	(revision 483)
@@ -12,6 +12,8 @@
   INTEGER,SAVE :: ncell_v
 !$OMP THREADPRIVATE(ncell_v)
-
-  PRIVATE ncell_i,ncell_v
+  INTEGER,SAVE :: ncell_e
+!$OMP THREADPRIVATE(ncell_e)
+
+  PRIVATE ncell_i,ncell_v,ncell_e
 
 #ifdef CPP_USING_XIOS
@@ -44,5 +46,5 @@
  USE mpi_mod
  USE time_mod
- USE metric, ONLY : vup,vdown
+ USE metric, ONLY : vup,vdown, cell_glo
  IMPLICIT NONE
   TYPE(xios_context) :: ctx_hdl
@@ -51,6 +53,7 @@
   REAL(rstd) :: lev_valuep1(llm+1)
   INTEGER :: ncell, ncell_tot, ncell_glo(0:mpi_size-1), displ
-  INTEGER :: ind, i,j,k,l
+  INTEGER :: ind, i,j,k,l,ij
   REAL(rstd),ALLOCATABLE    :: lon(:), lat(:), bounds_lon(:,:), bounds_lat(:,:)
+  INTEGER, ALLOCATABLE      :: ind_glo(:)
   TYPE(t_domain),POINTER :: d
 
@@ -64,4 +67,5 @@
    CALL xios_set_axis_attr("lev",n_glo=llm ,value=lev_value) ;
    CALL xios_set_axis_attr("levp1",n_glo=llm+1 ,value=lev_valuep1) ;
+   CALL xios_set_axis_attr("nq",n_glo=nqtot) ;
    
    ncell=0
@@ -86,5 +90,5 @@
    ncell_tot=sum(ncell_glo(:))
    
-   ALLOCATE(lon(ncell), lat(ncell), bounds_lon(0:5,ncell), bounds_lat(0:5,ncell)) 
+   ALLOCATE(lon(ncell), lat(ncell), bounds_lon(0:5,ncell), bounds_lat(0:5,ncell), ind_glo(ncell)) 
    
    ncell=0
@@ -104,4 +108,5 @@
              bounds_lon(k,ncell)=bounds_lon(k,ncell)*180/Pi
            ENDDO
+           ind_glo(ncell)=domain(ind)%assign_cell_glo(i,j)-1 
          ENDIF
        ENDDO
@@ -109,11 +114,73 @@
    ENDDO         
 
-  
    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", data_dim=1, type='unstructured' , nvertex=6, i_index=ind_glo)
    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) 
+   DEALLOCATE(lon, lat, bounds_lon, bounds_lat,ind_glo) 
     
+
+
+   ncell=0
+   DO ind=1,ndomain
+     d=>domain(ind)
+
+     DO j=d%jj_begin,d%jj_end
+       DO i=d%ii_begin,d%ii_end
+         DO k=0,5
+            IF (d%edge_assign_domain(k,i,j)==domloc_glo_ind(ind) .AND. d%edge_assign_i(k,i,j)==i .AND. d%edge_assign_j(k,i,j)==j &
+                                                                                 .AND. d%edge_assign_pos(k,i,j)==k) THEN
+               ncell=ncell+1
+            ENDIF
+         ENDDO
+       ENDDO
+     ENDDO
+   ENDDO
+   ncell_e=ncell
+   
+   CALL MPI_ALLGATHER(ncell_e,1,MPI_INTEGER,ncell_glo,1,MPI_INTEGER,comm_icosa,ierr)
+   displ=0
+   DO i=1,mpi_rank
+     displ=displ+ncell_glo(i-1)
+   ENDDO
+   ncell_tot=sum(ncell_glo(:))
+   
+   ALLOCATE(lon(ncell), lat(ncell), bounds_lon(0:1,ncell), bounds_lat(0:1,ncell),ind_glo(ncell)) 
+
+
+   ncell=0
+   DO ind=1,ndomain
+     d=>domain(ind)
+     CALL swap_dimensions(ind)
+     CALL swap_geometry(ind)
+
+     DO j=d%jj_begin,d%jj_end
+       DO i=d%ii_begin,d%ii_end
+         DO k=0,5
+           IF (d%edge_assign_domain(k,i,j)==domloc_glo_ind(ind) .AND. d%edge_assign_i(k,i,j)==i .AND. d%edge_assign_j(k,i,j)==j &
+                                                                                 .AND. d%edge_assign_pos(k,i,j)==k) THEN
+              ncell=ncell+1
+              ij=(j-1)*iim+i
+
+              lon(ncell)=lon_e(ij+u_pos(k+1))*180/Pi
+              lat(ncell)=lat_e(ij+u_pos(k+1))*180/Pi
+               
+              CALL xyz2lonlat(d%vertex(:,MOD((k-1)+6,6),i,j),bounds_lon(0,ncell), bounds_lat(0,ncell))
+              CALL xyz2lonlat(d%vertex(:,k,i,j),bounds_lon(1,ncell), bounds_lat(1,ncell))
+              bounds_lon(:,ncell)=bounds_lon(:,ncell)*180/Pi
+              bounds_lat(:,ncell)=bounds_lat(:,ncell)*180/Pi
+              ind_glo(ncell)=cell_glo(d%assign_cell_glo(i,j))%edge(MOD(k+d%delta(i,j)+6,6))-1 
+           ENDIF               
+         ENDDO
+       ENDDO
+     ENDDO
+   ENDDO
+   CALL xios_set_domain_attr("u",ni_glo=ncell_tot, ibegin=displ, ni=ncell)
+   CALL xios_set_domain_attr("u", data_dim=1, type='unstructured' , nvertex=2, i_index=ind_glo)
+   CALL xios_set_domain_attr("u",lonvalue_1d=lon, latvalue_1d=lat, bounds_lon_1d=bounds_lon, bounds_lat_1d=bounds_lat)
+
+   DEALLOCATE(lon, lat, bounds_lon, bounds_lat,ind_glo) 
+
+
    ncell=0
    DO ind=1,ndomain
@@ -219,15 +286,28 @@
    IF (Field(1)%field_type==field_T) THEN
      IF (field(1)%ndim==2) THEN
-        CALL xios_write_field_scalar(name,field,1)
+        CALL xios_write_field_scalar(name,field,1,1)
+     ELSE IF (field(1)%ndim==3) THEN
+        CALL xios_write_field_scalar(name,field,size(field(1)%rval3d,2),1)
+     ELSE IF (field(1)%ndim==4) THEN
+!        DO iq=1,size(field(1)%rval4d,3)
+!          WRITE(str_number,'(i10)') iq
+!          CALL xios_write_field_scalar(name//TRIM(ADJUSTL(str_number)),field,size(field(1)%rval4d,2),iq)
+          CALL xios_write_field_scalar(name,field,size(field(1)%rval4d,2),size(field(1)%rval4d,3))
+!        ENDDO
+     ELSE
+        PRINT *, "xios_write_field : dimension > 4 are not supported for now"
+     ENDIF
+
+   ELSE IF (Field(1)%field_type==field_U) THEN
+      IF (field(1)%ndim==2) THEN
+        CALL xios_write_field_U(name,field,1,1)
       ELSE IF (field(1)%ndim==3) THEN
-        CALL xios_write_field_scalar(name,field,size(field(1)%rval3d,2))
+        CALL xios_write_field_U(name,field,size(field(1)%rval3d,2),1)
       ELSE IF (field(1)%ndim==4) THEN
-        DO iq=1,size(field(1)%rval4d,3)
-          WRITE(str_number,'(i10)') iq
-          CALL xios_write_field_scalar(name//TRIM(ADJUSTL(str_number)),field,size(field(1)%rval4d,2),iq)
-        ENDDO
+        CALL xios_write_field_U(name,field,size(field(1)%rval4d,2),size(field(1)%rval4d,3))
       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
@@ -262,12 +342,23 @@
    IF (Field(1)%field_type==field_T) THEN
      IF (field(1)%ndim==2) THEN
-        CALL xios_read_field_scalar(name,field,1)
+        CALL xios_read_field_scalar(name,field,1,1)
       ELSE IF (field(1)%ndim==3) THEN
-        CALL xios_read_field_scalar(name,field,size(field(1)%rval3d,2))
+        CALL xios_read_field_scalar(name,field,size(field(1)%rval3d,2),1)
       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
+!        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
+          CALL xios_read_field_scalar(name,field,size(field(1)%rval4d,2),size(field(1)%rval4d,3))
+      ELSE
+        PRINT *, "xios_write_field : dimension > 4 are not supported for now"
+      ENDIF
+   ELSE IF (Field(1)%field_type==field_U) THEN
+     IF (field(1)%ndim==2) THEN
+        CALL xios_read_field_u(name,field,1,1)
+      ELSE IF (field(1)%ndim==3) THEN
+        CALL xios_read_field_u(name,field,size(field(1)%rval3d,2),1)
+      ELSE IF (field(1)%ndim==4) THEN
+          CALL xios_read_field_u(name,field,size(field(1)%rval4d,2),size(field(1)%rval4d,3))
       ELSE
         PRINT *, "xios_write_field : dimension > 4 are not supported for now"
@@ -294,5 +385,5 @@
 
  
- SUBROUTINE xios_write_field_scalar(name,field,nlev,iq)
+ SUBROUTINE xios_write_field_scalar(name,field,nlev,nq)
  USE genmod
  USE mpipara
@@ -308,7 +399,7 @@
    TYPE(t_field), POINTER :: field(:)
    INTEGER,INTENT(IN) :: nlev
-   INTEGER,INTENT(IN),OPTIONAL :: iq
-   
-   REAL(rstd) :: field_tmp(ncell_i,nlev)
+   INTEGER,INTENT(IN) :: nq
+   
+   REAL(rstd) :: field_tmp(ncell_i,nlev,nq)
    TYPE(t_domain),POINTER :: d
    INTEGER :: n,i,j,ij,ind
@@ -325,5 +416,5 @@
              n=n+1
              ij=d%iim*(j-1)+i
-             field_tmp(n,1)=field(ind)%rval2d(ij)
+             field_tmp(n,1,1)=field(ind)%rval2d(ij)
            ENDIF
          ENDDO
@@ -340,5 +431,5 @@
              n=n+1
              ij=d%iim*(j-1)+i
-             field_tmp(n,:)=field(ind)%rval3d(ij,:)
+             field_tmp(n,:,1)=field(ind)%rval3d(ij,:)
            ENDIF
          ENDDO
@@ -355,5 +446,5 @@
              n=n+1
              ij=d%iim*(j-1)+i
-             field_tmp(n,:)=field(ind)%rval4d(ij,:,iq)
+             field_tmp(n,:,:)=field(ind)%rval4d(ij,:,:)
            ENDIF
          ENDDO
@@ -367,5 +458,5 @@
 
 
- SUBROUTINE xios_read_field_scalar(name,field,nlev,iq)
+ SUBROUTINE xios_read_field_scalar(name,field,nlev,nq)
  USE genmod
  USE mpipara
@@ -381,7 +472,7 @@
    TYPE(t_field), POINTER :: field(:)
    INTEGER,INTENT(IN) :: nlev
-   INTEGER,INTENT(IN),OPTIONAL :: iq
-   
-   REAL(rstd) :: field_tmp(ncell_i,nlev)
+   INTEGER,INTENT(IN) :: nq
+   
+   REAL(rstd) :: field_tmp(ncell_i,nlev,nq)
    TYPE(t_domain),POINTER :: d
    INTEGER :: n,i,j,ij,ind
@@ -400,5 +491,5 @@
              n=n+1
              ij=d%iim*(j-1)+i
-             field(ind)%rval2d(ij)=field_tmp(n,1)
+             field(ind)%rval2d(ij)=field_tmp(n,1,1)
            ENDIF
          ENDDO
@@ -415,5 +506,5 @@
              n=n+1
              ij=d%iim*(j-1)+i
-             field(ind)%rval3d(ij,:)=field_tmp(n,:)
+             field(ind)%rval3d(ij,:)=field_tmp(n,:,1)
            ENDIF
          ENDDO
@@ -430,5 +521,5 @@
              n=n+1
              ij=d%iim*(j-1)+i
-             field(ind)%rval4d(ij,:,iq)=field_tmp(n,:)
+             field(ind)%rval4d(ij,:,:)=field_tmp(n,:,:)
            ENDIF
          ENDDO
@@ -438,4 +529,189 @@
  
  END SUBROUTINE xios_read_field_scalar
+
+ SUBROUTINE xios_write_field_U(name,field,nlev,nq)
+ 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) :: nq
+   
+   REAL(rstd) :: field_tmp(ncell_e,nlev,nq)
+   TYPE(t_domain),POINTER :: d
+   INTEGER :: n,i,j,k,ij,ind
+   
+   IF (field(1)%ndim==2) THEN
+     n=0
+     DO ind=1,ndomain
+       d=>domain(ind)
+       CALL swap_dimensions(ind)
+       CALL swap_geometry(ind)
+
+       DO j=d%jj_begin,d%jj_end
+         DO i=d%ii_begin,d%ii_end
+           DO k=0,5
+             IF (d%edge_assign_domain(k,i,j)==domloc_glo_ind(ind) .AND. d%edge_assign_i(k,i,j)==i .AND. d%edge_assign_j(k,i,j)==j &
+                                                                                 .AND. d%edge_assign_pos(k,i,j)==k) THEN
+               n=n+1
+               ij=iim*(j-1)+i
+               Field_tmp(n,1,1)=d%edge_assign_sign(k,i,j)*field(ind)%rval2d(ij+d%u_pos(k+1))
+             ENDIF
+           ENDDO
+         ENDDO
+       ENDDO
+     ENDDO       
+  
+   ELSE IF (field(1)%ndim==3) THEN
+
+     n=0
+     DO ind=1,ndomain
+       d=>domain(ind)
+       CALL swap_dimensions(ind)
+       CALL swap_geometry(ind)
+
+       DO j=d%jj_begin,d%jj_end
+         DO i=d%ii_begin,d%ii_end
+           DO k=0,5
+             IF (d%edge_assign_domain(k,i,j)==domloc_glo_ind(ind) .AND. d%edge_assign_i(k,i,j)==i .AND. d%edge_assign_j(k,i,j)==j &
+                                                                                  .AND. d%edge_assign_pos(k,i,j)==k) THEN
+               n=n+1
+               ij=iim*(j-1)+i
+               Field_tmp(n,:,1)=d%edge_assign_sign(k,i,j)*field(ind)%rval3d(ij+d%u_pos(k+1),:)
+             ENDIF
+           ENDDO
+         ENDDO
+       ENDDO
+     ENDDO       
+
+   ELSE IF (field(1)%ndim==4) THEN
+
+     n=0
+     DO ind=1,ndomain
+       d=>domain(ind)
+       CALL swap_dimensions(ind)
+       CALL swap_geometry(ind)
+
+       DO j=d%jj_begin,d%jj_end
+         DO i=d%ii_begin,d%ii_end
+           DO k=0,5
+             IF (d%edge_assign_domain(k,i,j)==domloc_glo_ind(ind) .AND. d%edge_assign_i(k,i,j)==i .AND. d%edge_assign_j(k,i,j)==j &
+                                                                                  .AND. d%edge_assign_pos(k,i,j)==k) THEN
+               n=n+1
+               ij=iim*(j-1)+i
+               Field_tmp(n,:,:)=d%edge_assign_sign(k,i,j)*field(ind)%rval4d(ij+d%u_pos(k+1),:,:)
+             ENDIF
+           ENDDO
+         ENDDO
+       ENDDO
+     ENDDO       
+
+   ENDIF
+   
+   CALL xios_send_field(name,field_tmp)
+ 
+ END SUBROUTINE xios_write_field_u 
+
+
+ SUBROUTINE xios_read_field_u(name,field,nlev,nq)
+ 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) :: nq
+   
+   REAL(rstd) :: field_tmp(ncell_e,nlev,nq)
+   TYPE(t_domain),POINTER :: d
+   INTEGER :: n,i,j,k,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)
+       CALL swap_geometry(ind)
+
+       DO j=d%jj_begin,d%jj_end
+         DO i=d%ii_begin,d%ii_end
+           DO k=0,5
+             IF (d%edge_assign_domain(k,i,j)==domloc_glo_ind(ind) .AND. d%edge_assign_i(k,i,j)==i .AND. d%edge_assign_j(k,i,j)==j &
+                                                                                 .AND. d%edge_assign_pos(k,i,j)==k) THEN
+               n=n+1
+               ij=iim*(j-1)+i
+               field(ind)%rval2d(ij+d%u_pos(k+1))=Field_tmp(n,1,1)*d%edge_assign_sign(k,i,j)
+             ENDIF
+           ENDDO
+         ENDDO
+       ENDDO
+     ENDDO       
+  
+   ELSE IF (field(1)%ndim==3) THEN
+
+     n=0
+     DO ind=1,ndomain
+       d=>domain(ind)
+       CALL swap_dimensions(ind)
+       CALL swap_geometry(ind)
+
+       DO j=d%jj_begin,d%jj_end
+         DO i=d%ii_begin,d%ii_end
+           DO k=0,5
+             IF (d%edge_assign_domain(k,i,j)==domloc_glo_ind(ind) .AND. d%edge_assign_i(k,i,j)==i .AND. d%edge_assign_j(k,i,j)==j &
+                                                                                  .AND. d%edge_assign_pos(k,i,j)==k) THEN
+               n=n+1
+               ij=iim*(j-1)+i
+               field(ind)%rval3d(ij+d%u_pos(k+1),:)=Field_tmp(n,:,1)*d%edge_assign_sign(k,i,j)
+             ENDIF
+           ENDDO
+         ENDDO
+       ENDDO
+     ENDDO       
+
+   ELSE IF (field(1)%ndim==4) THEN
+
+     n=0
+     DO ind=1,ndomain
+       d=>domain(ind)
+       CALL swap_dimensions(ind)
+       CALL swap_geometry(ind)
+
+       DO j=d%jj_begin,d%jj_end
+         DO i=d%ii_begin,d%ii_end
+           DO k=0,5
+             IF (d%edge_assign_domain(k,i,j)==domloc_glo_ind(ind) .AND. d%edge_assign_i(k,i,j)==i .AND. d%edge_assign_j(k,i,j)==j &
+                                                                                  .AND. d%edge_assign_pos(k,i,j)==k) THEN
+               n=n+1
+               ij=iim*(j-1)+i
+               field(ind)%rval4d(ij+d%u_pos(k+1),:,:)=Field_tmp(n,:,:)*d%edge_assign_sign(k,i,j)
+             ENDIF
+           ENDDO
+         ENDDO
+       ENDDO
+     ENDDO       
+
+   ENDIF
+   
+ 
+ END SUBROUTINE xios_read_field_u 
+
 
 
@@ -673,4 +949,5 @@
 END INTERFACE  xios_send_field
 
+INTEGER,PARAMETER :: xios_timestep=1
 
 CONTAINS  
@@ -724,7 +1001,8 @@
   END SUBROUTINE xios_set_context
   
-  SUBROUTINE xios_set_fieldgroup_attr(name,enabled)
+  SUBROUTINE xios_set_fieldgroup_attr(name,enabled,freq_op)
     CHARACTER(LEN=*) :: name
     LOGICAL,OPTIONAL          :: enabled
+    INTEGER,OPTIONAL          :: freq_op
   END SUBROUTINE xios_set_fieldgroup_attr
 
@@ -733,4 +1011,11 @@
     LOGICAL,OPTIONAL          :: enabled
   END SUBROUTINE xios_set_filegroup_attr
+
+  SUBROUTINE xios_set_file_attr(id,name,enabled, output_freq)
+    CHARACTER(LEN=*) :: id
+    CHARACTER(LEN=*),OPTIONAL :: name
+    LOGICAL,OPTIONAL          :: enabled
+    INTEGER,OPTIONAL          :: output_freq
+  END SUBROUTINE xios_set_file_attr
 
   SUBROUTINE xios_get_axis_attr(name,n_glo,value)
@@ -740,4 +1025,10 @@
   END SUBROUTINE xios_get_axis_attr
 
+  SUBROUTINE xios_set_axis_attr(id,n_glo,value)
+    CHARACTER(LEN=*) :: id
+    INTEGER,OPTIONAL          :: n_glo
+    REAL,OPTIONAL             :: value(:)
+  END SUBROUTINE xios_set_axis_attr
+
 #endif  
 
