<div dir="ltr">This looks like my fault, I'll fix it.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Feb 6, 2013 at 10:02 PM, 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>
For example<br>
<br>
static PetscErrorCode oursnesfunction(SNES snes,Vec x,Vec f,void *ctx)<br>
{<br>
PetscObjectUseFortranCallback(snes,_cb.function,(SNES*,Vec*,Vec*,void*,PetscErrorCode*),(&snes,&x,&f,_ctx,&ierr));<br>
return 0;<br>
}<br>
<br>
with<br>
<br>
#define PetscObjectAllocateFortranPointers(obj,N) do { \<br>
if (!((PetscObject)(obj))->fortran_func_pointers) { \<br>
*ierr = PetscMalloc((N)*sizeof(void(*)(void)),&((PetscObject)(obj))->fortran_func_pointers);if (*ierr) return; \<br>
*ierr = PetscMemzero(((PetscObject)(obj))->fortran_func_pointers,(N)*sizeof(void(*)(void)));if (*ierr) return; \<br>
((PetscObject)obj)->num_fortran_func_pointers = (N); \<br>
} \<br>
} while (0)<br>
<br>
/* Entire function body, _ctx is a "special" variable that can be passed along */<br>
#define PetscObjectUseFortranCallback_Private(obj,cid,types,args,cbclass) { \<br>
PetscErrorCode ierr; \<br>
void (PETSC_STDCALL *func) types,*_ctx; \<br>
PetscFunctionBegin; \<br>
ierr = PetscObjectGetFortranCallback((PetscObject)(obj),(cbclass),(cid),(PetscVoidFunction*)&func,&_ctx);CHKERRQ(ierr); \<br>
(*func)args;CHKERRQ(ierr); \<br>
PetscFunctionReturn(0); \<br>
}<br>
#define PetscObjectUseFortranCallback(obj,cid,types,args) PetscObjectUseFortranCallback_Private(obj,cid,types,args,PETSC_FORTRAN_CALLBACK_CLASS)<br>
#define PetscObjectUseFortranCallbackSubType(obj,cid,types,args) PetscObjectUseFortranCallback_Private(obj,cid,types,args,PETSC_FORTRAN_CALLBACK_SUBTYPE)<br>
<br>
But any function with PetscFunctionBegin/Return needs to have<br>
<br>
#undef __FUNCT__<br>
#define __FUNCT__<br>
<br>
so most of the fortran stubs are broken with error messages about wrong function names.<br>
<br>
Does anyone test before they push anymore :-)?<br>
<span class="HOEnZb"><font color="#888888"><br>
Barry<br>
<br>
</font></span></blockquote></div><br></div>