Changeset 11059


Ignore:
Timestamp:
12/24/11 09:22:30 (13 years ago)
Author:
Mathieu Morlighem
Message:

Find first cpu that has more than zero elements to write results

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/Container/Elements.cpp

    r11026 r11059  
    167167
    168168        extern int my_rank;
     169        extern int num_procs;
    169170
    170171        Patch  *patch        = NULL;
     
    179180        int    numberofvertices,numberofelements;
    180181        int    numberofresults,vectorsize;
     182        int    rank;
     183        int    minrank;
    181184
    182185        /*Recover parameters: */
     
    189192                /*No patch here, we prepare vectors*/
    190193
     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
    191199                /*see what the first element of this partition has in stock (this is common to all partitions)*/
    192                 if(my_rank==0){
    193                         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??");
    194202                        Element* element=(Element*)this->GetObjectByOffset(0);
    195203                        element->ListResultsInfo(&resultsenums,&resultssizes,&resultstimes,&resultssteps,&numberofresults);
     
    199207                /*Get out if there is no results. Otherwise broadcast info*/
    200208                if(!numberofresults) return;
    201                 if(my_rank!=0){
     209                if(my_rank!=minrank){
    202210                        resultsenums=(int*)xmalloc(numberofresults*sizeof(int));
    203211                        resultssizes=(int*)xmalloc(numberofresults*sizeof(int));
Note: See TracChangeset for help on using the changeset viewer.