/[escript]/trunk/paso/src/Paso_MPI.c
ViewVC logotype

Diff of /trunk/paso/src/Paso_MPI.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1343 by ksteube, Wed Nov 14 02:48:02 2007 UTC revision 1738 by gross, Fri Aug 29 05:06:45 2008 UTC
# Line 24  Line 24 
24  /* allocate memory for an mpi_comm, and find the communicator details */  /* allocate memory for an mpi_comm, and find the communicator details */
25  Paso_MPIInfo* Paso_MPIInfo_alloc( MPI_Comm comm )  Paso_MPIInfo* Paso_MPIInfo_alloc( MPI_Comm comm )
26  {  {
27    int error;    #ifdef PASO_MPI
28        int error;
29      #endif
30    
31    Paso_MPIInfo *out=NULL;    Paso_MPIInfo *out=NULL;
32    
33    out = MEMALLOC( 1, Paso_MPIInfo );    out = MEMALLOC( 1, Paso_MPIInfo );
# Line 98  dim_t Paso_MPIInfo_setDistribution(Paso_ Line 101  dim_t Paso_MPIInfo_setDistribution(Paso_
101     dim_t out;     dim_t out;
102     int s=mpi_info->size;     int s=mpi_info->size;
103     dim_t N=max_id-min_id+1;     dim_t N=max_id-min_id+1;
104     int local_N=N/s;     if (N>0) {
105     rest=N-local_N*s;        int local_N=N/s;
106     for (p=0; p<s; ++p) {        rest=N-local_N*s;
107        if (p<rest) {        for (p=0; p<s; ++p) {
108            distribution[p]=min_id+(local_N+1)*p;           if (p<rest) {
109            out=local_N+1;               distribution[p]=min_id+(local_N+1)*p;
110                 out=local_N+1;
111             } else {
112                 distribution[p]=min_id+rest+local_N*p;
113             }
114          }
115          distribution[s]=max_id+1;
116          if (rest==0) {
117             return local_N;
118        } else {        } else {
119            distribution[p]=min_id+rest+local_N*p;           return local_N+1;
120        }        }
121     }    } else {
122     distribution[s]=max_id+1;        for (p=0; p<s+1; ++p) distribution[p]=min_id;
123     if (rest==0) {        return 0;
124        return local_N;    }
    } else {  
       return local_N+1;  
    }  
125  }  }
126    
127  /* checks that there is no error accross all processes in a communicator */  /* checks that there is no error accross all processes in a communicator */
# Line 161  int Paso_MPIInfo_initialized( void ) Line 169  int Paso_MPIInfo_initialized( void )
169  }  }
170    
171  /* Append MPI rank to file name if multiple MPI processes */  /* Append MPI rank to file name if multiple MPI processes */
172  char *Paso_MPI_appendRankToFileName(char *fileName, int mpi_size, int mpi_rank) {  char *Paso_MPI_appendRankToFileName(const char *fileName, int mpi_size, int mpi_rank) {
173    char newFileName[4096];    /* Make plenty of room for the mpi_rank number and terminating '\0' */
174      char *newFileName = TMPMEMALLOC(strlen(fileName)+20,char);
175    strncpy(newFileName, fileName, strlen(fileName)+1);    strncpy(newFileName, fileName, strlen(fileName)+1);
176    if (mpi_size>1) sprintf(newFileName+strlen(newFileName), ".%04d", mpi_rank);    if (mpi_size>1) sprintf(newFileName+strlen(newFileName), ".%04d", mpi_rank);
177    return(newFileName);    return(newFileName);

Legend:
Removed from v.1343  
changed lines
  Added in v.1738

  ViewVC Help
Powered by ViewVC 1.1.26