Hello, I would welcome some help to this problem. I am trying to have a random no generator in a way that will create random no different for each process in the MPI run. I tried to seed with something that will take the rank of the process as below so I can take different numbers but are the same every time I run the program.
HOW CAN I TAKE DIFFERENT?
Many thanks on behalf
Code:
#include <stdio.h>
#include <mpi.h>
#include <time.h>
#include <limits.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{int i,id,p;
double random_val;
int seed;
MPI_Init(&argc,&argv);
MPI_Comm_rank(MPI_COMM_WORLD,&id);
MPI_Comm_size(MPI_COMM_WORLD,&p);
seed = 123456789 + id*100;
srand(seed);
random_val = (double)rand()/(double)RAND_MAX;
printf("Hello, world from process number %d with rand no %f\n", id, random_val);
MPI_Finalize();
return 0;
}