PETSC_EXTERN void PETSC_STDCALL matcreatebaij_(MPI_Comm *comm,PetscInt *bs,PetscInt *m,PetscInt *n,PetscInt *M,PetscInt *N, PetscInt *d_nz,PetscInt *d_nnz,PetscInt *o_nz,PetscInt *o_nnz,Mat *newmat,PetscErrorCode *ierr) { CHKFORTRANNULLINTEGER(d_nnz); CHKFORTRANNULLINTEGER(o_nnz); *ierr = MatCreateBAIJ(MPI_Comm_f2c(*(MPI_Fint*)&*comm),*bs,*m,*n,*M,*N,*d_nz,d_nnz,*o_nz,o_nnz,newmat); }
PETSC_EXTERN void PETSC_STDCALL matnestgetsubmats_(Mat *A,PetscInt *M,PetscInt *N,Mat *sub,int *ierr) { PetscInt i,j,m,n; Mat **mat; CHKFORTRANNULLINTEGER(M); CHKFORTRANNULLINTEGER(N); CHKFORTRANNULLOBJECT(sub); *ierr = MatNestGetSubMats(*A,&m,&n,&mat); if (M) { *M = m; } if (N) { *N = n; } if (sub) { for (i=0; i<m; i++) { for (j=0; j<n; j++) { sub[j + n * i] = mat[i][j]; } } } }
PETSC_EXTERN void PETSC_STDCALL aocreatemapping_(MPI_Comm *comm,PetscInt *napp,PetscInt *myapp,PetscInt *mypetsc,AO *aoout,PetscErrorCode *ierr) { if (*napp) { CHKFORTRANNULLINTEGER(myapp); CHKFORTRANNULLINTEGER(mypetsc); } *ierr = AOCreateMapping(MPI_Comm_f2c(*(MPI_Fint*)comm),*napp,myapp,mypetsc,aoout); }
void PETSC_STDCALL dacreate2d_(MPI_Comm *comm,DAPeriodicType *wrap,DAStencilType *stencil_type,PetscInt *M,PetscInt *N,PetscInt *m,PetscInt *n,PetscInt *w, PetscInt *s,PetscInt *lx,PetscInt *ly,DA *inra,PetscErrorCode *ierr) { CHKFORTRANNULLINTEGER(lx); CHKFORTRANNULLINTEGER(ly); *ierr = DACreate2d(MPI_Comm_f2c(*(MPI_Fint *)&*comm),*wrap,*stencil_type,*M,*N,*m,*n,*w,*s,lx,ly,inra); }
PETSC_EXTERN void PETSC_STDCALL dmdacreate2d_(MPI_Comm *comm,DMBoundaryType *bx,DMBoundaryType *by,DMDAStencilType *stencil_type,PetscInt *M,PetscInt *N,PetscInt *m,PetscInt *n,PetscInt *w, PetscInt *s,PetscInt *lx,PetscInt *ly,DM *inra,PetscErrorCode *ierr) { CHKFORTRANNULLINTEGER(lx); CHKFORTRANNULLINTEGER(ly); *ierr = DMDACreate2d(MPI_Comm_f2c(*(MPI_Fint*)&*comm),*bx,*by,*stencil_type,*M,*N,*m,*n,*w,*s,lx,ly,inra); }
PETSC_EXTERN void PETSC_STDCALL dmdagetghostcorners_(DM *da,PetscInt *x,PetscInt *y,PetscInt *z,PetscInt *m,PetscInt *n,PetscInt *p, int *ierr ) { CHKFORTRANNULLINTEGER(y); CHKFORTRANNULLINTEGER(z); CHKFORTRANNULLINTEGER(n); CHKFORTRANNULLINTEGER(p); *ierr = DMDAGetGhostCorners(*da,x,y,z,m,n,p); }
PETSC_EXTERN void PETSC_STDCALL pcasmgetsubksp_(PC *pc,PetscInt *n_local,PetscInt *first_local,KSP *ksp,PetscErrorCode *ierr) { KSP *tksp; PetscInt i,nloc; CHKFORTRANNULLINTEGER(n_local); CHKFORTRANNULLINTEGER(first_local); CHKFORTRANNULLOBJECT(ksp); *ierr = PCASMGetSubKSP(*pc,&nloc,first_local,&tksp); if (n_local) *n_local = nloc; if (ksp) { for (i=0; i<nloc; i++) ksp[i] = tksp[i]; } }
void PETSC_STDCALL dagetownershipranges_(DA *da,PetscInt lx[],PetscInt ly[],PetscInt lz[],PetscErrorCode *ierr) { const PetscInt *gx,*gy,*gz; PetscInt M,N,P,i; CHKFORTRANNULLINTEGER(lx); CHKFORTRANNULLINTEGER(ly); CHKFORTRANNULLINTEGER(lz); *ierr = DAGetInfo(*da,0,0,0,0,&M,&N,&P,0,0,0,0);if (*ierr) return; *ierr = DAGetOwnershipRanges(*da,&gx,&gy,&gz);if (*ierr) return; if (lx) {for (i=0; i<M; i++) {lx[i] = gx[i];}} if (ly) {for (i=0; i<N; i++) {ly[i] = gy[i];}} if (lz) {for (i=0; i<P; i++) {lz[i] = gz[i];}} }
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); }
EXTERN_C_BEGIN void PETSC_STDCALL matcreateseqbaij_(MPI_Comm *comm,PetscInt *bs,PetscInt *m,PetscInt *n,PetscInt *nz, PetscInt *nnz,Mat *newmat,PetscErrorCode *ierr) { CHKFORTRANNULLINTEGER(nnz); *ierr = MatCreateSeqBAIJ(MPI_Comm_f2c(*(MPI_Fint *)&*comm),*bs,*m,*n,*nz,nnz,newmat); }
EXTERN_C_BEGIN void PETSC_STDCALL dacreate1d_(MPI_Comm *comm,DAPeriodicType *wrap,PetscInt *M,PetscInt *w,PetscInt *s, PetscInt *lc,DA *inra,PetscErrorCode *ierr) { CHKFORTRANNULLINTEGER(lc); *ierr = DACreate1d(MPI_Comm_f2c(*(MPI_Fint *)&*comm),*wrap,*M,*w,*s,lc,inra); }
EXTERN_C_BEGIN void PETSC_STDCALL dmdacreate1d_(MPI_Comm *comm,DMDABoundaryType *bx,PetscInt *M,PetscInt *w,PetscInt *s, PetscInt *lc,DM *inra,PetscErrorCode *ierr) { CHKFORTRANNULLINTEGER(lc); *ierr = DMDACreate1d(MPI_Comm_f2c(*(MPI_Fint *)&*comm),*bx,*M,*w,*s,lc,inra); }
PETSC_EXTERN void PETSC_STDCALL matcreatempiadj_(MPI_Comm *comm,PetscInt *m,PetscInt *n,PetscInt *i,PetscInt *j,PetscInt *values,Mat *A,PetscErrorCode *ierr) { Mat_MPIAdj *adj; CHKFORTRANNULLINTEGER(values); *ierr = MatCreateMPIAdj(MPI_Comm_f2c(*(MPI_Fint*)&*comm),*m,*n,i,j,values,A); adj = (Mat_MPIAdj*)(*A)->data; adj->freeaij = PETSC_FALSE; }
PETSC_EXTERN void PETSC_STDCALL pcasmgetlocalsubmatrices_(PC *pc,PetscInt *n,Mat *mat, PetscErrorCode *ierr) { PetscInt nloc,i; Mat *tmat; CHKFORTRANNULLOBJECT(mat); CHKFORTRANNULLINTEGER(n); *ierr = PCASMGetLocalSubmatrices(*pc,&nloc,&tmat); if (n) *n = nloc; if (mat) { for (i=0; i<nloc; i++) mat[i] = tmat[i]; } }
PETSC_EXTERN void PETSC_STDCALL pcfieldsplitgetsubksp_(PC *pc,PetscInt *n_local,KSP *ksp,PetscErrorCode *ierr) { KSP *tksp; PetscInt i,nloc; CHKFORTRANNULLINTEGER(n_local); *ierr = PCFieldSplitGetSubKSP(*pc,&nloc,&tksp); if (*ierr) return; if (n_local) *n_local = nloc; CHKFORTRANNULLOBJECT(ksp); if (ksp) { for (i=0; i<nloc; i++) ksp[i] = tksp[i]; } *ierr = PetscFree(tksp); }
PETSC_EXTERN void PETSC_STDCALL matrestorerow_(Mat *mat,PetscInt *row,PetscInt *ncols,PetscInt *cols,PetscScalar *vals,PetscErrorCode *ierr) { const PetscInt **oocols = &my_ocols; const PetscScalar **oovals = &my_ovals; if (!matgetrowactive) { PetscError(PETSC_COMM_SELF,__LINE__,"MatRestoreRow_Fortran",__FILE__,PETSC_ERR_ARG_WRONGSTATE,PETSC_ERROR_INITIAL, "Must call MatGetRow() first"); *ierr = 1; return; } CHKFORTRANNULLINTEGER(cols); if (!cols) oocols = NULL; CHKFORTRANNULLSCALAR(vals); if (!vals) oovals = NULL; *ierr = MatRestoreRow(*mat,*row,ncols,oocols,oovals); matgetrowactive = 0; }
PETSC_EXTERN void PETSC_STDCALL pcasmgetlocalsubdomains_(PC *pc,PetscInt *n,IS *is,IS *is_local, PetscErrorCode *ierr) { PetscInt nloc,i; IS *tis, *tis_local; CHKFORTRANNULLOBJECT(is); CHKFORTRANNULLOBJECT(is_local); CHKFORTRANNULLINTEGER(n); *ierr = PCASMGetLocalSubdomains(*pc,&nloc,&tis,&tis_local); if (n) *n = nloc; if (is) { for (i=0; i<nloc; i++) is[i] = tis[i]; } if (is_local && tis_local) { for (i=0; i<nloc; i++) is_local[i] = tis_local[i]; } }
PETSC_EXTERN void PETSC_STDCALL matgetrow_(Mat *mat,PetscInt *row,PetscInt *ncols,PetscInt *cols,PetscScalar *vals,PetscErrorCode *ierr) { const PetscInt **oocols = &my_ocols; const PetscScalar **oovals = &my_ovals; if (matgetrowactive) { PetscError(PETSC_COMM_SELF,__LINE__,"MatGetRow_Fortran",__FILE__,PETSC_ERR_ARG_WRONGSTATE,PETSC_ERROR_INITIAL, "Cannot have two MatGetRow() active simultaneously\n\ call MatRestoreRow() before calling MatGetRow() a second time"); *ierr = 1; return; } CHKFORTRANNULLINTEGER(cols); if (!cols) oocols = NULL; CHKFORTRANNULLSCALAR(vals); if (!vals) oovals = NULL; *ierr = MatGetRow(*mat,*row,ncols,oocols,oovals); if (*ierr) return; if (oocols) { *ierr = PetscMemcpy(cols,my_ocols,(*ncols)*sizeof(PetscInt)); if (*ierr) return;} if (oovals) { *ierr = PetscMemcpy(vals,my_ovals,(*ncols)*sizeof(PetscScalar)); if (*ierr) return;} matgetrowactive = 1; }
void PETSC_STDCALL vecscatterremap_(VecScatter *scat,PetscInt *rto,PetscInt *rfrom, int *ierr) { CHKFORTRANNULLINTEGER(rto); CHKFORTRANNULLINTEGER(rfrom); *ierr = VecScatterRemap(*scat,rto,rfrom); }
PETSC_EXTERN void PETSC_STDCALL matgetrowmaxabs_(Mat *mat,Vec *v,PetscInt idx[], int *ierr ) { CHKFORTRANNULLINTEGER(idx); *ierr = MatGetRowMaxAbs(*mat,*v,idx); }
PETSC_EXTERN void PETSC_STDCALL matgetlocalsize_(Mat *mat,PetscInt *m,PetscInt *n, int *ierr ) { CHKFORTRANNULLINTEGER(m); CHKFORTRANNULLINTEGER(n); *ierr = MatGetLocalSize(*mat,m,n); }
PETSC_EXTERN void PETSC_STDCALL aocreatememoryscalable_(MPI_Comm *comm,PetscInt *napp,PetscInt *myapp,PetscInt *mypetsc,AO *aoout,PetscErrorCode *ierr) { CHKFORTRANNULLINTEGER(myapp); CHKFORTRANNULLINTEGER(mypetsc); *ierr = AOCreateMemoryScalable(MPI_Comm_f2c(*(MPI_Fint*)&*comm),*napp,myapp,mypetsc,aoout); }
void PETSC_STDCALL matmpibaijsetpreallocation_(Mat *mat,PetscInt *bs,PetscInt *d_nz,PetscInt *d_nnz,PetscInt *o_nz,PetscInt *o_nnz,PetscErrorCode *ierr) { CHKFORTRANNULLINTEGER(d_nnz); CHKFORTRANNULLINTEGER(o_nnz); *ierr = MatMPIBAIJSetPreallocation(*mat,*bs,*d_nz,d_nnz,*o_nz,o_nnz); }
void PETSC_STDCALL matseqbaijsetpreallocation_(Mat *mat,PetscInt *bs,PetscInt *nz,PetscInt *nnz,PetscErrorCode *ierr) { CHKFORTRANNULLINTEGER(nnz); *ierr = MatSeqBAIJSetPreallocation(*mat,*bs,*nz,nnz); }
PETSC_EXTERN void PETSC_STDCALL tssundialsgetiterations_(TS *ts,PetscInt *nonlin,PetscInt *lin,PetscErrorCode *ierr) { CHKFORTRANNULLINTEGER(nonlin); CHKFORTRANNULLINTEGER(lin); *ierr = TSSundialsGetIterations(*ts,nonlin,lin); }
PETSC_EXTERN void PETSC_STDCALL matmpiadjsetpreallocation_(Mat *mat,PetscInt *i,PetscInt *j,PetscInt *values, PetscErrorCode *ierr) { CHKFORTRANNULLINTEGER(values); *ierr = MatMPIAdjSetPreallocation(*mat,i,j,values); }