xref: /petsc/src/ksp/pc/impls/gasm/ftn-custom/zgasmf.c (revision b3598b199930f2c8142717fd21b08af9a1152710)
1768de9afSRichard Tran Mills #include <petsc/private/fortranimpl.h>
2768de9afSRichard Tran Mills #include <petscksp.h>
3768de9afSRichard Tran Mills 
4768de9afSRichard Tran Mills #if defined(PETSC_HAVE_FORTRAN_CAPS)
5*b3598b19SBarry Smith   #define pcgasmsetsubdomains_      PCGASMSETSUBDOMAINS
6*b3598b19SBarry Smith   #define pcgasmdestroysubdomains_  PCGASMDESTROYSUBDOMAINS
7ab32a8f3SSatish Balay   #define pcgasmgetsubksp1_         PCGASMGETSUBKSP1
8ab32a8f3SSatish Balay   #define pcgasmgetsubksp2_         PCGASMGETSUBKSP2
959fc98c0SBarry Smith   #define pcgasmgetsubksp3_         PCGASMGETSUBKSP3
1059fc98c0SBarry Smith   #define pcgasmgetsubksp4_         PCGASMGETSUBKSP4
1159fc98c0SBarry Smith   #define pcgasmgetsubksp5_         PCGASMGETSUBKSP5
1259fc98c0SBarry Smith   #define pcgasmgetsubksp6_         PCGASMGETSUBKSP6
1359fc98c0SBarry Smith   #define pcgasmgetsubksp7_         PCGASMGETSUBKSP7
1459fc98c0SBarry Smith   #define pcgasmgetsubksp8_         PCGASMGETSUBKSP8
156141accfSBarry Smith   #define pcgasmcreatesubdomains2d_ PCGASMCREATESUBDOMAINS2D
16768de9afSRichard Tran Mills #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
17*b3598b19SBarry Smith   #define pcgasmsetsubdomains_      pcgasmsetsubdomains
18*b3598b19SBarry Smith   #define pcgasmdestroysubdomains_  pcgasmdestroysubdomains
19ab32a8f3SSatish Balay   #define pcgasmgetsubksp2_         pcgasmgetsubksp2
2059fc98c0SBarry Smith   #define pcgasmgetsubksp3_         pcgasmgetsubksp3
2159fc98c0SBarry Smith   #define pcgasmgetsubksp4_         pcgasmgetsubksp4
2259fc98c0SBarry Smith   #define pcgasmgetsubksp5_         pcgasmgetsubksp5
2359fc98c0SBarry Smith   #define pcgasmgetsubksp6_         pcgasmgetsubksp6
2459fc98c0SBarry Smith   #define pcgasmgetsubksp7_         pcgasmgetsubksp7
2559fc98c0SBarry Smith   #define pcgasmgetsubksp8_         pcgasmgetsubksp8
266141accfSBarry Smith   #define pcgasmcreatesubdomains2d_ pcgasmcreatesubdomains2d
27768de9afSRichard Tran Mills #endif
28768de9afSRichard Tran Mills 
29*b3598b19SBarry Smith PETSC_EXTERN void pcgasmsetsubdomains_(PC *pc, PetscInt *n, IS *is, IS *isl, int *ierr)
30*b3598b19SBarry Smith {
31*b3598b19SBarry Smith   *ierr = PCGASMSetSubdomains(*pc, *n, is, isl);
32*b3598b19SBarry Smith }
33*b3598b19SBarry Smith 
34*b3598b19SBarry Smith PETSC_EXTERN void pcgasmdestroysubdomains_(PetscInt *n, IS *is, IS *isl, int *ierr)
35*b3598b19SBarry Smith {
36*b3598b19SBarry Smith   IS *iis, *iisl;
37*b3598b19SBarry Smith   *ierr = PetscMalloc1(*n, &iis);
38*b3598b19SBarry Smith   if (*ierr) return;
39*b3598b19SBarry Smith   *ierr = PetscArraycpy(iis, is, *n);
40*b3598b19SBarry Smith   if (*ierr) return;
41*b3598b19SBarry Smith   *ierr = PetscMalloc1(*n, &iisl);
42*b3598b19SBarry Smith   if (*ierr) return;
43*b3598b19SBarry Smith   *ierr = PetscArraycpy(iisl, isl, *n);
44*b3598b19SBarry Smith   *ierr = PCGASMDestroySubdomains(*n, &iis, &iisl);
45*b3598b19SBarry Smith }
46*b3598b19SBarry Smith 
476141accfSBarry Smith PETSC_EXTERN void pcgasmcreatesubdomains2d_(PC *pc, PetscInt *m, PetscInt *n, PetscInt *M, PetscInt *N, PetscInt *dof, PetscInt *overlap, PetscInt *Nsub, IS *is, IS *isl, int *ierr)
486141accfSBarry Smith {
496141accfSBarry Smith   IS *iis, *iisl;
506141accfSBarry Smith   *ierr = PCGASMCreateSubdomains2D(*pc, *m, *n, *M, *N, *dof, *overlap, Nsub, &iis, &iisl);
516141accfSBarry Smith   if (*ierr) return;
52*b3598b19SBarry Smith   *ierr = PetscArraycpy(is, iis, *Nsub);
536141accfSBarry Smith   if (*ierr) return;
54*b3598b19SBarry Smith   *ierr = PetscArraycpy(isl, iisl, *Nsub);
556141accfSBarry Smith   if (*ierr) return;
566141accfSBarry Smith   *ierr = PetscFree(iis);
576141accfSBarry Smith   if (*ierr) return;
586141accfSBarry Smith   *ierr = PetscFree(iisl);
596141accfSBarry Smith }
606141accfSBarry Smith 
61ab32a8f3SSatish Balay PETSC_EXTERN void pcgasmgetsubksp1_(PC *pc, PetscInt *n_local, PetscInt *first_local, KSP *ksp, PetscErrorCode *ierr)
62768de9afSRichard Tran Mills {
63768de9afSRichard Tran Mills   KSP     *tksp;
64768de9afSRichard Tran Mills   PetscInt i, nloc;
65768de9afSRichard Tran Mills   CHKFORTRANNULLINTEGER(n_local);
66768de9afSRichard Tran Mills   CHKFORTRANNULLINTEGER(first_local);
67768de9afSRichard Tran Mills   CHKFORTRANNULLOBJECT(ksp);
68768de9afSRichard Tran Mills   *ierr = PCGASMGetSubKSP(*pc, &nloc, first_local, &tksp);
69768de9afSRichard Tran Mills   if (n_local) *n_local = nloc;
70768de9afSRichard Tran Mills   if (ksp) {
71768de9afSRichard Tran Mills     for (i = 0; i < nloc; i++) ksp[i] = tksp[i];
72768de9afSRichard Tran Mills   }
73768de9afSRichard Tran Mills }
74768de9afSRichard Tran Mills 
75ab32a8f3SSatish Balay PETSC_EXTERN void pcgasmgetsubksp2_(PC *pc, PetscInt *n_local, PetscInt *first_local, KSP *ksp, PetscErrorCode *ierr)
76ab32a8f3SSatish Balay {
77ab32a8f3SSatish Balay   pcgasmgetsubksp1_(pc, n_local, first_local, ksp, ierr);
78ab32a8f3SSatish Balay }
7959fc98c0SBarry Smith 
8059fc98c0SBarry Smith PETSC_EXTERN void pcgasmgetsubksp3_(PC *pc, PetscInt *n_local, PetscInt *first_local, KSP *ksp, PetscErrorCode *ierr)
8159fc98c0SBarry Smith {
8259fc98c0SBarry Smith   pcgasmgetsubksp1_(pc, n_local, first_local, ksp, ierr);
8359fc98c0SBarry Smith }
8459fc98c0SBarry Smith 
8559fc98c0SBarry Smith PETSC_EXTERN void pcgasmgetsubksp4_(PC *pc, PetscInt *n_local, PetscInt *first_local, KSP *ksp, PetscErrorCode *ierr)
8659fc98c0SBarry Smith {
8759fc98c0SBarry Smith   pcgasmgetsubksp1_(pc, n_local, first_local, ksp, ierr);
8859fc98c0SBarry Smith }
8959fc98c0SBarry Smith 
9059fc98c0SBarry Smith PETSC_EXTERN void pcgasmgetsubksp5_(PC *pc, PetscInt *n_local, PetscInt *first_local, KSP *ksp, PetscErrorCode *ierr)
9159fc98c0SBarry Smith {
9259fc98c0SBarry Smith   pcgasmgetsubksp1_(pc, n_local, first_local, ksp, ierr);
9359fc98c0SBarry Smith }
9459fc98c0SBarry Smith 
9559fc98c0SBarry Smith PETSC_EXTERN void pcgasmgetsubksp6_(PC *pc, PetscInt *n_local, PetscInt *first_local, KSP *ksp, PetscErrorCode *ierr)
9659fc98c0SBarry Smith {
9759fc98c0SBarry Smith   pcgasmgetsubksp1_(pc, n_local, first_local, ksp, ierr);
9859fc98c0SBarry Smith }
9959fc98c0SBarry Smith 
10059fc98c0SBarry Smith PETSC_EXTERN void pcgasmgetsubksp7_(PC *pc, PetscInt *n_local, PetscInt *first_local, KSP *ksp, PetscErrorCode *ierr)
10159fc98c0SBarry Smith {
10259fc98c0SBarry Smith   pcgasmgetsubksp1_(pc, n_local, first_local, ksp, ierr);
10359fc98c0SBarry Smith }
10459fc98c0SBarry Smith 
10559fc98c0SBarry Smith PETSC_EXTERN void pcgasmgetsubksp8_(PC *pc, PetscInt *n_local, PetscInt *first_local, KSP *ksp, PetscErrorCode *ierr)
10659fc98c0SBarry Smith {
10759fc98c0SBarry Smith   pcgasmgetsubksp1_(pc, n_local, first_local, ksp, ierr);
10859fc98c0SBarry Smith }
109