Index: codes/icosagcm/trunk/src/restart.f90
===================================================================
--- codes/icosagcm/trunk/src/restart.f90	(revision 358)
+++ 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
