<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Thanks, Matt,
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I see your point.  My problem is that I need to have many “masters” and each of these needs to have their own and distinct group of “children” processes to
 run some linear algebra in parallel.  Being new to MPI, I thought that the Spawn approach would help with that, because I already had a PETSc program that could solve the associated Least-squares problem. I thought that I only needed to adapt that code so
 that instead of calling it at the prompt, I could integrate it to a MPI code using MPI.SPAWN function. Since for some reason the MPI.SPAWN is not working correctly for me I am now seeking to solve my problem by splitting the COMM_WORLD instead, which I believe
 is more in line with your suggestion.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Kind regards<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Rodrigo<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Matthew Knepley [mailto:knepley@gmail.com]
<br>
<b>Sent:</b> Thursday, March 02, 2017 8:11 AM<br>
<b>To:</b> Rodrigo Felicio<br>
<b>Cc:</b> Barry Smith; petsc-users@mcs.anl.gov<br>
<b>Subject:</b> Re: [petsc-users] petsc4py and MPI.COMM_SELF.Spawn<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<div>
<p class="MsoNormal">On Wed, Mar 1, 2017 at 2:51 PM, Rodrigo Felicio <<a href="mailto:Rodrigo.Felicio@iongeo.com" target="_blank">Rodrigo.Felicio@iongeo.com</a>> wrote:<o:p></o:p></p>
<p class="MsoNormal">Sorry, I spoke too soon...<br>
Reversing the order between mpi4py and petsc4py imports does work *only* on the master code side, but not on the child process code side. In that case, the program hangs after the children processes are fired up and fails the same way as reported before...<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Again, I have no idea what you mean here. I do not think you can separately run the two codes. How will the<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">PMI manager know that these two separate processes should be in the same communicator (WORLD). It<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">makes no sense to me. In MPI, you need to write the master and child in the same code, with a switch for the<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">master rank.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">   Matt<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">cheers<br>
Rodrigo<br>
________________________________________<br>
From: <a href="mailto:petsc-users-bounces@mcs.anl.gov">petsc-users-bounces@mcs.anl.gov</a> [<a href="mailto:petsc-users-bounces@mcs.anl.gov">petsc-users-bounces@mcs.anl.gov</a>] on behalf of Rodrigo Felicio [<a href="mailto:Rodrigo.Felicio@iongeo.com">Rodrigo.Felicio@iongeo.com</a>]<br>
Sent: Wednesday, March 01, 2017 2:31 PM<br>
To: Barry Smith<br>
Cc: <a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a><br>
Subject: Re: [petsc-users] petsc4py and MPI.COMM_SELF.Spawn<o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
I thought I had tried that as well with no success before, but this time it worked, despite some persistent error msgs related to PMI_finalize:<br>
<br>
time mpirun -n 1 python dyn_mem_ex.py<br>
proc 2 of 4 proc 3 of 4<br>
proc 1 of 4<br>
proc 0 of 4<br>
<br>
proc 1 of 4, Adim=[10]<br>
proc 2 of 4, Adim=[10]<br>
proc 0 of 4, Adim=[10]<br>
proc 3 of 4, Adim=[10]<br>
Adata = [ 0.  1.  2.  3.  4.  5.  6.  7.  8.  9.]<br>
Adata = [ 0.  1.  2.  3.  4.  5.  6.  7.  8.  9.]Adata = [ 0.  1.  2.  3.  4.  5.  6.  7.  8.  9.]<br>
<br>
Adata = [ 0.  1.  2.  3.  4.  5.  6.  7.  8.  9.]<br>
3.14160098692<br>
2.65258238441e-06<br>
[cli_0]: write_line error; fd=12 buf=:cmd=finalize<br>
:<br>
system msg for write_line failure : Bad file descriptor<br>
Fatal error in MPI_Finalize: Other MPI error, error stack:<br>
MPI_Finalize(281).....: MPI_Finalize failed<br>
MPI_Finalize(209).....:<br>
MPID_Finalize(133)....:<br>
MPIDI_PG_Finalize(106): PMI_Finalize failed, error -1<br>
<br>
real    0m0.586s<br>
user    0m0.536s<br>
sys     0m0.613s<br>
<br>
Best,<br>
Rodrigo<br>
<br>
________________________________<br>
<br>
<br>
This email and any files transmitted with it are confidential and are intended solely for the use of the individual or entity to whom they are addressed. If you are not the original recipient or the person responsible for delivering the email to the intended
 recipient, be advised that you have received this email in error, and that any use, dissemination, forwarding, printing, or copying of this email is strictly prohibited. If you received this email in error, please immediately notify the sender and delete the
 original.<br>
<br>
<br>
________________________________<br>
<br>
<br>
This email and any files transmitted with it are confidential and are intended solely for the use of the individual or entity to whom they are addressed. If you are not the original recipient or the person responsible for delivering the email to the intended
 recipient, be advised that you have received this email in error, and that any use, dissemination, forwarding, printing, or copying of this email is strictly prohibited. If you received this email in error, please immediately notify the sender and delete the
 original.<o:p></o:p></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><br>
<br clear="all">
<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">-- <o:p></o:p></p>
<div>
<p class="MsoNormal">What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener<o:p></o:p></p>
</div>
</div>
</div>
</div>
<br>
<hr>
<font face="Arial" color="Gray" size="1"><br>
<br>
This email and any files transmitted with it are confidential and are intended solely for the use of the individual or entity to whom they are addressed. If you are not the original recipient or the person responsible for delivering the email to the intended
 recipient, be advised that you have received this email in error, and that any use, dissemination, forwarding, printing, or copying of this email is strictly prohibited. If you received this email in error, please immediately notify the sender and delete the
 original.<br>
<br>
</font>
</body>
</html>