List Info

Thread: LAM: Problem running external program.




LAM: Problem running external program.
country flaguser name
India
2007-10-08 12:35:00
I am trying to run two external program sequentially. The program runs fine till the first external program call and dont execute the second one.

The code is as below:

#include <stdio.h>
#include "mpi.h"

int main(int argc,char **argv)
{
int *buf, i, rank, nints, len;
 ; char hostname[256];

 ; MPI_Init(&amp;argc,&amp;argv);
&nbsp; MPI_Comm_rank(MPI_COMM_WORLD, &rank);

  MPI_Barrier(MPI_COMM_WORLD);
&nbsp; gethostname(hostname,255);
 ; printf("Hello world!&nbsp; I am process number: %d on host %sn", rank, hostname);
  MPI_Barrier(MPI_COMM_WORLD);
&nbsp; execl("/bin/date", "date", NULL);
&nbsp; MPI_Barrier(MPI_COMM_WORLD);
&nbsp; execl("/bin/ls", "ls", NULL);
&nbsp; MPI_Barrier(MPI_COMM_WORLD);
&nbsp; MPI_Finalize();
 ; return 0;
}

The output I am getting is as below:

Hello world!&nbsp; I am process number: 0 on host cluster
Hello world!&nbsp; I am process number: 1 on host cluster
Hello world!&nbsp; I am process number: 2 on host compute-0-1.local
Hello world!&nbsp; I am process number: 4 on host compute-0-2.local
Hello world!&nbsp; I am process number: 3 on host compute-0-1.local
Hello world!&nbsp; I am process number: 5 on host compute-0-2.local
Thu Oct 11 12:18:40 IST 2007
Thu Oct 11 12:18:40 IST 2007
Thu Oct 11 12:18:40 IST 2007
Thu Oct 11 12:18:40 IST 2007
Thu Oct 11 12:18:40 IST 2007
Thu Oct 11 12:18:40 IST 2007



I am very new to MPI programing, any suggestions would be highly appreciated.

Thanking you in advance.

Regards

&#32;


Did you know? You can CHAT without downloading messenger. Click here
Re: LAM: Problem running external program.
user name
2007-10-08 12:44:42
Hi,
Use "system" instead of "execl".&nbsp; For more information try "man execl" and "man system".&nbsp; Basically, the first call to execl causes your program to be replaced by /bin/date. 
 
HTH,
 
mac mccalla


From: lam-bounceslam-mpi.org [mailto:lam-bounceslam-mpi.org] On Behalf Of E Cell
Sent: Monday, October 08, 2007 12:35 PM
To: lamlam-mpi.org
Subject: LAM: Problem running external program.

I am trying to run two external program sequentially. The program runs fine till the first external program call and dont execute the second one.

The code is as below:

#include <stdio.h>
#include "mpi.h"

int main(int argc,char **argv)
{
int *buf, i, rank, nints, len;
&nbsp; char hostname[256];

 ; MPI_Init(&argc,&argv);
  MPI_Comm_rank(MPI_COMM_WORLD, &rank);

  MPI_Barrier(MPI_COMM_WORLD);
&nbsp; gethostname(hostname,255);
&nbsp; printf("Hello world!&nbsp; I am process number: %d on host %sn", rank, hostname);
  MPI_Barrier(MPI_COMM_WORLD);
&nbsp; execl("/bin/date", "date", NULL);
&nbsp; MPI_Barrier(MPI_COMM_WORLD);
&nbsp; execl("/bin/ls", "ls", NULL);
&nbsp; MPI_Barrier(MPI_COMM_WORLD);
&nbsp; MPI_Finalize();
&nbsp; return 0;
}

The output I am getting is as below:

Hello world!&nbsp; I am process number: 0 on host cluster
Hello world!&nbsp; I am process number: 1 on host cluster
Hello world!&nbsp; I am process number: 2 on host compute-0-1.local
Hello world!&nbsp; I am process number: 4 on host compute-0-2.local
Hello world!&nbsp; I am process number: 3 on host compute-0-1.local
Hello world!&nbsp; I am process number: 5 on host compute-0-2.local
Thu Oct 11 12:18:40 IST 2007
Thu Oct 11 12:18:40 IST 2007
Thu Oct 11 12:18:40 IST 2007
Thu Oct 11 12:18:40 IST 2007
Thu Oct 11 12:18:40 IST 2007
Thu Oct 11 12:18:40 IST 2007



I am very new to MPI programing, any suggestions would be highly appreciated.

Thanking you in advance.

Regards


Did you know? You can CHAT without downloading messenger. Click here
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )