[petsc-users] MatShellGetContext in Fortran
Timothée Nicolas
timothee.nicolas at gmail.com
Wed Oct 7 13:19:33 CDT 2015
Hi all,
In the manual, it says, about MatShellSetContext and MatShellGetContext,
that in FORTRAN we cannot set a context other than integer or PetscObject.
http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreateShell.html#MatCreateShell
In my understanding, it means that I would be allowed to do, say
PetscInt :: ione
ione=1
call MatCreateShell(PETSC_COMM_WORLD,m,m,N,N,PETSC_NULL_INTEGER,A,ierr)
call MatShellSetContext(A,ione,ierr)
call MatShellSetOperation(A,MATOP_MULT,MyMult,ierr)
in the routine where I define the matrix A, and then recover the integer in
the routine MyMult with
PetscInt :: intval
call MatShellGetContext(A,intval,ierr)
This would allow me to circumvent the interdiction to pass a real context,
by e.g. using a module at the beginning of MyMult, containing contexts and
discriminating which context to use with the value of the integer (I want
to use Multigrid, so I cannot have a different routine for each level
obviously). However, this approach did not work, the value in intval stays
undefined. How could I solve this ?
Best
Timothee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20151007/acd63d9d/attachment.html>
More information about the petsc-users
mailing list