[petsc-dev] new Fortran function pointer stuff broken

Jed Brown jedbrown at mcs.anl.gov
Wed Feb 6 22:38:55 CST 2013


On Wed, Feb 6, 2013 at 10:16 PM, Jed Brown <jedbrown at mcs.anl.gov> wrote:

> This looks like my fault, I'll fix it.
>

https://bitbucket.org/petsc/petsc-dev/commits/f09b18c4bdd1452a92164146b0553a632a152397


>
>
> On Wed, Feb 6, 2013 at 10:02 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
>
>>
>> For example
>>
>> static PetscErrorCode oursnesfunction(SNES snes,Vec x,Vec f,void *ctx)
>> {
>>
>> PetscObjectUseFortranCallback(snes,_cb.function,(SNES*,Vec*,Vec*,void*,PetscErrorCode*),(&snes,&x,&f,_ctx,&ierr));
>>   return 0;
>> }
>>
>> with
>>
>> #define PetscObjectAllocateFortranPointers(obj,N) do {                  \
>>     if (!((PetscObject)(obj))->fortran_func_pointers) {                 \
>>       *ierr =
>> PetscMalloc((N)*sizeof(void(*)(void)),&((PetscObject)(obj))->fortran_func_pointers);if
>> (*ierr) return; \
>>       *ierr =
>> PetscMemzero(((PetscObject)(obj))->fortran_func_pointers,(N)*sizeof(void(*)(void)));if
>> (*ierr) return; \
>>       ((PetscObject)obj)->num_fortran_func_pointers = (N);              \
>>     }                                                                   \
>>   } while (0)
>>
>> /* Entire function body, _ctx is a "special" variable that can be passed
>> along */
>> #define PetscObjectUseFortranCallback_Private(obj,cid,types,args,cbclass)
>> { \
>>     PetscErrorCode ierr;                                                \
>>     void (PETSC_STDCALL *func) types,*_ctx;                             \
>>     PetscFunctionBegin;                                                 \
>>     ierr =
>> PetscObjectGetFortranCallback((PetscObject)(obj),(cbclass),(cid),(PetscVoidFunction*)&func,&_ctx);CHKERRQ(ierr);
>> \
>>     (*func)args;CHKERRQ(ierr);                                          \
>>     PetscFunctionReturn(0);                                             \
>>   }
>> #define PetscObjectUseFortranCallback(obj,cid,types,args)
>> PetscObjectUseFortranCallback_Private(obj,cid,types,args,PETSC_FORTRAN_CALLBACK_CLASS)
>> #define PetscObjectUseFortranCallbackSubType(obj,cid,types,args)
>> PetscObjectUseFortranCallback_Private(obj,cid,types,args,PETSC_FORTRAN_CALLBACK_SUBTYPE)
>>
>> But any function with PetscFunctionBegin/Return needs to have
>>
>> #undef __FUNCT__
>> #define __FUNCT__
>>
>> so most of the fortran stubs are broken with error messages about wrong
>> function names.
>>
>> Does anyone test before they push anymore :-)?
>>
>>   Barry
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20130206/ec9e7003/attachment.html>


More information about the petsc-dev mailing list