Index: XIOS/dev/branch_openmp/extern/ep_dev/main.cpp
===================================================================
--- XIOS/dev/branch_openmp/extern/ep_dev/main.cpp	(revision 1506)
+++ XIOS/dev/branch_openmp/extern/ep_dev/main.cpp	(revision 1511)
@@ -680,73 +680,164 @@
 
 
-    MPI_Barrier(comm);
-    {
-    int rank, size;
-    MPI_Comm_rank(comm, &rank);
-    MPI_Comm_size(comm, &size);
-
-    //int tab_color[16]={2,2,2,3,0,1,1,3,2,1,3,0,0,2,0,0};     // OK
-    //int tab_key[16]={3,11,10,5,6,8,15,7,2,1,9,13,4,14,12,0}; // OK 
-    
-
-    int tab_color[16]={2,2,1,1,1,1,0,1,1,1,0,1,1,1,2,0};
-    //int tab_key[16]={3,11,12,4,6,15,10,5,2,8,14,7,13,9,1,0};
-    int tab_key[16]={3,11,7,7,6,15,10,5,2,8,14,7,13,9,1,0};
-    
-    int color = tab_color[rank];
-    int key = tab_key[rank];
-  
-    MPI_Comm split_comm;
-    MPI_Comm_split(comm, color, key, &split_comm);
-
-
-    
-    int split_rank;
-    MPI_Comm_rank(split_comm, &split_rank);
-    
-    printf("rank = %d, color = %d, key = %d, split_rank = %d, local_rank=%d\n", rank, color, key, split_rank, split_comm->ep_comm_ptr->size_rank_info[1].first);
-
-
-    MPI_Barrier(comm);
-    if(rank == 0) printf("\tMPI_Comm_split OK\n");
-    MPI_Barrier(comm);
-/*
-    MPI_Comm inter_comm;
-    //MPI_Intercomm_create(sub_comm, 0, comm, (color+1)%2, 99, &inter_comm);
-    MPI_Intercomm_create(sub_comm, 0, comm, remote_leader, 99, &inter_comm);
-
-    MPI_Barrier(comm);
-    if(rank == 0) printf("\tMPI_Intercomm_create OK\n");
-    MPI_Barrier(comm);
-
-    
-
-    int high=color;
-    MPI_Comm intra_comm;
-    MPI_Intercomm_merge(inter_comm, high, &intra_comm);
-    
-    int intra_rank, intra_size;
-    MPI_Comm_rank(intra_comm, &intra_rank);
-    MPI_Comm_size(intra_comm, &intra_size);
-
-    MPI_Barrier(comm);
-    if(rank == 0) printf("\tMPI_Intercomm_merge OK\n");
-    MPI_Barrier(comm);
-    
-    
-
-    //check_test_gatherv(comm);
-*/
-    MPI_Barrier(comm);
-    MPI_Comm_free(&split_comm);
-
-
-    //MPI_Barrier(comm);
-    //MPI_Comm_free(&inter_comm);
-
-
+    // TEST OF COMM_SPLIT
+    {
+
+      MPI_Barrier(comm);
+      int rank, size;
+      MPI_Comm_rank(comm, &rank);
+      MPI_Comm_size(comm, &size);
+    
+      int color = rand()%3;
+      int key = rand()%5;
+      
+      int color2 = rand()%3;
+      int key2 = rand()%5;
+  
+      MPI_Comm split_comm;
+      MPI_Comm_split(comm, color, key, &split_comm);
+
+      
+      MPI_Comm split_comm2;
+      MPI_Comm_split(comm, color2, key2, &split_comm2);
+
+
+    
+      int split_rank, split_size;
+      MPI_Comm_rank(split_comm, &split_rank);
+      MPI_Comm_size(split_comm, &split_size);
+    
+#ifdef _Memory_check    
+      printf("rank = %d, color = %d, key = %d, split_rank = %d, local_rank=%d\n", rank, color, key, split_rank, split_comm->ep_comm_ptr->size_rank_info[1].first);
+#endif
+
+      MPI_Barrier(comm);
+      MPI_Barrier(comm);
+      MPI_Barrier(comm);
+      
+      if(rank == 0) printf("            \t tMPI_Comm_split \t OK\n");
+      
+      MPI_Barrier(comm);
+      MPI_Barrier(comm);
+      
+      int bcast_buf_size=100;
+      
+      std::vector<int> bcast_buf(bcast_buf_size, 0);
+      
+      if(split_rank==0) bcast_buf.assign(bcast_buf_size, (color+1)*split_size);
+      
+      MPI_Bcast(bcast_buf.data(), bcast_buf_size, MPI_INT, 0, split_comm);
+      
+      int bcast_test = 0;
+      for(int i=0; i<bcast_buf_size; i++)
+      {
+        if(bcast_buf[i] != (color+1)*split_size)
+          bcast_test = 1;
+      }
+  
+      int bcast_result;
+  
+      MPI_Reduce(&bcast_test, &bcast_result, 1, MPI_INT, MPI_SUM, 0, comm);
+  
+      MPI_Barrier(split_comm);
+      MPI_Comm_free(&split_comm);
+      
+      MPI_Barrier(split_comm2);
+      MPI_Comm_free(&split_comm2);
+      
+      
+      if(bcast_result == 0 && rank == 0)  printf("            \t test MPI_Bcast for split comm\t OK\n");
+      if(bcast_result != 0 && rank == 0)  printf("            \t test MPI_Bcast for split comm\t FAILED %d\n", bcast_result);
+      
+    }
+    
+    MPI_Barrier(comm);
+    MPI_Barrier(comm);
+    MPI_Barrier(comm);
+    
+    // TESE OF INTERCOMM_CREATE
+    {
+      MPI_Barrier(comm);
+      
+      int rank, size;
+      MPI_Comm_rank(comm, &rank);
+      MPI_Comm_size(comm, &size);
+      
+      int tab_color[16] = {2, 2, 2, 1, 2, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1};
+      int tab_key[16]   = {2, 1, 4, 1, 0, 4, 3, 3, 4, 3, 4, 4, 4, 0, 0, 2};
+
+      int color = tab_color[rank];
+      int key = tab_key[rank];
+      
+  
+      MPI_Comm split_comm;
+      MPI_Comm_split(comm, color, key, &split_comm);
+
+    
+      int split_rank, split_size;
+      MPI_Comm_rank(split_comm, &split_rank);
+      MPI_Comm_size(split_comm, &split_size);
+
+
+      printf("rank = %d, color = %d, key = %d, split_rank = %d, local_rank=%d\n", rank, color, key, split_rank, split_comm->ep_comm_ptr->size_rank_info[1].first);
+
+      MPI_Barrier(comm);
+      MPI_Barrier(comm);
+      
+      if(rank == 0) printf("            \t MPI_Comm_split \t OK\n");
+      
+      MPI_Barrier(comm);
+      MPI_Barrier(comm);
+      
+      
+      
+      
+      
+      int local_leader = 0;
+      int remote_leader = color==2? 13: 4;
+
+      MPI_Comm peer_comm = comm;
+
+      MPI_Comm inter_comm;
+      MPI_Intercomm_create(split_comm, local_leader, peer_comm, remote_leader, 99, &inter_comm);
+      
+
+
+      MPI_Barrier(comm);
+      MPI_Barrier(comm);
+
+      MPI_Barrier(split_comm);
+      MPI_Comm_free(&split_comm);
+
+
+      /*
+      MPI_Barrier(comm);
+      if(rank == 0) printf("\tMPI_Intercomm_create OK\n");
+      MPI_Barrier(comm);
+
+    
+
+      int high=color;
+      MPI_Comm intra_comm;
+      MPI_Intercomm_merge(inter_comm, high, &intra_comm);
+    
+      int intra_rank, intra_size;
+      MPI_Comm_rank(intra_comm, &intra_rank);
+      MPI_Comm_size(intra_comm, &intra_size);
+
+      MPI_Barrier(comm);
+      if(rank == 0) printf("\tMPI_Intercomm_merge OK\n");
+      MPI_Barrier(comm);
+    
+    
+
+      //check_test_gatherv(comm);
+      
+      MPI_Barrier(comm);
+      MPI_Comm_free(&inter_comm);
+      */
+    }
+  
     MPI_Barrier(comm);
     MPI_Comm_free(&comm);
-  }
   }
 
