<div dir="ltr"><div><div><div><div><div><div><div><div><div><div>Hi all,<br><br></div>In the manual, it says, about MatShellSetContext and MatShellGetContext, that in FORTRAN we cannot set a context other than integer or PetscObject. <br></div><br><a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreateShell.html#MatCreateShell">http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreateShell.html#MatCreateShell</a><br><br></div>In my understanding, it means that I would be allowed to do, say<br><br></div><div>PetscInt :: ione<br></div><div>ione=1<br></div><div>call MatCreateShell(PETSC_COMM_WORLD,m,m,N,N,PETSC_NULL_INTEGER,A,ierr)<br></div>call MatShellSetContext(A,ione,ierr)<br></div><div>call MatShellSetOperation(A,MATOP_MULT,MyMult,ierr)<br></div><div><br></div>in the routine where I define the matrix A, and then recover the integer in the routine MyMult with<br><br></div>PetscInt :: intval<br></div>call MatShellGetContext(A,intval,ierr)<br><br></div>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 ?<br><br></div>Best<br><br></div>Timothee<br></div>