/******************************************************** % % Written by: % -- % John L. Weatherwax 2006-05-29 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- */ #include #include "mpi.h" #include "global_grid.h" #include "parseInputArgs.h" void parseInputArgs(int argc, char* argv[],int PR, int *Ms, int *Ns, int *NbPP, int *Nts){ /* Check the NUMBER of input arguments */ if( argc < 5 | argc > 5 ){ fprintf(stderr,"Incorrect number of input arguments.\n"); MPI_Abort(MPI_COMM_WORLD,1); } /* Read in the virtual processing grid dimensions [Ms,Ns] */ *Ms = atoi(argv[1]); if( *Ms <= 0 ){ fprintf(stderr,"Input argument *Ms* must be positive\n"); MPI_Abort(MPI_COMM_WORLD,1); } if( *Ms == 1 ){ fprintf(stderr,"Input argument *Ms* must be greater than 1\n"); MPI_Abort(MPI_COMM_WORLD,1); } /*printf("Ms=%d\n",*Ms);*/ *Ns = atoi(argv[2]); if( *Ns <= 0 ){ fprintf(stderr,"Input argument *Ns* must be positive\n"); MPI_Abort(MPI_COMM_WORLD,1); } if( *Ns == 1 ){ fprintf(stderr,"Input argument *Ns* must be greater than 1\n"); MPI_Abort(MPI_COMM_WORLD,1); } /*printf("Ns=%d\n",*Ns);*/ if( (*Ms)*(*Ns) != PR ){ fprintf(stderr,"Product of Ms*Ns != PR\n"); MPI_Abort(MPI_COMM_WORLD,1); } /* Read in the requested number of bodies (particles) per processor */ *NbPP = atoi(argv[3]); if( *NbPP <= 0 || *NbPP > MAX_N_BODIES ){ fprintf(stderr,"Input argument *NbPP* must be positive and less than %d\n",MAX_N_BODIES); MPI_Abort(MPI_COMM_WORLD,1); } /*printf("NbPP=%d\n",*NbPP);*/ /* Read in the number of timesteps to perform --It seems that it would be easier to compare differing algorithms on an even basis if the number of timesteps taken by each was the same */ *Nts = atoi(argv[4]); if( *Nts < 0 ){ fprintf(stderr,"Input argument *Nts* must be positive\n"); MPI_Abort(MPI_COMM_WORLD,1); } /*printf("Nts=%d\n",*Nts);*/ }