<div dir="ltr"><div dir="ltr">On Thu, Oct 13, 2022 at 5:27 PM Peng Sun <<a href="mailto:psun@outlook.com">psun@outlook.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="msg2520927641871884292">




<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Hi Stefano,</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Sure, please see the following.  The PETSC_ARCH field is empty in the printout despite the fact that it was set to 'arch-linux-c-opt' in the shell.<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
{'PETSC_DIR': '/home/pesun/.emopt', 'PETSC_ARCH': ''}</div></div></div></blockquote><div><br></div><div>Can you show the whole output?</div><div><br></div><div>Also, did you remember to 'export' it so that it goes to subshells?</div><div><br></div><div>   Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="msg2520927641871884292"><div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Best regards,</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Peng Sun<br>
</div>
<div id="m_-3942971054390250224appendonsend"></div>
<hr style="display:inline-block;width:98%">
<div id="m_-3942971054390250224divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Stefano Zampini <<a href="mailto:stefano.zampini@gmail.com" target="_blank">stefano.zampini@gmail.com</a>><br>
<b>Sent:</b> Thursday, October 13, 2022 1:57 PM<br>
<b>To:</b> Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>><br>
<b>Cc:</b> Peng Sun <<a href="mailto:psun@outlook.com" target="_blank">psun@outlook.com</a>>; <a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a> <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>><br>
<b>Subject:</b> Re: [petsc-users] Issue with single precision complex numbers in petsc4py</font>
<div> </div>
</div>
<div style="overflow-wrap: break-word;">Matt
<div><br>
</div>
<div>Yes, petsc4py does the right thing. This is probably. Picking up the wrong PETSc arch.</div>
<div><br>
</div>
<div>Peng, can you please run this?</div>
<div>
<div><br>
</div>
<div>import petsc4py<br>
<div>petsc4py.init()</div>
<div>print(petsc4py.get_config())</div>
<div><br>
<blockquote type="cite">
<div>On Oct 13, 2022, at 11:23 PM, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> wrote:</div>
<br>
<div>
<div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
Lisandro,
<div><br>
</div>
<div>PETSc is compiled for single. Does petsc4py respect this, or does it always use double for getArray() and friends?</div>
<div><br>
</div>
<div>  Thanks,</div>
<div><br>
</div>
<div>     Matt</div>
</div>
<br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<div dir="ltr">On Thu, Oct 13, 2022 at 11:42 AM Peng Sun <<a href="mailto:psun@outlook.com" target="_blank">psun@outlook.com</a>> wrote:<br>
</div>
<blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt">Hi Matt,</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt"><br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt">Sure, please see the attached configure.log file.  Thanks!</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt"><br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt">Best regards,</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt">Peng Sun<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt"><br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt"><br>
</div>
<div id="m_-3942971054390250224x_m_-7847157880467528269appendonsend"></div>
<hr style="display:inline-block;width:965.016px">
<div id="m_-3942971054390250224x_m_-7847157880467528269divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt"><b>From:</b><span> </span>Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>><br>
<b>Sent:</b><span> </span>Thursday, October 13, 2022 6:34 AM<br>
<b>To:</b><span> </span>Peng Sun <<a href="mailto:psun@outlook.com" target="_blank">psun@outlook.com</a>><br>
<b>Cc:</b><span> </span><a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a><span> </span><<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>><br>
<b>Subject:</b><span> </span>Re: [petsc-users] Issue with single precision complex numbers in petsc4py</font>
<div> </div>
</div>
<div>
<div dir="ltr">First send configure.log so we can see the setup.
<div><br>
</div>
<div> <span> </span>Thanks,</div>
<div><br>
</div>
<div>     <span> </span>Matt</div>
</div>
<br>
<div>
<div dir="ltr">On Thu, Oct 13, 2022 at 12:53 AM Peng Sun <<a href="mailto:psun@outlook.com" target="_blank">psun@outlook.com</a>> wrote:<br>
</div>
<blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt">
<p style="margin-right:0in;margin-left:0in;font-size:11pt;font-family:Calibri,sans-serif">
Dear PETSc community,<u></u> <u></u></p>
<p style="margin-right:0in;margin-left:0in;font-size:11pt;font-family:Calibri,sans-serif">
<br>
</p>
<p style="margin-right:0in;margin-left:0in;font-size:11pt;font-family:Calibri,sans-serif">
I have a question regarding the single precision complex numbers of petsc4py.<span> <span> </span></span>I configured PETSc with the “--with-scalar-type=complex --with-precision=single" option before compiling, but all
 the DA structures I created with petsc4py had double precision.  </p>
<p style="margin-right:0in;margin-left:0in;font-size:11pt;font-family:Calibri,sans-serif">
<br>
</p>
<p style="margin-right:0in;margin-left:0in;font-size:11pt;font-family:Calibri,sans-serif">
Here is a minimum test code on Python 3.8/PETSc 3.12/petsc4py 3.12: both print commands show data type of complex128.  Could anybody please help me?  Thanks!</p>
<p style="margin-right:0in;margin-left:0in;font-size:11pt;font-family:Calibri,sans-serif">
<br>
</p>
<div style="margin:0px 0in;font-size:11pt;font-family:Calibri,sans-serif">
<pre style="margin-top:0px;width:auto;max-height:600px;overflow:auto;text-align:left"><code style="margin:0px"><span style="margin:0px;font-size:13px">import</span> petsc4py
<span style="margin:0px;font-size:13px">import</span> sys
petsc4py.init(sys.argv)
<span style="margin:0px;font-size:13px">from</span> petsc4py <span style="margin:0px;font-size:13px">import</span> PETSc

da=PETSc.DA().create(sizes=[<span style="margin:0px;font-size:13px">2</span>,<span style="margin:0px;font-size:13px">2</span>,<span style="margin:0px;font-size:13px">2</span>],dof=<span style="margin:0px;font-size:13px">1</span>,stencil_type=<span style="margin:0px;font-size:13px">0</span>,stencil_width=<span style="margin:0px;font-size:13px">1</span>,boundary_type=<span style="margin:0px;font-size:13px">1</span>)
da_1 = da.createGlobalVec()
<span style="margin:0px;font-size:13px">print</span>(petsc4py.PETSc.ComplexType)
<span style="margin:0px;font-size:13px">print</span>(da_1.getArray().dtype)</code></pre>
<br>
</div>
<p style="margin-right:0in;margin-left:0in;font-size:11pt;font-family:Calibri,sans-serif">
<br>
</p>
<p style="margin-right:0in;margin-left:0in;font-size:11pt;font-family:Calibri,sans-serif">
<br>
</p>
<p style="margin-right:0in;margin-left:0in;font-size:11pt;font-family:Calibri,sans-serif">
Best regards,</p>
<p style="margin-right:0in;margin-left:0in;font-size:11pt;font-family:Calibri,sans-serif">
Peng Sun</p>
</div>
</div>
</div>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
--<span> </span><br>
<div dir="ltr">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>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</div>
<div><br>
</div>
<div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br clear="all" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<br>
</div>
<span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline">--<span> </span></span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>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</div>
<div><br>
</div>
<div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>

</div></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>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</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>