1 #include <petsc/private/fortranimpl.h> 2 #include <petscis.h> 3 #include <petscviewer.h> 4 5 #if defined(PETSC_HAVE_FORTRAN_CAPS) 6 #define islocaltoglobalmappingview_ ISLOCALTOGLOBALMAPPINGVIEW 7 #define islocaltoglobalmpnggetinfosize_ ISLOCALTOGLOBALMPNGGETINFOSIZE 8 #define islocaltoglobalmappinggetinfo_ ISLOCALTOGLOBALMAPPINGGETINFO 9 #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) 10 #define islocaltoglobalmappingview_ islocaltoglobalmappingview 11 #define islocaltoglobalmpnggetinfosize_ islocaltoglobalmpnggetinfosize 12 #define islocaltoglobalmappinggetinfo_ islocaltoglobalmappinggetinfo 13 #endif 14 15 PETSC_EXTERN void PETSC_STDCALL islocaltoglobalmappingview_(ISLocalToGlobalMapping *mapping,PetscViewer *viewer,PetscErrorCode *ierr) 16 { 17 PetscViewer v; 18 PetscPatchDefaultViewers_Fortran(viewer,v); 19 *ierr = ISLocalToGlobalMappingView(*mapping,v); 20 } 21 22 static PetscInt *sprocs, *snumprocs, **sindices; 23 static PetscBool called; 24 PETSC_EXTERN void PETSC_STDCALL islocaltoglobalmpnggetinfosize_(ISLocalToGlobalMapping *mapping,PetscInt *size,PetscInt *maxnumprocs,PetscErrorCode *ierr) 25 { 26 PetscInt i; 27 if (called) {*ierr = PETSC_ERR_ARG_WRONGSTATE; return;} 28 *ierr = ISLocalToGlobalMappingGetInfo(*mapping,size,&sprocs,&snumprocs,&sindices); if (*ierr) return; 29 *maxnumprocs = 0; 30 for (i=0; i<*size; i++) *maxnumprocs = PetscMax(*maxnumprocs,snumprocs[i]); 31 called = PETSC_TRUE; 32 } 33 34 PETSC_EXTERN void PETSC_STDCALL islocaltoglobalmappinggetinfo_(ISLocalToGlobalMapping *mapping,PetscInt *size,PetscInt *procs,PetscInt *numprocs, 35 PetscInt *indices,PetscErrorCode *ierr) 36 { 37 PetscInt i,j; 38 if (!called) {*ierr = PETSC_ERR_ARG_WRONGSTATE; return;} 39 *ierr = PetscMemcpy(procs,sprocs,*size*sizeof(PetscInt)); if (*ierr) return; 40 *ierr = PetscMemcpy(numprocs,snumprocs,*size*sizeof(PetscInt)); if (*ierr) return; 41 for (i=0; i<*size; i++) { 42 for (j=0; j<numprocs[i]; j++) indices[i + (*size)*j] = sindices[i][j]; 43 } 44 *ierr = ISLocalToGlobalMappingRestoreInfo(*mapping,size,&sprocs,&snumprocs,&sindices); if (*ierr) return; 45 called = PETSC_FALSE; 46 } 47