Actual source code: zisltogf.c
1: #include <petsc/private/fortranimpl.h>
2: #include <petscis.h>
3: #include <petscviewer.h>
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
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: }
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) {
28: *ierr = PETSC_ERR_ARG_WRONGSTATE;
29: return;
30: }
31: *ierr = ISLocalToGlobalMappingGetInfo(*mapping, size, &sprocs, &snumprocs, &sindices);
32: if (*ierr) return;
33: *maxnumprocs = 0;
34: for (i = 0; i < *size; i++) *maxnumprocs = PetscMax(*maxnumprocs, snumprocs[i]);
35: called = PETSC_TRUE;
36: }
38: PETSC_EXTERN void islocaltoglobalmappinggetinfo_(ISLocalToGlobalMapping *mapping, PetscInt *size, PetscInt *procs, PetscInt *numprocs, PetscInt *indices, PetscErrorCode *ierr)
39: {
40: PetscInt i, j;
41: if (!called) {
42: *ierr = PETSC_ERR_ARG_WRONGSTATE;
43: return;
44: }
45: *ierr = PetscArraycpy(procs, sprocs, *size);
46: if (*ierr) return;
47: *ierr = PetscArraycpy(numprocs, snumprocs, *size);
48: if (*ierr) return;
49: for (i = 0; i < *size; i++) {
50: for (j = 0; j < numprocs[i]; j++) indices[i + (*size) * j] = sindices[i][j];
51: }
52: *ierr = ISLocalToGlobalMappingRestoreInfo(*mapping, size, &sprocs, &snumprocs, &sindices);
53: if (*ierr) return;
54: called = PETSC_FALSE;
55: }
57: PETSC_EXTERN void islocaltoglobalmappingviewfromoptions_(ISLocalToGlobalMapping *ao, PetscObject obj, char *type, PetscErrorCode *ierr, PETSC_FORTRAN_CHARLEN_T len)
58: {
59: char *t;
61: FIXCHAR(type, len, t);
62: CHKFORTRANNULLOBJECT(obj);
63: *ierr = ISLocalToGlobalMappingViewFromOptions(*ao, obj, t);
64: if (*ierr) return;
65: FREECHAR(type, t);
66: }