I am having problems with sending my array N_List
int** N_List = create_2d_int_array(len_N_List, 100, "voro:N_List");
double** atoms = create_2d_double_array((int) (8*box_x*box_y*box_z/(lattice*lattice*lattice)), 3, "voro:atoms");
for(i=0;i<len_N_List; i++)
for(j=0;j<100;j++)
N_List[i][j] = 0;
The code runs fine with N_list send and recv omitted but with it, it causes a segmentation fault
Send
if(rank != 0)
{
MPI::COMM_WORLD.Send(&itr_atoms, 1, MPI::INT, 0, 100000+rank);
MPI::COMM_WORLD.Send(atoms, itr_atoms*3, MPI::DOUBLE, 0, 200000+rank);
MPI::COMM_WORLD.Send(&itr_gb_atoms, 1, MPI::INT, 0, 300000+rank);
MPI::COMM_WORLD.Send(gb_atoms, itr_gb_atoms*3, MPI::DOUBLE, 0, 400000+rank);
cout << "Send 1\n";
MPI::COMM_WORLD.Send(N_List, len_N_List*100, MPI::INT, 0, 500000+rank);
for(int rj=0; rj<len_N_List; rj++)
MPI::COMM_WORLD.Send(&num_N[rj], 1, MPI::INT, 0, ((rank+1)*1000000)+rj);
cout << "Send 2\n";
}
Receive
The two loops below are inside an if loop: if(rank == 0)
for(int rj=1; rj<size; rj++)
{
MPI::COMM_WORLD.Recv(&itr_atoms, 1, MPI::INT, rj, 100000+rj);
MPI::COMM_WORLD.Recv(atoms, itr_atoms*3, MPI::DOUBLE, rj, 200000+rj);
MPI::COMM_WORLD.Recv(&itr_gb_atoms, 1, MPI::INT, rj, 300000+rj);
MPI::COMM_WORLD.Recv(gb_atoms, itr_gb_atoms*3, MPI::DOUBLE, rj, 400000+rj);
cout << "Recv 1\n";
}
for(int rj=1; rj<size; rj++)
{
MPI::COMM_WORLD.Recv(N_List, len_N_List*100, MPI::INT, rj, 500000+rj);
for(int rk=0; rk<len_N_List; rk++)
MPI::COMM_WORLD.Recv(&num_N[rk], 1, MPI::INT, rj, ((rj+1)*1000000)+rk);
cout << "Recv 2\n";
}
[SOLI37468C:20550] Signal: Segmentation fault (11)
[SOLI37468C:20550] Signal code: Address not mapped (1)
[SOLI37468C:20550] Failing at address: 0x40
[SOLI37468C:20551] *** Process received signal ***
[SOLI37468C:20551] Signal: Segmentation fault (11)
[SOLI37468C:20551] Signal code: Address not mapped (1)
[SOLI37468C:20551] Failing at address: 0x5bf000
[SOLI37468C:20550] *** Process received signal ***
At a glance can anyone see if I am doing something foolish