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

Update

The two arrays i am trying to send from the other processors to processor 0 are incorrect
(atoms and N_list)(the first array does not receive the information and the second array still gives a segmentation fault)

The way I am sending the information must be wrong

I can send 1 dimensional arrays through send and recv successfully (receiving the same information i send)

How can you split an array so that i can send rows individually

Is there a way for example to call parts of an array as below

\\100 cells in a row
for(i=0;i<number_of_rows;i++)
{
  send row i
  MPI::COMM_WORLD.Send(data position of [i][0] - end of row, length(100), MPI::INT, to, tag);
}

Update

\\100 cells in a row
      for(i=0;i<number_of_rows;i++)
      {
      send row i
      MPI::COMM_WORLD.Send(data position of [i][0] - end of row, length(100), MPI::INT, to, tag);
      }

I should have tried it before i asked as it worked

for(int ti=0; ti<itr_atoms;ti++)
      MPI::COMM_WORLD.Send(&atoms[ti][0],         3,    MPI::DOUBLE, 0, 1000000+ti);

I would still like to know how to send 2d arrays

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.