1 #include <petsc/private/fortranimpl.h> 2 #include <petscmat.h> 3 4 #if defined(PETSC_HAVE_FORTRAN_CAPS) 5 #define matcreatenest_ MATCREATENEST 6 #define matnestgetiss_ MATNESTGETISS 7 #define matnestgetsubmats_ MATNESTGETSUBMATS 8 #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) 9 #define matcreatenest_ matcreatenest 10 #define matnestgetiss_ matnestgetiss 11 #define matnestgetsubmats_ matnestgetsubmats 12 #endif 13 14 PETSC_EXTERN void PETSC_STDCALL matcreatenest_(MPI_Fint *comm,PetscInt *nr,IS is_row[],PetscInt *nc,IS is_col[],Mat a[],Mat *B,int *ierr) 15 { 16 CHKFORTRANNULLOBJECT(is_row); 17 CHKFORTRANNULLOBJECT(is_col); 18 *ierr = MatCreateNest(MPI_Comm_f2c(*comm),*nr,is_row,*nc,is_col,a,B); 19 } 20 21 PETSC_EXTERN void PETSC_STDCALL matnestgetiss_(Mat *A,IS rows[],IS cols[], int *ierr ) 22 { 23 CHKFORTRANNULLOBJECT(rows); 24 CHKFORTRANNULLOBJECT(cols); 25 *ierr = MatNestGetISs(*A,rows,cols); 26 } 27 28 PETSC_EXTERN void PETSC_STDCALL matnestgetsubmats_(Mat *A,PetscInt *M,PetscInt *N,Mat *sub,int *ierr) 29 { 30 PetscInt i,j,m,n; 31 Mat **mat; 32 33 CHKFORTRANNULLINTEGER(M); 34 CHKFORTRANNULLINTEGER(N); 35 CHKFORTRANNULLOBJECT(sub); 36 37 *ierr = MatNestGetSubMats(*A,&m,&n,&mat); 38 39 if (M) { 40 *M = m; 41 } 42 if (N) { 43 *N = n; 44 } 45 if (sub) { 46 for (i=0; i<m; i++) { 47 for (j=0; j<n; j++) { 48 sub[j + n * i] = mat[i][j]; 49 } 50 } 51 } 52 } 53