Index: LMDZ6/branches/Ocean_skin/libf/phylmd/oasis.F90
===================================================================
--- LMDZ6/branches/Ocean_skin/libf/phylmd/oasis.F90	(revision 3428)
+++ LMDZ6/branches/Ocean_skin/libf/phylmd/oasis.F90	(revision 3605)
@@ -104,7 +104,12 @@
 #ifdef CPP_XIOS
     USE wxios, ONLY : wxios_context_init 
+    USE xios  
 #endif
     USE print_control_mod, ONLY: lunout
-    USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat
+    USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat, grid_type, unstructured, regular_lonlat
+    USE geometry_mod, ONLY: ind_cell_glo                    
+    USE mod_phys_lmdz_mpi_data, ONLY: klon_mpi_para_nb
+    
+
 
 ! Local variables
@@ -113,5 +118,5 @@
     INTEGER                            :: ierror, il_commlocal
     INTEGER                            :: il_part_id
-    INTEGER, DIMENSION(3)              :: ig_paral
+    INTEGER, ALLOCATABLE               :: ig_paral(:)
     INTEGER, DIMENSION(2)              :: il_var_nodims
     INTEGER, DIMENSION(4)              :: il_var_actual_shape
@@ -136,5 +141,12 @@
 ! Define the model name
 !
-    clmodnam = 'LMDZ'       ! as in $NBMODEL in Cpl/Nam/namcouple.tmp
+    IF (grid_type==unstructured) THEN
+        clmodnam = 'icosa'                 ! as in $NBMODEL in Cpl/Nam/namcouple.tmp
+    ELSE IF (grid_type==regular_lonlat) THEN
+        clmodnam = 'LMDZ'                  ! as in $NBMODEL in Cpl/Nam/namcouple.tmp
+    ELSE
+	abort_message='Pb : type of grid unknown'
+	CALL abort_physic(modname,abort_message,1)
+    ENDIF
 
 
@@ -236,9 +248,30 @@
 ! Domain decomposition
 !************************************************************************************
-    ig_paral(1) = 1                            ! apple partition for //
-    ig_paral(2) = (jj_begin-1)*nbp_lon+ii_begin-1  ! offset
-    ig_paral(3) = (jj_end*nbp_lon+ii_end) - (jj_begin*nbp_lon+ii_begin) + 1
-
-    IF (mpi_rank==mpi_size-1) ig_paral(3)=ig_paral(3)+nbp_lon-1
+    IF (grid_type==unstructured) THEN
+
+      ALLOCATE( ig_paral(klon_mpi_para_nb(mpi_rank) + 2) ) 
+
+      ig_paral(1) = 4                                      ! points partition for //
+      ig_paral(2) = klon_mpi_para_nb(mpi_rank)             ! nb of local cells
+
+      DO jf=1, klon_mpi_para_nb(mpi_rank)
+        ig_paral(2+jf) = ind_cell_glo(jf)
+      ENDDO
+
+    ELSE IF (grid_type==regular_lonlat) THEN
+
+      ALLOCATE( ig_paral(3) )
+
+      ig_paral(1) = 1                            ! apple partition for //
+      ig_paral(2) = (jj_begin-1)*nbp_lon+ii_begin-1  ! offset
+      ig_paral(3) = (jj_end*nbp_lon+ii_end) - (jj_begin*nbp_lon+ii_begin) + 1
+
+      IF (mpi_rank==mpi_size-1) ig_paral(3)=ig_paral(3)+nbp_lon-1
+    ELSE
+      abort_message='Pb : type of grid unknown'
+      CALL abort_physic(modname,abort_message,1)
+    ENDIF
+
+
     WRITE(lunout,*) mpi_rank,'ig_paral--->',ig_paral(2),ig_paral(3)
     
@@ -253,11 +286,11 @@
     ENDIF
 
-    il_var_nodims(1) = 2
-    il_var_nodims(2) = 1
-
-    il_var_actual_shape(1) = 1
-    il_var_actual_shape(2) = nbp_lon
-    il_var_actual_shape(3) = 1
-    il_var_actual_shape(4) = nbp_lat
+    il_var_nodims(1) = 2                        ! rank of field array (1d or 2d)
+    il_var_nodims(2) = 1                        ! always 1 in current oasis version" doc oasis3mct p18
+
+    il_var_actual_shape(1) = 1                  ! min of 1st dimension (always 1)
+    il_var_actual_shape(2) = nbp_lon            ! max of 1st dimension
+    il_var_actual_shape(3) = 1                  ! min of 2nd dimension (always 1)
+    il_var_actual_shape(4) = nbp_lat            ! max of 2nd dimension
    
     il_var_type = PRISM_Real
@@ -302,4 +335,7 @@
 ! End definition
 !************************************************************************************
+#ifdef CPP_XIOS
+    CALL xios_oasis_enddef()
+#endif
     CALL prism_enddef_proto(ierror)
     IF (ierror .NE. PRISM_Ok) THEN
@@ -311,5 +347,5 @@
 
 #ifdef CPP_XIOS
-    CALL wxios_context_init()
+!    CALL wxios_context_init()
 #endif
 
