[issm-svn] r11239 - issm/trunk/src/c/Container
morlighe at issm.ess.uci.edu
morlighe at issm.ess.uci.edu
Fri Jan 27 08:41:40 PST 2012
Author: morlighe
Date: 2012-01-27 08:41:40 -0800 (Fri, 27 Jan 2012)
New Revision: 11239
Modified:
issm/trunk/src/c/Container/Elements.cpp
Log:
Find the first cpu that has at least one element to output results instead of cpu 0, which might be empty
Modified: issm/trunk/src/c/Container/Elements.cpp
===================================================================
--- issm/trunk/src/c/Container/Elements.cpp 2012-01-27 16:20:25 UTC (rev 11238)
+++ issm/trunk/src/c/Container/Elements.cpp 2012-01-27 16:41:40 UTC (rev 11239)
@@ -179,6 +179,8 @@
bool results_as_patches;
int numberofvertices,numberofelements;
int numberofresults,vectorsize;
+ int rank;
+ int minrank;
/*Recover parameters: */
parameters->FindParam(&io_gather,SettingsIoGatherEnum);
@@ -189,25 +191,31 @@
if(!results_as_patches){
/*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));
resultstimes=(double*)xmalloc(numberofresults*sizeof(double));
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*/
for(int i=0;i<numberofresults;i++){
More information about the issm-svn
mailing list