<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Ah, silly me... Of course, if the program can't actually see the
interface then it makes sense that it won't work.<br>
As always, thanks a lot for your help, Barry!<br>
<br>
Samuel<br>
<br>
<br>
<div class="moz-cite-prefix">On 12/13/2017 04:01 AM, Smith, Barry F.
wrote:<br>
</div>
<blockquote
cite="mid:60ECF900-6539-467E-BF8A-E527F26568BA@mcs.anl.gov"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<div class="BodyFragment"><font size="2"><span
style="font-size:10pt;">
<div class="PlainText"><br>
Samuel,<br>
<br>
I have attached a fixed up version of your example
that works correctly. Your basic problem was that you did
not "use" the final module in the main program so it did
know the interfaces for the routines. I have included
this example in PETSc for others to benefit from in the
branch barry/add-f90-matshellgetcontext-example<br>
<br>
Thanks for the question,<br>
<br>
Barry<br>
</div>
</span></font></div>
<div class="BodyFragment"><font size="2"><span
style="font-size:10pt;">
<div class="PlainText"><br>
<br>
<br>
<br>
> On Dec 12, 2017, at 3:52 AM, Samuel Lanthaler
<a class="moz-txt-link-rfc2396E" href="mailto:s.lanthaler@gmail.com"><s.lanthaler@gmail.com></a> wrote:<br>
> <br>
> Let me also add a minimal example (relying only on
petsc), which leads to the same error message on my
machine. Again, what I'm trying to do is very simple:<br>
> • MatCreateShell => Initialize Mat :: F<br>
> • MatShellSetContext => set the context of
F to ctxF (looking at the petsc source code, this call
actually seems to be superfluous, but nevermind)<br>
> • MatShellGetContext => get the pointer
ctxF_pt to point to the matrix context
<br>
> I'm getting an error message in the third step.<br>
> <br>
> [0]PETSC ERROR: --------------------- Error Message
--------------------------------------------------------------
<br>
> [0]PETSC ERROR: Null argument, when expecting valid
pointer <br>
> [0]PETSC ERROR: Null Pointer: Parameter # 2 <br>
> Again, thanks for your help!<br>
> Cheers,<br>
> Samuel<br>
> <br>
> On 12/11/2017 07:41 PM, Samuel Lanthaler wrote:<br>
>> Dear petsc-/slepc-users, <br>
>> <br>
>> I have been trying to understand
matrix-free/shell matrices in PETSc for eventual use in
solving a non-linear eigenvalue problem using SLEPC. But I
seem to be having trouble with calls to
MatShellGetContext. As far as I understand, this function
should initialize a pointer (second argument) so that the
subroutine output will point to the context associated
with my shell-matrix (let's say of TYPE(MatCtx))? When
calling that subroutine, I get the following error
message:
<br>
>> <br>
>> [0]PETSC ERROR: --------------------- Error
Message
--------------------------------------------------------------
<br>
>> [0]PETSC ERROR: Null argument, when expecting
valid pointer <br>
>> [0]PETSC ERROR: Null Pointer: Parameter # 2 <br>
>> <br>
>> In my code, the second input argument to the
routine is a null-pointer of TYPE(MatCtx),POINTER :: arg2.
Which the error message appears to be unhappy with. I
noticed that there is no error message if I instead pass
an object TYPE(MatCtx) :: arg2 to the routine... which
doesn't really make sense to me? Could someone maybe
explain to me what is going on, here?
<br>
>> <br>
>> Just in case, let me also attach my concrete
example code (it is supposed to be a Fortran version of
the slepc-example in
slepc-3.8.1/src/nep/examples/tutorials/ex21.c). I have
added an extra call to MatShellGetContext on line 138,
after the function and jacobian should supposedly have
been set up. <br>
>> <br>
>> Thanks a lot for your help! <br>
>> <br>
>> Cheers, <br>
>> <br>
>> Samuel <br>
>> <br>
> <br>
> <matshell.f90><br>
<br>
</div>
</span></font></div>
</blockquote>
<br>
</body>
</html>