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 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 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 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 = PetscArraycpy(procs,sprocs,*size); if (*ierr) return; 40 *ierr = PetscArraycpy(numprocs,snumprocs,*size); 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 48 PETSC_EXTERN void islocaltoglobalmappingviewfromoptions_(ISLocalToGlobalMapping *ao,PetscObject obj,char* type,PetscErrorCode *ierr,PETSC_FORTRAN_CHARLEN_T len) 49 { 50 char *t; 51 52 FIXCHAR(type,len,t); 53 CHKFORTRANNULLOBJECT(obj); 54 *ierr = ISLocalToGlobalMappingViewFromOptions(*ao,obj,t);if (*ierr) return; 55 FREECHAR(type,t); 56 } 57