<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Oct 7, 2020, at 5:02 PM, baikadi pranay <<a href="mailto:pranayreddy865@gmail.com" class="">pranayreddy865@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Thank you Barry for the response. Just to make sure I understood correctly, I do not need to define any attributes to the vectors and it is automatically taken care of (both the intent as well as the allocatable attributes). Am I correct?<br class="">For the second question, my subroutine should look like this:<br class=""><b class="">FormFunction(snes,x,f,3,INTEGER_VARIABLE,ierr)<br class=""></b>Is this correct?<br class=""><br class=""></div></div></blockquote><div><br class=""></div> For example src/snes/tutorials/ex1f.F90</div><div><br class=""><div> subroutine FormFunction(snes,x,f,dummy,ierr)</div><div> use petscsnes</div><div> implicit none</div><div><br class=""></div><div> SNES snes</div><div> Vec x,f</div><div> PetscErrorCode ierr</div><div> integer dummy(*)</div><div><br class=""></div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class="">Thank you in advance.<br class="">Best Regards,<br class="">Pranay.<br class=""><br class=""></div><div hspace="streak-pt-mark" style="max-height:1px" class=""><img alt="" style="width:0px;max-height:0px;overflow:hidden" src="https://mailfoogae.appspot.com/t?sender=acHJhbmF5cmVkZHk4NjVAZ21haWwuY29t&type=zerocontent&guid=a0bc30d7-a0b3-4291-b9a4-e90deb8fbde8" class=""><font color="#ffffff" size="1" class="">ᐧ</font></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Oct 7, 2020 at 1:26 PM Barry Smith <<a href="mailto:bsmith@petsc.dev" class="">bsmith@petsc.dev</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br class="">
<br class="">
> On Oct 7, 2020, at 1:41 PM, baikadi pranay <<a href="mailto:pranayreddy865@gmail.com" target="_blank" class="">pranayreddy865@gmail.com</a>> wrote:<br class="">
> <br class="">
> Hello,<br class="">
> I have a few questions regarding FormFunction when using the SNES solvers. I am using Fortran90. <br class="">
> <br class="">
> 1) I went through the example (ex1f.F90) provided in the documentation that uses Newton method to solve a two-variable system. In the subroutine FormFunction, the first argument is an input vector (x). However in the code, no attributes are specified saying that it is an input argument for the subroutine (i.e. intent attribute is not specified). Is this automatically taken care of or should I be defining the intent attribute in my code ?<br class="">
<br class="">
We don't currently provide attributes for our Fortran stubs, so it is best if you do not mark them in your subroutines. <br class="">
<br class="">
Yes the x is input only and the f is output only.<br class="">
<br class="">
> Also, should I use the "allocatable" attribute when defining the vector x?<br class="">
<br class="">
I am pretty sure no.<br class="">
<br class="">
> Please comment similarly on the output vector f as well.<br class="">
> 2) Should the ctx argument of the subroutine FormFunction be defined as "PETSC_NULL_INTEGER"?<br class="">
<br class="">
The context is how you convey additional information into FormFunction(). Should you choose to not use it then in your function you can declare it as a integer and simply not use it. If you are calling your FormFunction() from Fortran then just pass a meaningless integer as that argument. PETSC_NULL_INTEGER is for call PETSc functions that take integer array arguments that you are not supplying.<br class="">
<br class="">
Barry<br class="">
<br class="">
<br class="">
<br class="">
> <br class="">
> Please let me know if you need any further information. <br class="">
> <br class="">
> Thank you.<br class="">
> Best Regards,<br class="">
> Pranay.<br class="">
<br class="">
</blockquote></div>
</div></blockquote></div><br class=""></body></html>