Newsgroups: comp.parallel.mpi
From: Andreas Baumhof <baumhof@informatik.uni-muenchen.de>
Subject: MPI newbi problem
Organization: Deas Corporation
Date: Fri, 04 Oct 1996 16:43:19 +0200
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: <32552241.34DDDCB7@informatik.uni-muenchen.de>

Hello MPI-Users,

I am very new to MPI an have a question how MPI works.
I am using it on LINUX with the ch_p4 device.

I thought that "mpirun -np 3 file" runs the whole file on 3 machines.
But the following program does not work:

double *punkt, *erg, *erg1;

MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
MPI_Comm_size(MPI_COMM_WORLD, &p);

if (my_rank == 1) {
  erg=f(punkt);
  sprintf(message, "f(..) = %0.12lf", *erg);
  MPI_Send(message, strlen(message)+1, MPI_CHAR, 0, tag,
MPI_COMM_WORLD);
} else if (my_rank == 2) {
  erg=d(punkt);
  sprintf(message, "d(..) = (%0.12f, %0.12f), *erg, *(erg+1));
  MPI_Send(message, strlen(message)+1, MPI_CHAR, 0, tag,
MPI_COMM_WORLD);
} else if (my_rank == 0) {
  for (i=1;i<p;i++) {
    MPI_Recv(message, 100, MPI_CHAR, source, tag, MPI_COMM_WORLD,
&status);
}

In this version the program crashes with the output:
p2_5119: p4_error: interrupt SIGSEGV: 11
rm_l_-301727744_5126: p4_error: interrupt SIGINT:2
f(..) = 0.987221333333
p0_5104: (5.821580) Trying to receive a message when there are no
connections; Bailing out


If I use erg1 instead of erg when my_rank==2 then the output is correct!

What is the problem here??

Thanks :-)


----------------------------------
Andreas Baumhof
baumhof@informatik.uni-muenchen.de
----------------------------------

