[petsc-users] SNESDMDASNESSetFunctionLocal in Fortran

Khaled Nabil Shar Abdelaziz kabdelaz at purdue.edu
Tue May 16 19:07:47 CDT 2023

This is very useful! I was more focused on my search for an example with DMDASNES example instead of ctx.

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?

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.

Thank you for your patience! I am still new to PETSc and learning how to use it.

From: Matthew Knepley <knepley at gmail.com>
Sent: Sunday, May 14, 2023 12:24 PM
To: Khaled Nabil Shar Abdelaziz <kabdelaz at purdue.edu>
Cc: petsc-users at mcs.anl.gov
Subject: Re: [petsc-users] SNESDMDASNESSetFunctionLocal in Fortran

---- External Email: Use caution with attachments, links, or sharing data ----

On Sun, May 14, 2023 at 12:06 PM Khaled Nabil Shar Abdelaziz <kabdelaz at purdue.edu<mailto:kabdelaz at purdue.edu>> wrote:
Hey there,

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.

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?

I think we show how to do this here:




Thanks in advance!

Best regards,

What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
-- Norbert Wiener

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20230517/0dfde866/attachment.html>

More information about the petsc-users mailing list