gather a Petsc Vector spread across the cluster, onto node 0, and then broadcast to all nodes.
More...
Go to the source code of this file.
gather a Petsc Vector spread across the cluster, onto node 0, and then broadcast to all nodes.
Definition in file VecToMPISerial.cpp.
◆ VecToMPISerial()
int VecToMPISerial |
( |
double ** |
pgathered_vector, |
|
|
Vec |
vector, |
|
|
ISSM_MPI_Comm |
comm, |
|
|
bool |
broadcast |
|
) |
| |
Definition at line 14 of file VecToMPISerial.cpp.
22 PetscInt lower_row,upper_row;
28 double* local_vector=NULL;
34 double* gathered_vector=NULL;
40 VecGetSize(vector,&vector_size);
42 *pgathered_vector=NULL;
47 if(broadcast || my_rank==0){
48 gathered_vector=xNew<double>(vector_size);
52 VecGetOwnershipRange(vector,&lower_row,&upper_row);
54 range=upper_row-lower_row+1;
57 idxn=xNew<int>(range);
58 for (i=0;i<range;i++){
59 *(idxn+i)=lower_row+i;
61 local_vector=xNew<double>(range);
63 VecGetValues(vector,range,idxn,local_vector);
68 for (i=1;i<num_procs;i++){
84 if (range)memcpy(gathered_vector+lower_row,local_vector,range*
sizeof(
double));
93 *pgathered_vector=gathered_vector;
97 xDelete<double>(local_vector);
int ISSM_MPI_Send(void *buf, int count, ISSM_MPI_Datatype datatype, int dest, int tag, ISSM_MPI_Comm comm)
int ISSM_MPI_Recv(void *buf, int count, ISSM_MPI_Datatype datatype, int source, int tag, ISSM_MPI_Comm comm, ISSM_MPI_Status *status)