Actual source code: zisltogf.c

  1: #include <petsc/private/ftnimpl.h>
  2: #include <petscis.h>
  3: #include <petscviewer.h>

  5: #if PetscDefined(HAVE_FORTRAN_CAPS)
  6:   #define islocaltoglobalmpnggetinfosize_ ISLOCALTOGLOBALMPNGGETINFOSIZE
  7:   #define islocaltoglobalmappinggetinfo_  ISLOCALTOGLOBALMAPPINGGETINFO
  8: #elif !PetscDefined(HAVE_FORTRAN_UNDERSCORE)
  9:   #define islocaltoglobalmpnggetinfosize_ islocaltoglobalmpnggetinfosize
 10:   #define islocaltoglobalmappinggetinfo_  islocaltoglobalmappinggetinfo
 11: #endif

 13: static PetscInt  *sprocs, *snumprocs, **sindices;
 14: static PetscBool  called;
 15: PETSC_EXTERN void islocaltoglobalmpnggetinfosize_(ISLocalToGlobalMapping *mapping, PetscInt *size, PetscInt *maxnumprocs, PetscErrorCode *ierr)
 16: {
 17:   if (called) {
 18:     *ierr = PETSC_ERR_ARG_WRONGSTATE;
 19:     return;
 20:   }
 21:   *ierr = ISLocalToGlobalMappingGetInfo(*mapping, size, &sprocs, &snumprocs, &sindices);
 22:   if (*ierr) return;
 23:   *maxnumprocs = 0;
 24:   for (PetscInt i = 0; i < *size; i++) *maxnumprocs = PetscMax(*maxnumprocs, snumprocs[i]);
 25:   called = PETSC_TRUE;
 26: }

 28: PETSC_EXTERN void islocaltoglobalmappinggetinfo_(ISLocalToGlobalMapping *mapping, PetscInt *size, PetscInt *procs, PetscInt *numprocs, PetscInt *indices, PetscErrorCode *ierr)
 29: {
 30:   if (!called) {
 31:     *ierr = PETSC_ERR_ARG_WRONGSTATE;
 32:     return;
 33:   }
 34:   *ierr = PetscArraycpy(procs, sprocs, *size);
 35:   if (*ierr) return;
 36:   *ierr = PetscArraycpy(numprocs, snumprocs, *size);
 37:   if (*ierr) return;
 38:   for (PetscInt i = 0; i < *size; i++) {
 39:     for (PetscInt j = 0; j < numprocs[i]; j++) indices[i + (*size) * j] = sindices[i][j];
 40:   }
 41:   *ierr = ISLocalToGlobalMappingRestoreInfo(*mapping, size, &sprocs, &snumprocs, &sindices);
 42:   if (*ierr) return;
 43:   called = PETSC_FALSE;
 44: }