<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.16825" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV dir=ltr align=left><SPAN class=404390114-08052009><FONT face=Arial
color=#0000ff size=2>Hi,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=404390114-08052009><FONT face=Arial
color=#0000ff size=2> Didn't passing a dummy env block to CreateProcess()
work for you ?</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=404390114-08052009><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=404390114-08052009><FONT face=Arial
color=#0000ff size=2>Regards,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=404390114-08052009><FONT face=Arial
color=#0000ff size=2>Jayesh</FONT></SPAN></DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> Rod Cook [mailto:rod@cookies.demon.co.uk]
<BR><B>Sent:</B> Wednesday, April 22, 2009 10:12 AM<BR><B>To:</B> Jayesh
Krishna<BR><B>Cc:</B> mpich-discuss@mcs.anl.gov<BR><B>Subject:</B> Re:
[mpich-discuss] Running one MPI program from another<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV><FONT face=Arial size=2>Jayesh,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I can get my example code to work using
MPI_Comm_spawn but it doesn't work for my actual application. The problem
with using MPI_Comm_spawn is that I don't know how to tell that the spawned
program has finished -- this is why I used CreateProcess because it is possible
to wait for the program to terminate. The spawned program could be a non MPI
executable or a standalone MPI executable which can't communicate with the
program calling MPI_Comm_spawn. </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Cheers,</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>Rod</FONT></DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=jayesh@mcs.anl.gov href="mailto:jayesh@mcs.anl.gov">Jayesh
Krishna</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=rod@cookies.demon.co.uk
href="mailto:rod@cookies.demon.co.uk">'Rod Cook'</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Cc:</B> <A title=mpich-discuss@mcs.anl.gov
href="mailto:mpich-discuss@mcs.anl.gov">mpich-discuss@mcs.anl.gov</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Wednesday, April 22, 2009 3:40
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> RE: [mpich-discuss] Running one
MPI program from another</DIV>
<DIV><BR></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=369243814-22042009>Hi,</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=369243814-22042009> Did you try MPI_Comm_spawn()
?</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=369243814-22042009></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=369243814-22042009>Regards,</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=369243814-22042009>Jayesh</SPAN></FONT></DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> <A
href="mailto:mpich-discuss-bounces@mcs.anl.gov">mpich-discuss-bounces@mcs.anl.gov</A>
[mailto:mpich-discuss-bounces@mcs.anl.gov] <B>On Behalf Of </B>Rod
Cook<BR><B>Sent:</B> Wednesday, April 22, 2009 7:50 AM<BR><B>To:</B> <A
href="mailto:mpich-discuss@mcs.anl.gov">mpich-discuss@mcs.anl.gov</A><BR><B>Subject:</B>
[mpich-discuss] Running one MPI program from another<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV><FONT face=Arial size=2>Hi,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I am trying to run an MPI program (prog) from
another MPI program (test) using CreateProcess under Windows XP.
</FONT><FONT face=Arial size=2>I am using MPICH2 v1.08. </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Source for test</FONT></DIV>
<DIV><FONT face=Arial size=2>#include "stdafx.h"<BR>#include
<afx.h><BR>#include "mpi.h"</FONT></DIV>
<DIV><FONT face=Arial size=2>int run_program( char * program
)<BR>{<BR> STARTUPINFO si;<BR> PROCESS_INFORMATION
pi;<BR> ZeroMemory( &si, sizeof(si) );<BR> si.cb =
sizeof(si);<BR> ZeroMemory( &pi, sizeof(pi) );<BR>
if( !CreateProcess( NULL, program, NULL, NULL, FALSE,</FONT><FONT
face=Arial size=2> 0,</FONT><FONT face=Arial size=2> NULL, NULL, &si,
&pi ) ) <BR> {<BR> return
-1;<BR> }<BR> WaitForSingleObject( pi.hProcess,
INFINITE );<BR> CloseHandle( pi.hProcess );<BR>
CloseHandle( pi.hThread );<BR> return 0;<BR>}<BR>int main(int
argc, char* argv[])<BR>{<BR> MPI_Init(NULL,NULL);<BR>
run_program("prog");<BR> MPI_Finalize();<BR> return
0;<BR>}<BR></DIV></FONT>
<DIV><FONT face=Arial size=2>Source for prog</FONT></DIV>
<DIV><FONT face=Arial size=2>#include "stdafx.h"<BR>#include
"mpi.h"</FONT></DIV>
<DIV><FONT face=Arial size=2>int main(int argc, char*
argv[])<BR>{<BR> MPI_Init( NULL, NULL );<BR>
MPI_Finalize();<BR> return 0;<BR>}<BR></FONT></DIV>
<DIV><FONT face=Arial size=2>I get the following error when I run
test:</DIV></FONT>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>>mpiexec -n 1 test<BR>MPIDU_Sock_post_connect
failed.<BR>[0] PMI_ConnectToHost failed: unable to post a connect to
Yellowtail
yellowtail<BR>
:2057, error: Unknown error class, error
stack:<BR>MPIDU_Sock_post_connect(1228): unable to connect to Yellowtail
yellowtail <BR> on port 2057, exhausted all endpoints (errno
-1)<BR>MPIDU_Sock_post_connect(1275): unable to connect
to
on port 2057,<BR> No connection could be made because the target
machine actively refused it. (er<BR>rno
10061)<BR>MPIDU_Sock_post_connect(1275): unable to connect to yellowtail on
port 2057, No<BR>connection could be made because the target machine actively
refused it. (errno<BR>10061)<BR>MPIDU_Sock_post_connect(1275): unable to
connect to Yellowtail on port 2057, No<BR>connection could be made because the
target machine actively refused it. (errno<BR>10061)<BR>uPMI_ConnectToHost
returning PMI_FAIL<BR>[0] PMI_Init failed.<BR>Fatal error in MPI_Init: Other
MPI error, error stack:<BR>MPIR_Init_thread(294): Initialization
failed<BR>MPID_Init(83)........: channel initialization
failed<BR>MPID_Init(334).......: PMI_Init returned -1<BR>></FONT></DIV>
<DIV><FONT face=Arial size=2> </DIV></FONT>
<DIV><FONT face=Arial size=2>In my actual application prog is either a
standalone MPI program which I can't change or a non MPI program (in
which case test works) . </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT><FONT face=Arial
size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I'd be gratefull for any help.</FONT><FONT
face=Arial size=2></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Thanks</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Rod Cook</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV></BLOCKQUOTE></BODY></HTML>