[petsc-users] Fortran application context, passing a module
    Barry Smith 
    bsmith at mcs.anl.gov
       
    Fri Mar 17 00:15:50 CDT 2017
    
    
  
  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. 
  The conventional way to do this is to pass a derived type directly as the context. So you would just have
   type(mgrid) mygrid
    then when you call SNESSetComputeFunction() or whatever routine you are calling that requires a context
    SNESSetComputeFunction(snes,v,computefunction,mygrid,ierr)
    and inside your computefunction the ctx argument is declared as type(grid) mygrid
    See, for example, src/snes/examples/tutorials/ex5f90.F90
  Barry
> type(mgrid)
   
> On Mar 17, 2017, at 12:02 AM, Praveen C <cpraveen at gmail.com> wrote:
> 
> Dear all
> 
> I want to pass my own module as an application context in fortran. So I am trying something like this
> 
> type(mgrid),target :: g
> PetscFortranAddr :: ctx(6)
> ctx(1) => g
> 
> But this gives an error
> Error: Non-POINTER in pointer association context (pointer assignment) at (1)
> 
> Could you tell me how I can make this work ?
> 
> Thanks
> praveen
    
    
More information about the petsc-users
mailing list