53 #include "Petra_Comm.h"
54 #include "Petra_Time.h"
56 int main(
int argc,
char *argv[]) {
60 MPI_Init(&argc,&argv);
63 MPI_Comm_size(MPI_COMM_WORLD, &size);
64 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
69 Petra_Comm & petracomm = *
new Petra_Comm( MPI_COMM_WORLD );
70 int MyPID = petracomm.MyPID();
71 int NumProc = petracomm.NumProc();
72 cout <<
"Processor "<<MyPID<<
" of " << NumProc <<
" is alive."<<endl;
75 cout <<
" This special routine only works for 2 processors " << endl;
80 Petra_Comm * other_comm;
83 unsigned int icomm = &petracomm;
85 if (MyPID==1) cout <<
"Address of Petra_Comm object on PE 1 = " << &petracomm << endl;
87 if (MyPID==0) MPI_Recv((
void *) &other_comm, 1, MPI_UNSIGNED, 1, 99, MPI_COMM_WORLD, &status);
88 else MPI_Send ( (
void *) &icomm, 1, MPI_UNSIGNED, 0, 99, MPI_COMM_WORLD);
90 if (MyPID==0) cout <<
"Address of other Petra_Comm object on PE 0 = " << other_comm << endl;
92 int otherPID = other_comm->MyPID();
94 if (MyPID==0) cout <<
"Processor "<<MyPID<<
" of " << NumProc
95 <<
" has a neighbor processor with ID "
96 << otherPID <<
" of " << other_comm->NumProc() <<endl;
int main(int argc, char *argv[])