Index: /issm/trunk/src/c/Container/Elements.cpp
===================================================================
--- /issm/trunk/src/c/Container/Elements.cpp	(revision 11238)
+++ /issm/trunk/src/c/Container/Elements.cpp	(revision 11239)
@@ -180,4 +180,6 @@
 	int    numberofvertices,numberofelements;
 	int    numberofresults,vectorsize;
+	int    rank;
+	int    minrank;
 
 	/*Recover parameters: */
@@ -190,14 +192,20 @@
 		/*No patch here, we prepare vectors*/
 
+		/*Get rank of first cpu that has results*/
+		if(this->Size()) rank=my_rank;
+		else rank=num_procs;
+		MPI_Allreduce (&rank,&minrank,1,MPI_INT,MPI_MIN,MPI_COMM_WORLD);
+
 		/*see what the first element of this partition has in stock (this is common to all partitions)*/
-		if(my_rank==0){
-			if(this->Size()==0) _error_("Cannot write results because first partition has no element. Maybe too many cpus were requested");
+		if(my_rank==minrank){
+			if(this->Size()==0) _error_("Cannot write results because there is no element??");
 			Element* element=(Element*)this->GetObjectByOffset(0);
 			element->ListResultsInfo(&resultsenums,&resultssizes,&resultstimes,&resultssteps,&numberofresults);
 		}
-		MPI_Bcast(&numberofresults,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
+		MPI_Bcast(&numberofresults,1,MPI_DOUBLE,minrank,MPI_COMM_WORLD);
+
 		/*Get out if there is no results. Otherwise broadcast info*/
 		if(!numberofresults) return;
-		if(my_rank!=0){
+		if(my_rank!=minrank){
 			resultsenums=(int*)xmalloc(numberofresults*sizeof(int));
 			resultssizes=(int*)xmalloc(numberofresults*sizeof(int));
@@ -205,8 +213,8 @@
 			resultssteps=(int*)xmalloc(numberofresults*sizeof(int));
 		}
-		MPI_Bcast(resultsenums,numberofresults,MPI_INT,0,MPI_COMM_WORLD);
-		MPI_Bcast(resultssizes,numberofresults,MPI_INT,0,MPI_COMM_WORLD);
-		MPI_Bcast(resultstimes,numberofresults,MPI_DOUBLE,0,MPI_COMM_WORLD);
-		MPI_Bcast(resultssteps,numberofresults,MPI_INT,0,MPI_COMM_WORLD);
+		MPI_Bcast(resultsenums,numberofresults,MPI_INT,minrank,MPI_COMM_WORLD);
+		MPI_Bcast(resultssizes,numberofresults,MPI_INT,minrank,MPI_COMM_WORLD);
+		MPI_Bcast(resultstimes,numberofresults,MPI_DOUBLE,minrank,MPI_COMM_WORLD);
+		MPI_Bcast(resultssteps,numberofresults,MPI_INT,minrank,MPI_COMM_WORLD);
 
 		/*Loop over all results and get nodal vector*/
