<div dir="ltr"><div dir="ltr">On Tue, May 16, 2023 at 8:07 PM Khaled Nabil Shar Abdelaziz <<a href="mailto:kabdelaz@purdue.edu">kabdelaz@purdue.edu</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="msg-8500322500013950735">
<div lang="EN-US" style="overflow-wrap: break-word;">
<div class="m_-8500322500013950735WordSection1">
<p class="MsoNormal">This is very useful! I was more focused on my search for an example with DMDASNES example instead of ctx.
<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I guess from the looks of it, I can pass it directly in the ctx argument or I can pass the pointer using the interfaces defined in the referenced code you provided, correct?</p></div></div></div></blockquote><div><br></div><div>Yes.</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="msg-8500322500013950735"><div lang="EN-US" style="overflow-wrap: break-word;"><div class="m_-8500322500013950735WordSection1">
<p class="MsoNormal">Another question I had is that functions has to be defined as external? Is that a general case? Or is it just when the subroutine is defined elsewhere so I have to define it as external. Because now when the solver calls the FormFunction,
a NULL is being passed and I can’t access the x or F vectors. </p></div></div></div></blockquote><div><br></div><div>The symbol has to be exposed by the linker, so most times (unless everything is in the same file), it needs</div><div>to be external.</div><div><br></div><div> Thanks,</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="msg-8500322500013950735"><div lang="EN-US" style="overflow-wrap: break-word;"><div class="m_-8500322500013950735WordSection1">
<p class="MsoNormal">Thank you for your patience! I am still new to PETSc and learning how to use it.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(225,225,225);padding:3pt 0in 0in">
<p class="MsoNormal"><b>From:</b> Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> <br>
<b>Sent:</b> Sunday, May 14, 2023 12:24 PM<br>
<b>To:</b> Khaled Nabil Shar Abdelaziz <<a href="mailto:kabdelaz@purdue.edu" target="_blank">kabdelaz@purdue.edu</a>><br>
<b>Cc:</b> <a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a><br>
<b>Subject:</b> Re: [petsc-users] SNESDMDASNESSetFunctionLocal in Fortran<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<table border="0" cellpadding="0" width="100%" style="width:100%;background:rgb(255,240,160)">
<tbody>
<tr>
<td style="padding:3.75pt">
<p class="MsoNormal"><span style="font-size:10pt;font-family:Verdana,sans-serif;color:black">----
<b>External Email</b>: Use caution with attachments, links, or sharing data ----<u></u><u></u></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<div>
<p class="MsoNormal">On Sun, May 14, 2023 at 12:06 PM Khaled Nabil Shar Abdelaziz <<a href="mailto:kabdelaz@purdue.edu" target="_blank">kabdelaz@purdue.edu</a>> wrote:<u></u><u></u></p>
</div>
<div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0in 0in 0in 6pt;margin:5pt 0in 5pt 4.8pt">
<div>
<div>
<div>
<p class="MsoNormal">Hey there,<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">I'm having a problem with the DMDASNESSetFunctionLocal() function in C and its Fortran counterpart. The thing is, in C, you can pass a bunch of variables using the ctx parameter,
but in Fortran, it only seems to accept one variable.<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">What's weird is that the SNESSetFunction() function has a similar ctx parameter, but in Fortran, it can handle multiple variables for ctx, unlike DMDASNESSetFunctionLocal(). Do
you know if this is on purpose, or am I missing something?<u></u><u></u></p>
</div>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I think we show how to do this here:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"> <a href="https://gitlab.com/petsc/petsc/-/blob/main/src/snes/tutorials/ex5f90t.F90" target="_blank">https://gitlab.com/petsc/petsc/-/blob/main/src/snes/tutorials/ex5f90t.F90</a><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"> Thanks,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"> Matt<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0in 0in 0in 6pt;margin:5pt 0in 5pt 4.8pt">
<div>
<div>
<div>
<p class="MsoNormal">Thanks in advance!<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">Best regards,<u></u><u></u></p>
<p class="MsoNormal">Khaled<u></u><u></u></p>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><br clear="all">
<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<p class="MsoNormal"><span class="m_-8500322500013950735gmailsignatureprefix">-- </span><u></u><u></u></p>
<div>
<div>
<div>
<div>
<div>
<div>
<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<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div></blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><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>