xref: /petsc/src/ksp/pc/impls/gasm/ftn-custom/zgasmf.c (revision 6f8503afd8ad4bbe73ed56cecb56c6e6848a045d)
16dd63270SBarry Smith #include <petsc/private/ftnimpl.h>
2768de9afSRichard Tran Mills #include <petscksp.h>
3768de9afSRichard Tran Mills 
4768de9afSRichard Tran Mills #if defined(PETSC_HAVE_FORTRAN_CAPS)
5b3598b19SBarry Smith   #define pcgasmdestroysubdomains_  PCGASMDESTROYSUBDOMAINS
6*6f8503afSBarry Smith   #define pcgasmgetsubksp_          PCGASMGETSUBKSP
76141accfSBarry Smith   #define pcgasmcreatesubdomains2d_ PCGASMCREATESUBDOMAINS2D
8768de9afSRichard Tran Mills #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
9b3598b19SBarry Smith   #define pcgasmdestroysubdomains_  pcgasmdestroysubdomains
10*6f8503afSBarry Smith   #define pcgasmgetsubksp_          pcgasmgetsubksp
116141accfSBarry Smith   #define pcgasmcreatesubdomains2d_ pcgasmcreatesubdomains2d
12768de9afSRichard Tran Mills #endif
13768de9afSRichard Tran Mills 
14ce78bad3SBarry Smith PETSC_EXTERN void pcgasmdestroysubdomains_(PetscInt *n, F90Array1d *is1, F90Array1d *is2, int *ierr PETSC_F90_2PTR_PROTO(ptrd1) PETSC_F90_2PTR_PROTO(ptrd2))
15b3598b19SBarry Smith {
16ce78bad3SBarry Smith   IS *isa, *isb;
17ce78bad3SBarry Smith 
18ce78bad3SBarry Smith   *ierr = F90Array1dAccess(is1, MPIU_FORTRANADDR, (void **)&isa PETSC_F90_2PTR_PARAM(ptrd1));
19b3598b19SBarry Smith   if (*ierr) return;
20ce78bad3SBarry Smith   *ierr = F90Array1dAccess(is2, MPIU_FORTRANADDR, (void **)&isb PETSC_F90_2PTR_PARAM(ptrd2));
21b3598b19SBarry Smith   if (*ierr) return;
22ce78bad3SBarry Smith   *ierr = F90Array1dDestroy(is1, MPIU_FORTRANADDR PETSC_F90_2PTR_PARAM(ptrd1));
23b3598b19SBarry Smith   if (*ierr) return;
24ce78bad3SBarry Smith   *ierr = F90Array1dDestroy(is2, MPIU_FORTRANADDR PETSC_F90_2PTR_PARAM(ptrd2));
25ce78bad3SBarry Smith   if (*ierr) return;
26ce78bad3SBarry Smith   *ierr = PCGASMDestroySubdomains(*n, &isa, &isb);
27b3598b19SBarry Smith }
28b3598b19SBarry Smith 
29ce78bad3SBarry Smith PETSC_EXTERN void pcgasmcreatesubdomains2d_(PC *pc, PetscInt *m, PetscInt *n, PetscInt *M, PetscInt *N, PetscInt *dof, PetscInt *overlap, PetscInt *Nsub, F90Array1d *is1, F90Array1d *is2, int *ierr PETSC_F90_2PTR_PROTO(ptrd1) PETSC_F90_2PTR_PROTO(ptrd2))
306141accfSBarry Smith {
316141accfSBarry Smith   IS *iis, *iisl;
326141accfSBarry Smith   *ierr = PCGASMCreateSubdomains2D(*pc, *m, *n, *M, *N, *dof, *overlap, Nsub, &iis, &iisl);
336141accfSBarry Smith   if (*ierr) return;
34ce78bad3SBarry Smith   *ierr = F90Array1dCreate(iis, MPIU_FORTRANADDR, 1, *Nsub, is1 PETSC_F90_2PTR_PARAM(ptrd1));
356141accfSBarry Smith   if (*ierr) return;
36ce78bad3SBarry Smith   *ierr = F90Array1dCreate(iisl, MPIU_FORTRANADDR, 1, *Nsub, is2 PETSC_F90_2PTR_PARAM(ptrd2));
376141accfSBarry Smith   if (*ierr) return;
386141accfSBarry Smith }
396141accfSBarry Smith 
40ce78bad3SBarry Smith PETSC_EXTERN void pcgasmgetsubksp_(PC *pc, PetscInt *n_local, PetscInt *first_local, F90Array1d *ksp, PetscErrorCode *ierr PETSC_F90_2PTR_PROTO(ptrd))
41768de9afSRichard Tran Mills {
42768de9afSRichard Tran Mills   KSP     *tksp;
43ce78bad3SBarry Smith   PetscInt nloc, flocal;
44ce78bad3SBarry Smith 
45768de9afSRichard Tran Mills   CHKFORTRANNULLINTEGER(n_local);
46768de9afSRichard Tran Mills   CHKFORTRANNULLINTEGER(first_local);
47ce78bad3SBarry Smith   *ierr = PCGASMGetSubKSP(*pc, &nloc, &flocal, &tksp);
48768de9afSRichard Tran Mills   if (n_local) *n_local = nloc;
49ce78bad3SBarry Smith   if (first_local) *first_local = flocal;
50ce78bad3SBarry Smith   *ierr = F90Array1dCreate(tksp, MPIU_FORTRANADDR, 1, nloc, ksp PETSC_F90_2PTR_PARAM(ptrd));
5159fc98c0SBarry Smith }
52