{ PetscObjectAllocateFortranPointers(*pc,9); ((PetscObject)*pc)->fortran_func_pointers[7] = (PetscVoidFunction)postsolve; *ierr = PCShellSetPostSolve(*pc,ourshellpostsolve); } PETSC_EXTERN void PETSC_STDCALL pcshellsetview_(PC *pc,void (PETSC_STDCALL *view)(void*,PetscViewer*,PetscErrorCode*),PetscErrorCode *ierr) { PetscObjectAllocateFortranPointers(*pc,9); ((PetscObject)*pc)->fortran_func_pointers[8] = (PetscVoidFunction)view; *ierr = PCShellSetView(*pc,ourshellview); } PETSC_EXTERN void PETSC_STDCALL pcshellsetname_(PC *pc,CHAR name PETSC_MIXED_LEN(len), PetscErrorCode *ierr PETSC_END_LEN(len)) { char *c; FIXCHAR(name,len,c); *ierr = PCShellSetName(*pc,c); FREECHAR(name,c); } PETSC_EXTERN void PETSC_STDCALL pcshellgetname_(PC *pc,CHAR name PETSC_MIXED_LEN(len), PetscErrorCode *ierr PETSC_END_LEN(len)) { const char *c; *ierr = PCShellGetName(*pc,&c);if (*ierr) return; *ierr = PetscStrncpy(name,c,len); }
#include <petsc/private/fortranimpl.h> #include <petscdraw.h> #if defined(PETSC_HAVE_FORTRAN_CAPS) #define petscdrawaxissetlabels_ PETSCDRAWAXISSETLABELS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) #define petscdrawaxissetlabels_ petscdrawaxissetlabels #endif PETSC_EXTERN void PETSC_STDCALL petscdrawaxissetlabels_(PetscDrawAxis *axis,CHAR top PETSC_MIXED_LEN(len1), CHAR xlabel PETSC_MIXED_LEN(len2),CHAR ylabel PETSC_MIXED_LEN(len3), PetscErrorCode *ierr PETSC_END_LEN(len1) PETSC_END_LEN(len2) PETSC_END_LEN(len3)) { char *t1,*t2,*t3; FIXCHAR(top,len1,t1); FIXCHAR(xlabel,len2,t2); FIXCHAR(ylabel,len3,t3); *ierr = PetscDrawAxisSetLabels(*axis,t1,t2,t3); FREECHAR(top,t1); FREECHAR(xlabel,t2); FREECHAR(ylabel,t3); }
#include <petsc-private/fortranimpl.h> #include <petscviewer.h> #if defined(PETSC_HAVE_FORTRAN_CAPS) #define petscviewerfilesetname_ PETSCVIEWERFILESETNAME #define petscviewerasciiprintf_ PETSCVIEWERASCIIPRINTF #define petscviewerasciisynchronizedprintf_ PETSCVIEWERASCIISYNCHRONIZEDPRINTF #define petscviewerasciisynchronizedallow_ PETSCVIEWERASCIISYNCHRONIZEALLOW #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) #define petscviewerfilesetname_ petscviewerfilesetname #define petscviewerasciiprintf_ petscviewerasciiprintf #define petscviewerasciisynchronizedprintf_ petscviewerasciisynchronizedprintf #define petscviewerasciisynchronizedallow_ petscviewerasciisynchronizedallow #endif PETSC_EXTERN void PETSC_STDCALL petscviewerfilesetname_(PetscViewer *viewer,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *c1; PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); FIXCHAR(name,len,c1); *ierr = PetscViewerFileSetName(v,c1); FREECHAR(name,c1); } #undef __FUNCT__ #define __FUNCT__ "PetscFixSlashN" static PetscErrorCode PetscFixSlashN(const char *in, char **out) { PetscErrorCode ierr; PetscInt i;
#include "private/fortranimpl.h" #include "petscpc.h" #if defined(PETSC_HAVE_FORTRAN_CAPS) #define pcsettype_ PCSETTYPE #define pcgettype_ PCGETTYPE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) #define pcsettype_ pcsettype #define pcgettype_ pcgettype #endif EXTERN_C_BEGIN void PETSC_STDCALL pcsettype_(PC *pc,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(type,len,t); *ierr = PCSetType(*pc,t); FREECHAR(type,t); } void PETSC_STDCALL pcgettype_(PC *pc,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { const char *tname; *ierr = PCGetType(*pc,&tname); *ierr = PetscStrncpy(name,tname,len);if (*ierr) return; FIXRETURNCHAR(PETSC_TRUE,name,len); }
Mat mat = (Mat) ctx; (*(void (PETSC_STDCALL *)(void*,Vec*,Vec*,PetscErrorCode*))(((PetscObject)mat)->fortran_func_pointers[0]))((void*)(PETSC_UINTPTR_T)((PetscObject)mat)->fortran_func_pointers[1],&x,&f,&ierr);CHKERRQ(ierr); return 0; } PETSC_EXTERN void PETSC_STDCALL matmffdsetfunction_(Mat *mat,void (PETSC_STDCALL *func)(void*,Vec*,Vec*,PetscErrorCode*),void *ctx,PetscErrorCode *ierr) { CHKFORTRANNULLOBJECT(ctx); PetscObjectAllocateFortranPointers(*mat,2); ((PetscObject)*mat)->fortran_func_pointers[0] = (PetscVoidFunction)func; ((PetscObject)*mat)->fortran_func_pointers[1] = (PetscVoidFunction)(PETSC_UINTPTR_T)ctx; *ierr = MatMFFDSetFunction(*mat,ourmatmffdfunction,*mat); } PETSC_EXTERN void PETSC_STDCALL matmffdsettype_(Mat *mat,CHAR ftype PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(ftype,len,t); *ierr = MatMFFDSetType(*mat,t); FREECHAR(ftype,t); } PETSC_EXTERN void PETSC_STDCALL matmffdsetoptionsprefix_(Mat *mat,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(prefix,len,t); *ierr = MatMFFDSetOptionsPrefix(*mat,t); FREECHAR(prefix,t); }
PetscErrorCode ierr = 0; (*(void (PETSC_STDCALL *)(SNESLineSearch*,Vec*, Vec*, PetscBool*,void*,PetscErrorCode*))(((PetscObject)linesearch)->fortran_func_pointers[1]))(&linesearch,&X,&Y,changed,ctx,&ierr);CHKERRQ(ierr); return 0; } static PetscErrorCode oursneslinesearchpostcheck(SNESLineSearch linesearch, Vec X, Vec Y, Vec W, PetscBool * changed_Y, PetscBool * changed_W, void * ctx) { PetscErrorCode ierr = 0; (*(void (PETSC_STDCALL *)(SNESLineSearch*,Vec*,Vec*,Vec*,PetscBool*,PetscBool*,void*,PetscErrorCode*)) (((PetscObject)linesearch)->fortran_func_pointers[2]))(&linesearch,&X,&Y,&W,changed_Y,changed_W,ctx,&ierr);CHKERRQ(ierr); return 0; } EXTERN_C_BEGIN void PETSC_STDCALL sneslinesearchsettype_(SNESLineSearch *linesearch,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(type,len,t); *ierr = SNESLineSearchSetType(*linesearch,t); FREECHAR(type,t); } void PETSC_STDCALL sneslinesearchsetprecheck_(SNESLineSearch *linesearch, void (PETSC_STDCALL *func)(SNESLineSearch*,Vec*,Vec*,PetscBool*,PetscErrorCode*), void *ctx, PetscErrorCode *ierr) { PetscObjectAllocateFortranPointers(*linesearch,3);
#include <petsc-private/fortranimpl.h> #include <petscts.h> #if defined(PETSC_HAVE_FORTRAN_CAPS) #define tssettype_ TSSETTYPE #define tsgettype_ TSGETTYPE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) #define tssettype_ tssettype #define tsgettype_ tsgettype #endif PETSC_EXTERN void PETSC_STDCALL tssettype_(TS *ts,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(type,len,t); *ierr = TSSetType(*ts,t); FREECHAR(type,t); } PETSC_EXTERN void PETSC_STDCALL tsgettype_(TS *ts,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { const char *tname; *ierr = TSGetType(*ts,&tname); *ierr = PetscStrncpy(name,tname,len); FIXRETURNCHAR(PETSC_TRUE,name,len); }
#include <petsc-private/fortranimpl.h> #if defined(PETSC_HAVE_FORTRAN_CAPS) #define petscobjecttypecompare_ PETSCOBJECTTYPECOMPARE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) #define petscobjecttypecompare_ petscobjecttypecompare #endif PETSC_EXTERN void PETSC_STDCALL petscobjecttypecompare_(PetscObject *obj,CHAR type_name PETSC_MIXED_LEN(len), PetscBool *same,PetscErrorCode *ierr PETSC_END_LEN(len)) { char *c1; FIXCHAR(type_name,len,c1); *ierr = PetscObjectTypeCompare(*obj,c1,same); FREECHAR(type_name,c1); }
PETSC_EXTERN void PETSC_STDCALL pcview_(PC *pc,PetscViewer *viewer, PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = PCView(*pc,v); } PETSC_EXTERN void PETSC_STDCALL pcgetoperators_(PC *pc,Mat *mat,Mat *pmat,MatStructure *flag,PetscErrorCode *ierr) { CHKFORTRANNULLOBJECT(mat); CHKFORTRANNULLOBJECT(pmat); CHKFORTRANNULLINTEGER(flag); *ierr = PCGetOperators(*pc,mat,pmat,flag); } PETSC_EXTERN void PETSC_STDCALL pcsetoptionsprefix_(PC *pc,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(prefix,len,t); *ierr = PCSetOptionsPrefix(*pc,t); FREECHAR(prefix,t); } PETSC_EXTERN void PETSC_STDCALL pcappendoptionsprefix_(PC *pc,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(prefix,len,t); *ierr = PCAppendOptionsPrefix(*pc,t); FREECHAR(prefix,t);
#define stgetoptionsprefix_ STGETOPTIONSPREFIX #define stview_ STVIEW #define stgetmatmode_ STGETMATMODE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) #define stsettype_ stsettype #define stgettype_ stgettype #define stcreate_ stcreate #define stdestroy_ stdestroy #define stsetoptionsprefix_ stsetoptionsprefix #define stappendoptionsprefix_ stappendoptionsprefix #define stgetoptionsprefix_ stgetoptionsprefix #define stview_ stview #define stgetmatmode_ stgetmatmode #endif PETSC_EXTERN void PETSC_STDCALL stsettype_(ST *st,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(type,len,t); *ierr = STSetType(*st,t); FREECHAR(type,t); } PETSC_EXTERN void PETSC_STDCALL stgettype_(ST *st,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { STType tname; *ierr = STGetType(*st,&tname); if (*ierr) return; *ierr = PetscStrncpy(name,tname,len); FIXRETURNCHAR(PETSC_TRUE,name,len);
#include <petsc-private/fortranimpl.h> #include <petscts.h> #if defined(PETSC_HAVE_FORTRAN_CAPS) #define tspythonsettype_ TSPYTHONSETTYPE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) #define tspythonsettype_ tspythonsettype #endif EXTERN_C_BEGIN void PETSC_STDCALL tspythonsettype_(TS *ts, CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len) ) { char *t; FIXCHAR(name,len,t); *ierr = TSPythonSetType(*ts,t); FREECHAR(name,t); } EXTERN_C_END
#define petscoptionsgetreal_ petscoptionsgetreal #define petscoptionsgetrealarray_ petscoptionsgetrealarray #define petscoptionsgetstring_ petscoptionsgetstring #define petscoptionsgetintarray_ petscoptionsgetintarray #define petscgetprogramname_ petscgetprogramname #define petscoptionsinsertfile_ petscoptionsinsertfile #define petscoptionsclear_ petscoptionsclear #define petscoptionsinsertstring_ petscoptionsinsertstring #define petscoptionsview_ petscoptionsview #endif EXTERN_C_BEGIN /* ---------------------------------------------------------------------*/ void PETSC_STDCALL petscoptionsinsertstring_(CHAR file PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *c1; FIXCHAR(file,len,c1); *ierr = PetscOptionsInsertString(c1); FREECHAR(file,c1); } void PETSC_STDCALL petscoptionsinsertfile_(MPI_Fint *comm,CHAR file PETSC_MIXED_LEN(len),PetscBool *require,PetscErrorCode *ierr PETSC_END_LEN(len)) { char *c1; FIXCHAR(file,len,c1); *ierr = PetscOptionsInsertFile(MPI_Comm_f2c(*comm),c1,*require); FREECHAR(file,c1);
#include <petsc/private/fortranimpl.h> #if defined(PETSC_HAVE_FORTRAN_CAPS) #define petscobjectsetoptionsprefix PETSCOBJECTSETOPTIONSPREFIX #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) #define petscobjectsetoptionsprefix_ petscobjectsetoptionsprefix #endif PETSC_EXTERN void PETSC_STDCALL petscobjectsetoptionsprefix_(PetscObject *obj,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(prefix,len,t); *ierr = PetscObjectSetOptionsPrefix(*obj,t); FREECHAR(prefix,t); } PETSC_EXTERN void PETSC_STDCALL petscoptionsprefixpush_(PetscOptions options,CHAR prefix PETSC_MIXED_LEN(len), int *ierr PETSC_END_LEN(len)) { CHKFORTRANNULLOBJECTDEREFERENCE(options); *ierr = PetscOptionsPrefixPush(options,prefix); } PETSC_EXTERN void PETSC_STDCALL petscoptionsprefixpop_(PetscOptions options,int *ierr ) { CHKFORTRANNULLOBJECTDEREFERENCE(options); *ierr = PetscOptionsPrefixPop(options); }
void PETSC_STDCALL taosetconstraintsroutine_(Tao *tao, Vec *C, void (PETSC_STDCALL *func)(Tao*, Vec *, Vec *, void *, PetscErrorCode *), void *ctx, PetscErrorCode *ierr) { CHKFORTRANNULLOBJECT(ctx); PetscObjectAllocateFortranPointers(*tao,NFUNCS); if (!func) { *ierr = TaoSetConstraintsRoutine(*tao,*C,0,ctx); } else { ((PetscObject)*tao)->fortran_func_pointers[CONSTRAINTS] = (PetscVoidFunction)func; *ierr = TaoSetConstraintsRoutine(*tao, *C, ourtaoconstraintsroutine,ctx); } } void PETSC_STDCALL taosettype_(Tao *tao, CHAR type_name PETSC_MIXED_LEN(len), PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(type_name,len,t); *ierr = TaoSetType(*tao,t); FREECHAR(type_name,t); } void PETSC_STDCALL taoview_(Tao *tao, PetscViewer *viewer, PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = TaoView(*tao,v);
#include <petsc-private/fortranimpl.h> #if defined(PETSC_HAVE_FORTRAN_CAPS) #define petscviewerhdf5open_ PETSCVIEWERHDF5OPEN #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) #define petscviewerhdf5open_ petscviewerhdf5open #endif EXTERN_C_BEGIN void PETSC_STDCALL petscviewerhdf5open_(MPI_Comm *comm,CHAR name PETSC_MIXED_LEN(len),PetscFileMode *type, PetscViewer *binv,PetscErrorCode *ierr PETSC_END_LEN(len)) { char *c1; FIXCHAR(name,len,c1); *ierr = PetscViewerHDF5Open(MPI_Comm_f2c(*(MPI_Fint *)&*comm),c1,*type,binv); FREECHAR(name,c1); } EXTERN_C_END
static PetscErrorCode PetscFixSlashN(const char *in, char **out) { PetscErrorCode ierr; PetscInt i; size_t len; PetscFunctionBegin; ierr = PetscStrallocpy(in,out);CHKERRQ(ierr); ierr = PetscStrlen(*out,&len);CHKERRQ(ierr); for (i=0; i<(int)len-1; i++) { if ((*out)[i] == '\\' && (*out)[i+1] == 'n') {(*out)[i] = ' '; (*out)[i+1] = '\n';} } PetscFunctionReturn(0); } PETSC_EXTERN void PETSC_STDCALL petscfprintf_(MPI_Comm *comm,FILE **file,CHAR fname PETSC_MIXED_LEN(len1),PetscErrorCode *ierr PETSC_END_LEN(len1)) { char *c1,*tmp; FIXCHAR(fname,len1,c1); *ierr = PetscFixSlashN(c1,&tmp);if (*ierr) return; FREECHAR(fname,c1); *ierr = PetscFPrintf(MPI_Comm_f2c(*(MPI_Fint*)&*comm),*file,tmp);if (*ierr) return; *ierr = PetscFree(tmp); } PETSC_EXTERN void PETSC_STDCALL petscprintf_(MPI_Comm *comm,CHAR fname PETSC_MIXED_LEN(len1),PetscErrorCode *ierr PETSC_END_LEN(len1)) { char *c1,*tmp; FIXCHAR(fname,len1,c1);
#include <petsc/private/fortranimpl.h> #include <petscpc.h> #if defined(PETSC_HAVE_FORTRAN_CAPS) #define pccompositeaddpc_ PCCOMPOSITEADDPC #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) #define pccompositeaddpc_ pccompositeaddpc #endif PETSC_EXTERN void PETSC_STDCALL pccompositeaddpc_(PC *pc,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(type,len,t); *ierr = PCCompositeAddPC(*pc,t); FREECHAR(type,t); }
} } PETSC_EXTERN void PETSC_STDCALL taolinesearchsetobjectiveandgtsroutine_(TaoLineSearch *ls, void (PETSC_STDCALL *func)(TaoLineSearch*, Vec *, Vec *, PetscReal*, PetscReal*,void*, PetscErrorCode *), void *ctx, PetscErrorCode *ierr) { CHKFORTRANNULLOBJECT(ctx); PetscObjectAllocateFortranPointers(*ls,NFUNCS); if (!func) { *ierr = TaoLineSearchSetObjectiveAndGTSRoutine(*ls,0,ctx); } else { ((PetscObject)*ls)->fortran_func_pointers[OBJGTS] = (PetscVoidFunction)func; *ierr = TaoLineSearchSetObjectiveAndGTSRoutine(*ls, ourtaolinesearchobjectiveandgtsroutine,ctx); } } PETSC_EXTERN void PETSC_STDCALL taolinesearchsettype_(TaoLineSearch *ls, CHAR type_name PETSC_MIXED_LEN(len), PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(type_name,len,t); *ierr = TaoLineSearchSetType(*ls,t); FREECHAR(type_name,t); } PETSC_EXTERN void PETSC_STDCALL taolinesearchview_(TaoLineSearch *ls, PetscViewer *viewer, PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = TaoLineSearchView(*ls,v);
/* -----------------------------------------------------------------------------------------------*/ #if defined(PETSC_HAVE_SAWS) #include <petscviewersaws.h> extern PetscErrorCode PetscInitializeSAWs(const char[]); #endif /* petscinitialize - Version called from Fortran. Notes: Since this is called from Fortran it does not return error codes */ PETSC_EXTERN void PETSC_STDCALL petscinitialize_(CHAR filename PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { #if defined (PETSC_USE_NARGS) short flg,i; #else int i; #if !defined(PETSC_HAVE_PXFGETARG_NEW) && !defined (PETSC_HAVE_PXFGETARG_NEW) && !defined(PETSC_HAVE_FORTRAN_GET_COMMAND_ARGUMENT) int j; #endif #endif #if defined(PETSC_HAVE_CUDA) PetscBool flg2; cublasStatus_t cberr; #endif int flag; PetscMPIInt size;
#include <petsc/private/fortranimpl.h> #include <petscksp.h> #if defined(PETSC_HAVE_FORTRAN_CAPS) #define ksppythonsettype_ KSPPYTHONSETTYPE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) #define ksppythonsettype_ ksppythonsettype #endif PETSC_EXTERN void PETSC_STDCALL ksppythonsettype_(KSP *ksp, CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(name,len,t); *ierr = KSPPythonSetType(*ksp,t); FREECHAR(name,t); }
#define petsclogallbegin_ petsclogallbegin #define petsclogdestroy_ petsclogdestroy #define petsclogbegin_ petsclogbegin #define petsclogeventregister_ petsclogeventregister #define petsclogdump_ petsclogdump #define petsclogstagepop_ petsclogstagepop #define petsclogstageregister_ petsclogstageregister #define petsccookieregister_ petsccookieregister #define petsclogstagepush_ petsclogstagepush #define petscgetflops_ petscgetflops #define petsclogstagegetid_ petsclogstagegetid #endif EXTERN_C_BEGIN void PETSC_STDCALL petsclogprintsummary_(MPI_Comm *comm,CHAR filename PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { #if defined(PETSC_USE_LOG) char *t; FIXCHAR(filename,len,t); *ierr = PetscLogPrintSummary(MPI_Comm_f2c(*(MPI_Fint *)&*comm),t); FREECHAR(filename,t); #endif } void PETSC_STDCALL petsclogprintDetailed_(MPI_Comm *comm,CHAR filename PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { #if defined(PETSC_USE_LOG) char *t; FIXCHAR(filename,len,t); *ierr = PetscLogPrintDetailed(MPI_Comm_f2c(*(MPI_Fint *)&*comm),t);
#include <petsc-private/fortranimpl.h> #include <petscpc.h> #if defined(PETSC_HAVE_FORTRAN_CAPS) #define pchypresettype_ PCHYPRESETTYPE #define pchypregettype_ PCHYPREGETTYPE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) #define pchypresettype_ pchypresettype #define pchypregettype_ pchypregettype #endif PETSC_EXTERN void PETSC_STDCALL pchypresettype_(PC *pc, CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(name,len,t); *ierr = PCHYPRESetType(*pc,t); FREECHAR(name,t); } PETSC_EXTERN void PETSC_STDCALL pchypregettype_(PC *pc,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { const char *tname; *ierr = PCHYPREGetType(*pc,&tname); *ierr = PetscStrncpy(name,tname,len);if (*ierr) return; FIXRETURNCHAR(PETSC_TRUE,name,len); }
*ierr = MatDenseGetArray(*mat,&mm); if (*ierr) return; *ierr = MatGetSize(*mat,&m,&n); if (*ierr) return; *ierr = PetscScalarAddressToFortran((PetscObject)*mat,1,fa,mm,m*n,ia); if (*ierr) return; } PETSC_EXTERN void PETSC_STDCALL matdenserestorearray_(Mat *mat,PetscScalar *fa,size_t *ia,PetscErrorCode *ierr) { PetscScalar *lx; PetscInt m,n; *ierr = MatGetSize(*mat,&m,&n); if (*ierr) return; *ierr = PetscScalarAddressFromFortran((PetscObject)*mat,fa,*ia,m*n,&lx);if (*ierr) return; *ierr = MatDenseRestoreArray(*mat,&lx);if (*ierr) return; } PETSC_EXTERN void PETSC_STDCALL matfactorgetsolverpackage_(Mat *mat,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { const char *tname; *ierr = MatFactorGetSolverPackage(*mat,&tname);if (*ierr) return; if (name != PETSC_NULL_CHARACTER_Fortran) { *ierr = PetscStrncpy(name,tname,len);if (*ierr) return; } FIXRETURNCHAR(PETSC_TRUE,name,len); } PETSC_EXTERN void PETSC_STDCALL matgetfactor_(Mat *mat,CHAR outtype PETSC_MIXED_LEN(len),MatFactorType *ftype,Mat *M,PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(outtype,len,t); *ierr = MatGetFactor(*mat,t,*ftype,M);
#include <petsc/private/fortranimpl.h> #if defined(PETSC_HAVE_FORTRAN_CAPS) #define petscpythoninitialize_ PETSCPYTHONINITIALIZE #define petscpythonfinalize_ PETSCPYTHONFINALIZE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) #define petscpythoninitialize_ petscpythoninitialize #define petscpythonfinalize_ petscpythonfinalize #endif PETSC_EXTERN void PETSC_STDCALL petscpythoninitialize_(CHAR n1 PETSC_MIXED_LEN(l1),CHAR n2 PETSC_MIXED_LEN(l2), PetscErrorCode *ierr PETSC_END_LEN(l1) PETSC_END_LEN(l2)) { char *t1,*t2; FIXCHAR(n1,l1,t1); FIXCHAR(n2,l2,t2); *ierr = PetscPythonInitialize(t1,t2);if (*ierr) return; FREECHAR(n1,t1); FREECHAR(n2,t2); } PETSC_EXTERN void PETSC_STDCALL petscpythonfinalize_(PetscErrorCode *ierr) { *ierr = PetscPythonFinalize(); }
PETSC_EXTERN void PETSC_STDCALL petsclogeventbegin_(PetscLogEvent *e,PetscErrorCode *ierr) { *ierr = PetscLogEventBegin(*e,0,0,0,0); } PETSC_EXTERN void PETSC_STDCALL petsclogeventend_(PetscLogEvent *e,PetscErrorCode *ierr) { *ierr = PetscLogEventEnd(*e,0,0,0,0); } PETSC_EXTERN void PETSC_STDCALL petsclogflops_(PetscLogDouble *f,PetscErrorCode *ierr) { *ierr = PetscLogFlops(*f); } PETSC_EXTERN void PETSC_STDCALL petsclogview_(PetscViewer *viewer,PetscErrorCode *ierr PETSC_END_LEN(len)) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = PetscLogView(v); } PETSC_EXTERN void PETSC_STDCALL petsclogprintDetailed_(MPI_Comm *comm,CHAR filename PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { #if defined(PETSC_USE_LOG) char *t; FIXCHAR(filename,len,t); *ierr = PetscLogPrintDetailed(MPI_Comm_f2c(*(MPI_Fint*)&*comm),t); FREECHAR(filename,t); #endif }
#include "private/fortranimpl.h" #include "petscpc.h" #if defined(PETSC_HAVE_FORTRAN_CAPS) #define pcfactorsetmatorderingtype_ PCFACTORSETMATORDERINGTYPE #define pcfactorsetmatsolverpackage_ PCFACTORSETMATSOLVERPACKAGE #define pcfactorgetmatsolverpackage_ PCFACTORGETMATSOLVERPACKAGE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) #define pcfactorsetmatorderingtype_ pcfactorsetmatorderingtype #define pcfactorsetmatsolverpackage_ pcfactorsetmatsolverpackage #define pcfactorgetmatsolverpackage_ pcfactorgetmatsolverpackage #endif EXTERN_C_BEGIN void PETSC_STDCALL pcfactorsetmatorderingtype_(PC *pc,CHAR ordering PETSC_MIXED_LEN(len), PetscErrorCode *ierr PETSC_END_LEN(len)){ char *t; FIXCHAR(ordering,len,t); *ierr = PCFactorSetMatOrderingType(*pc,t); FREECHAR(ordering,t); } void PETSC_STDCALL pcfactorsetmatsolverpackage_(PC *pc,CHAR ordering PETSC_MIXED_LEN(len), PetscErrorCode *ierr PETSC_END_LEN(len)){ char *t; FIXCHAR(ordering,len,t); *ierr = PCFactorSetMatSolverPackage(*pc,t); FREECHAR(ordering,t); } void PETSC_STDCALL pcfactorgetmatsolverpackage_(PC *mat,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) {
#include "private/fortranimpl.h" #include "petscda.h" #if defined(PETSC_HAVE_FORTRAN_CAPS) #define dasetfieldname_ DASETFIELDNAME #define dagetfieldname_ DAGETFIELDNAME #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) #define dasetfieldname_ dasetfieldname #define dagetfieldname_ dagetfieldname #endif EXTERN_C_BEGIN void PETSC_STDCALL dasetfieldname_(DA *da,PetscInt *nf,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(name,len,t); *ierr = DASetFieldName(*da,*nf,t); FREECHAR(name,t); } void PETSC_STDCALL dagetfieldname_(DA *da,PetscInt *nf,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *tname; *ierr = DAGetFieldName(*da,*nf,&tname); *ierr = PetscStrncpy(name,tname,len); } EXTERN_C_END
#include "private/fortranimpl.h" #include "petscsnes.h" #if defined(PETSC_HAVE_FORTRAN_CAPS) #define snespythonsettype_ SNESPYTHONSETTYPE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) #define snespythonsettype_ snespythonsettype #endif EXTERN_C_BEGIN void PETSC_STDCALL snespythonsettype_(SNES *snes, CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len) ) { char *t; FIXCHAR(name,len,t); *ierr = SNESPythonSetType(*snes,t); FREECHAR(name,t); } EXTERN_C_END
#endif EXTERN_C_BEGIN void PETSC_STDCALL matpartitioningsetvertexweights_(MatPartitioning *part,const PetscInt weights[],PetscErrorCode *ierr) { PetscInt len; PetscInt *array; *ierr = MatGetLocalSize((*part)->adj,&len,0); if (*ierr) return; *ierr = PetscMalloc(len*sizeof(PetscInt),&array); if (*ierr) return; *ierr = PetscMemcpy(array,weights,len*sizeof(PetscInt));if (*ierr) return; *ierr = MatPartitioningSetVertexWeights(*part,array); } void PETSC_STDCALL matpartitioningview_(MatPartitioning *part,PetscViewer *viewer, PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = MatPartitioningView(*part,v); } void PETSC_STDCALL matpartitioningsettype_(MatPartitioning *part,CHAR type PETSC_MIXED_LEN(len), PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(type,len,t); *ierr = MatPartitioningSetType(*part,t); FREECHAR(type,t); } EXTERN_C_END
#include <petsc-private/fortranimpl.h> #if defined(PETSC_HAVE_FORTRAN_CAPS) #define petscgethostname_ PETSCGETHOSTNAME #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) #define petscgethostname_ petscgethostname #endif EXTERN_C_BEGIN void PETSC_STDCALL petscgethostname_(CHAR str PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *tstr; size_t tlen; tstr = str; tlen = len; /* int to size_t */ *ierr = PetscGetHostName(tstr,tlen); FIXRETURNCHAR(PETSC_TRUE,str,len); } EXTERN_C_END