I am a beginner with Unix and MPI. For the serial program, I run the program by typing make
in /directory/buildagain
and then ./runPR.sh values.txt
. (values.txt
just contains the line Chain
)
Here is a small portion of my code.
int main( int argc, char *argv[ ] )
{
if( strcmp(argv[1],"-PR") == 0 )
runPR(argc-2, &argv[2]);
return 0;
}
int runPR(int argc, char* argv[])
{
cout<<"run here"<<endl;
MPI_Status status;
PetscMPIInt rank,size;
//bunch of code that assigns argv2 to include argv and some new strings and sets
//argc2=argc plus the number of new string
PetscInitialize(&argc2, &argv2,0,0);
MPI_Comm_size(PETSC_COMM_WORLD,&size);
MPI_Comm_rank(PETSC_COMM_WORLD,&rank);
PetscPrintf(PETSC_COMM_WORLD,"Number of processors = %d, rank = %d\n",size,rank);
PetscSynchronizedPrintf(PETSC_COMM_WORLD,"synchronized rank = %d\n",rank);
PetscSynchronizedFlush(PETSC_COMM_WORLD);//,PETSC_STDOUT);
MPI_Barrier(PETSC_COMM_WORLD);
PetscPrintf(PETSC_COMM_SELF,"[%d] Jumbled Hello World\n",rank);
PROpt opt;
Solve* ps = new Solve();
PROpt opt;
Solve* ps = new Solve();
ps->getFile(&opt,argv[0]);
}
By typing mpirun -np 4 ./runPR.sh values.txt
, I see Number of processors = 1, rank = 0
and
synchronized rank = 0
printed 4 times. But I don't see synchronized rank = 1
or 2 or 3 printed out. Why is this?
Here is what run.PR.sh
contains
DIR=/directory/buildagain/bin/Project
FILELIST=$1
while read FILE
do
echo "Processing ${FILE}..."
./makeInp.sh ${FILE} ${FILE} >INP/${FILE}.inp
mpiexec -np 4 ${DIR} -PR INP/${FILE}.inp
done < ${FILELIST}
EDIT: I was able to get the helloworld PETSc example to work properly at http://www.mcs.anl.gov/petsc/petsc-current/src/sys/examples/tutorials/ex2.c.html