Changeset 11239
- Timestamp:
- 01/27/12 08:41:40 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/Container/Elements.cpp
r11237 r11239 180 180 int numberofvertices,numberofelements; 181 181 int numberofresults,vectorsize; 182 int rank; 183 int minrank; 182 184 183 185 /*Recover parameters: */ … … 190 192 /*No patch here, we prepare vectors*/ 191 193 194 /*Get rank of first cpu that has results*/ 195 if(this->Size()) rank=my_rank; 196 else rank=num_procs; 197 MPI_Allreduce (&rank,&minrank,1,MPI_INT,MPI_MIN,MPI_COMM_WORLD); 198 192 199 /*see what the first element of this partition has in stock (this is common to all partitions)*/ 193 if(my_rank== 0){194 if(this->Size()==0) _error_("Cannot write results because first partition has no element. Maybe too many cpus were requested");200 if(my_rank==minrank){ 201 if(this->Size()==0) _error_("Cannot write results because there is no element??"); 195 202 Element* element=(Element*)this->GetObjectByOffset(0); 196 203 element->ListResultsInfo(&resultsenums,&resultssizes,&resultstimes,&resultssteps,&numberofresults); 197 204 } 198 MPI_Bcast(&numberofresults,1,MPI_DOUBLE,0,MPI_COMM_WORLD); 205 MPI_Bcast(&numberofresults,1,MPI_DOUBLE,minrank,MPI_COMM_WORLD); 206 199 207 /*Get out if there is no results. Otherwise broadcast info*/ 200 208 if(!numberofresults) return; 201 if(my_rank!= 0){209 if(my_rank!=minrank){ 202 210 resultsenums=(int*)xmalloc(numberofresults*sizeof(int)); 203 211 resultssizes=(int*)xmalloc(numberofresults*sizeof(int)); … … 205 213 resultssteps=(int*)xmalloc(numberofresults*sizeof(int)); 206 214 } 207 MPI_Bcast(resultsenums,numberofresults,MPI_INT, 0,MPI_COMM_WORLD);208 MPI_Bcast(resultssizes,numberofresults,MPI_INT, 0,MPI_COMM_WORLD);209 MPI_Bcast(resultstimes,numberofresults,MPI_DOUBLE, 0,MPI_COMM_WORLD);210 MPI_Bcast(resultssteps,numberofresults,MPI_INT, 0,MPI_COMM_WORLD);215 MPI_Bcast(resultsenums,numberofresults,MPI_INT,minrank,MPI_COMM_WORLD); 216 MPI_Bcast(resultssizes,numberofresults,MPI_INT,minrank,MPI_COMM_WORLD); 217 MPI_Bcast(resultstimes,numberofresults,MPI_DOUBLE,minrank,MPI_COMM_WORLD); 218 MPI_Bcast(resultssteps,numberofresults,MPI_INT,minrank,MPI_COMM_WORLD); 211 219 212 220 /*Loop over all results and get nodal vector*/
Note:
See TracChangeset
for help on using the changeset viewer.