xref: /petsc/src/ksp/pc/impls/asm/ftn-custom/zasmf.c (revision ce78bad369055609e946c9d2c25ea67a45873e27)
1*ce78bad3SBarry Smith #include <petsc/private/f90impl.h>
2c6db04a5SJed Brown #include <petscksp.h>
3e54e4138SSatish Balay 
4e54e4138SSatish Balay #if defined(PETSC_HAVE_FORTRAN_CAPS)
5*ce78bad3SBarry Smith   #define pcasmgetsubksp_           PCASMGETSUBKSP
6e54e4138SSatish Balay   #define pcasmgetlocalsubmatrices_ PCASMGETLOCALSUBMATRICES
7e54e4138SSatish Balay   #define pcasmgetlocalsubdomains_  PCASMGETLOCALSUBDOMAINS
8ef356e52SBarry Smith   #define pcasmcreatesubdomains_    PCASMCREATESUBDOMAINS
9ef356e52SBarry Smith   #define pcasmdestroysubdomains_   PCASMDESTROYSUBDOMAINS
106141accfSBarry Smith   #define pcasmcreatesubdomains2d_  PCASMCREATESUBDOMAINS2D
11e54e4138SSatish Balay #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
12*ce78bad3SBarry Smith   #define pcasmgetsubksp_           pcasmgetsubksp
13e54e4138SSatish Balay   #define pcasmgetlocalsubmatrices_ pcasmgetlocalsubmatrices
14e54e4138SSatish Balay   #define pcasmgetlocalsubdomains_  pcasmgetlocalsubdomains
15ef356e52SBarry Smith   #define pcasmcreatesubdomains_    pcasmcreatesubdomains
16ef356e52SBarry Smith   #define pcasmdestroysubdomains_   pcasmdestroysubdomains
176141accfSBarry Smith   #define pcasmcreatesubdomains2d_  pcasmcreatesubdomains2d
18e54e4138SSatish Balay #endif
19e54e4138SSatish Balay 
20*ce78bad3SBarry Smith PETSC_EXTERN void pcasmcreatesubdomains_(Mat *mat, PetscInt n, F90Array1d *is, PetscErrorCode *ierr PETSC_F90_2PTR_PROTO(ptrd1))
216141accfSBarry Smith {
22ef356e52SBarry Smith   IS *insubs;
23ef356e52SBarry Smith 
24*ce78bad3SBarry Smith   CHKFORTRANNULLOBJECT(is);
25*ce78bad3SBarry Smith   *ierr = PCASMCreateSubdomains(*mat, n, &insubs);
265975b3b6SBarry Smith   if (*ierr) return;
27*ce78bad3SBarry Smith   if (insubs) *ierr = F90Array1dCreate(insubs, MPIU_FORTRANADDR, 1, n, is PETSC_F90_2PTR_PARAM(ptrd1));
28ef356e52SBarry Smith }
29ef356e52SBarry Smith 
30*ce78bad3SBarry Smith PETSC_EXTERN void pcasmgetlocalsubmatrices_(PC *pc, PetscInt *n, F90Array1d *mat, PetscErrorCode *ierr PETSC_F90_2PTR_PROTO(ptrd))
31ef356e52SBarry Smith {
32*ce78bad3SBarry Smith   PetscInt nloc;
33e54e4138SSatish Balay   Mat     *tmat;
34*ce78bad3SBarry Smith 
35e54e4138SSatish Balay   CHKFORTRANNULLOBJECT(mat);
36e54e4138SSatish Balay   CHKFORTRANNULLINTEGER(n);
37e54e4138SSatish Balay   *ierr = PCASMGetLocalSubmatrices(*pc, &nloc, &tmat);
38e54e4138SSatish Balay   if (n) *n = nloc;
39*ce78bad3SBarry Smith   if (mat) *ierr = F90Array1dCreate(tmat, MPIU_FORTRANADDR, 1, nloc, mat PETSC_F90_2PTR_PARAM(ptrd));
40e54e4138SSatish Balay }
41*ce78bad3SBarry Smith 
42*ce78bad3SBarry Smith PETSC_EXTERN void pcasmgetlocalsubdomains_(PC *pc, PetscInt *n, F90Array1d *is, F90Array1d *is_local, int *ierr PETSC_F90_2PTR_PROTO(ptrd1) PETSC_F90_2PTR_PROTO(ptrd2))
43e54e4138SSatish Balay {
44*ce78bad3SBarry Smith   PetscInt nloc;
452b691e39SMatthew Knepley   IS      *tis, *tis_local;
46*ce78bad3SBarry Smith 
47e54e4138SSatish Balay   CHKFORTRANNULLOBJECT(is);
482b691e39SMatthew Knepley   CHKFORTRANNULLOBJECT(is_local);
49e54e4138SSatish Balay   CHKFORTRANNULLINTEGER(n);
502b691e39SMatthew Knepley   *ierr = PCASMGetLocalSubdomains(*pc, &nloc, &tis, &tis_local);
51*ce78bad3SBarry Smith   if (*ierr) return;
52e54e4138SSatish Balay   if (n) *n = nloc;
53*ce78bad3SBarry Smith   if (is) *ierr = F90Array1dCreate(tis, MPIU_FORTRANADDR, 1, nloc, is PETSC_F90_2PTR_PARAM(ptrd1));
54*ce78bad3SBarry Smith   if (*ierr) return;
55*ce78bad3SBarry Smith   if (is_local) *ierr = F90Array1dCreate(tis_local, MPIU_FORTRANADDR, 1, nloc, is_local PETSC_F90_2PTR_PARAM(ptrd2));
56*ce78bad3SBarry Smith   if (*ierr) return;
57e54e4138SSatish Balay }
58*ce78bad3SBarry Smith 
59*ce78bad3SBarry Smith PETSC_EXTERN void pcasmdestroysubdomains_(PetscInt *n, F90Array1d *is1, F90Array1d *is2, int *ierr PETSC_F90_2PTR_PROTO(ptrd1) PETSC_F90_2PTR_PROTO(ptrd2))
60*ce78bad3SBarry Smith {
61*ce78bad3SBarry Smith   IS *isa, *isb;
62*ce78bad3SBarry Smith 
63*ce78bad3SBarry Smith   *ierr = F90Array1dAccess(is1, MPIU_FORTRANADDR, (void **)&isa PETSC_F90_2PTR_PARAM(ptrd1));
64*ce78bad3SBarry Smith   if (*ierr) return;
65*ce78bad3SBarry Smith   *ierr = F90Array1dAccess(is2, MPIU_FORTRANADDR, (void **)&isb PETSC_F90_2PTR_PARAM(ptrd2));
66*ce78bad3SBarry Smith   if (*ierr) return;
67*ce78bad3SBarry Smith   *ierr = PCASMDestroySubdomains(*n, &isa, &isb);
68*ce78bad3SBarry Smith   if (*ierr) return;
69*ce78bad3SBarry Smith   *ierr = F90Array1dDestroy(is1, MPIU_FORTRANADDR PETSC_F90_2PTR_PARAM(ptrd1));
70*ce78bad3SBarry Smith   if (*ierr) return;
71*ce78bad3SBarry Smith   *ierr = F90Array1dDestroy(is2, MPIU_FORTRANADDR PETSC_F90_2PTR_PARAM(ptrd2));
72*ce78bad3SBarry Smith   if (*ierr) return;
732b691e39SMatthew Knepley }
74*ce78bad3SBarry Smith 
75*ce78bad3SBarry Smith PETSC_EXTERN void pcasmcreatesubdomains2d_(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))
76*ce78bad3SBarry Smith {
77*ce78bad3SBarry Smith   IS *iis, *iisl;
78*ce78bad3SBarry Smith 
79*ce78bad3SBarry Smith   *ierr = PCASMCreateSubdomains2D(*m, *n, *M, *N, *dof, *overlap, Nsub, &iis, &iisl);
80*ce78bad3SBarry Smith   if (*ierr) return;
81*ce78bad3SBarry Smith   *ierr = F90Array1dCreate(iis, MPIU_FORTRANADDR, 1, *Nsub, is1 PETSC_F90_2PTR_PARAM(ptrd1));
82*ce78bad3SBarry Smith   if (*ierr) return;
83*ce78bad3SBarry Smith   *ierr = F90Array1dCreate(iisl, MPIU_FORTRANADDR, 1, *Nsub, is2 PETSC_F90_2PTR_PARAM(ptrd2));
84*ce78bad3SBarry Smith   if (*ierr) return;
85*ce78bad3SBarry Smith }
86*ce78bad3SBarry Smith 
87*ce78bad3SBarry Smith PETSC_EXTERN void pcasmgetsubksp_(PC *pc, PetscInt *n_local, PetscInt *first_local, F90Array1d *ksp, PetscErrorCode *ierr PETSC_F90_2PTR_PROTO(ptrd))
88*ce78bad3SBarry Smith {
89*ce78bad3SBarry Smith   KSP     *tksp;
90*ce78bad3SBarry Smith   PetscInt nloc, flocal;
91*ce78bad3SBarry Smith 
92*ce78bad3SBarry Smith   CHKFORTRANNULLINTEGER(n_local);
93*ce78bad3SBarry Smith   CHKFORTRANNULLINTEGER(first_local);
94*ce78bad3SBarry Smith   *ierr = PCASMGetSubKSP(*pc, &nloc, &flocal, &tksp);
95*ce78bad3SBarry Smith   if (n_local) *n_local = nloc;
96*ce78bad3SBarry Smith   if (first_local) *first_local = flocal;
97*ce78bad3SBarry Smith   *ierr = F90Array1dCreate(tksp, MPIU_FORTRANADDR, 1, nloc, ksp PETSC_F90_2PTR_PARAM(ptrd));
98e54e4138SSatish Balay }
99