<div dir="ltr">Thanks Barry. I have to pass three derived types. I now put my 3 types into another type and pass that as the application context.<div><br></div><div>Best</div><div>praveen</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 17, 2017 at 10:45 AM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
It looks to me that you are trying to pass a Fortran 90 derived type as one entry in an array of addresses as an application context (perhaps from some PETSc example). This will not work as written because Fortran doesn't know that PetscFortranAddr is an array of addresses.<br>
<br>
The conventional way to do this is to pass a derived type directly as the context. So you would just have<br>
<br>
type(mgrid) mygrid<br>
<br>
then when you call SNESSetComputeFunction() or whatever routine you are calling that requires a context<br>
<br>
SNESSetComputeFunction(snes,v,<wbr>computefunction,mygrid,ierr)<br>
<br>
and inside your computefunction the ctx argument is declared as type(grid) mygrid<br>
<br>
See, for example, src/snes/examples/tutorials/<wbr>ex5f90.F90<br>
<br>
<br>
Barry<br>
<br>
> type(mgrid)<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
> On Mar 17, 2017, at 12:02 AM, Praveen C <<a href="mailto:cpraveen@gmail.com">cpraveen@gmail.com</a>> wrote:<br>
><br>
> Dear all<br>
><br>
> I want to pass my own module as an application context in fortran. So I am trying something like this<br>
><br>
> type(mgrid),target :: g<br>
> PetscFortranAddr :: ctx(6)<br>
> ctx(1) => g<br>
><br>
> But this gives an error<br>
> Error: Non-POINTER in pointer association context (pointer assignment) at (1)<br>
><br>
> Could you tell me how I can make this work ?<br>
><br>
> Thanks<br>
> praveen<br>
<br>
</div></div></blockquote></div><br></div>