xref: /petsc/src/mat/graphops/partition/ftn-custom/zpartitionf.c (revision 8be712e46db5d855f641c6bd97b4543e0efe65bd)
1*8be712e4SBarry Smith #include <../src/mat/impls/adj/mpi/mpiadj.h>
2*8be712e4SBarry Smith #include <petsc/private/fortranimpl.h>
3*8be712e4SBarry Smith #include <petscmat.h>
4*8be712e4SBarry Smith 
5*8be712e4SBarry Smith #if defined(PETSC_HAVE_FORTRAN_CAPS)
6*8be712e4SBarry Smith   #define matpartitioningsetvertexweights_ MATPARTITIONINGSETVERTEXWEIGHTS
7*8be712e4SBarry Smith   #define matpartitioningview_             MATPARTITIONINGVIEW
8*8be712e4SBarry Smith   #define matpartitioningsettype_          MATPARTITIONINGSETTYPE
9*8be712e4SBarry Smith   #define matpartitioningviewfromoptions_  MATPARTITIONINGVIEWFROMOPTIONS
10*8be712e4SBarry Smith #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
11*8be712e4SBarry Smith   #define matpartitioningsetvertexweights_ matpartitioningsetvertexweights
12*8be712e4SBarry Smith   #define matpartitioningview_             matpartitioningview
13*8be712e4SBarry Smith   #define matpartitioningsettype_          matpartitioningsettype
14*8be712e4SBarry Smith   #define matpartitioningviewfromoptions_  matpartitioningviewfromoptions
15*8be712e4SBarry Smith #endif
16*8be712e4SBarry Smith 
17*8be712e4SBarry Smith PETSC_EXTERN void matpartitioningsetvertexweights_(MatPartitioning *part, const PetscInt weights[], PetscErrorCode *ierr)
18*8be712e4SBarry Smith {
19*8be712e4SBarry Smith   PetscInt  len;
20*8be712e4SBarry Smith   PetscInt *array;
21*8be712e4SBarry Smith   *ierr = MatGetLocalSize((*part)->adj, &len, 0);
22*8be712e4SBarry Smith   if (*ierr) return;
23*8be712e4SBarry Smith   *ierr = PetscMalloc1(len, &array);
24*8be712e4SBarry Smith   if (*ierr) return;
25*8be712e4SBarry Smith   *ierr = PetscArraycpy(array, weights, len);
26*8be712e4SBarry Smith   if (*ierr) return;
27*8be712e4SBarry Smith   *ierr = MatPartitioningSetVertexWeights(*part, array);
28*8be712e4SBarry Smith }
29*8be712e4SBarry Smith PETSC_EXTERN void matpartitioningview_(MatPartitioning *part, PetscViewer *viewer, PetscErrorCode *ierr)
30*8be712e4SBarry Smith {
31*8be712e4SBarry Smith   PetscViewer v;
32*8be712e4SBarry Smith   PetscPatchDefaultViewers_Fortran(viewer, v);
33*8be712e4SBarry Smith   *ierr = MatPartitioningView(*part, v);
34*8be712e4SBarry Smith }
35*8be712e4SBarry Smith 
36*8be712e4SBarry Smith PETSC_EXTERN void matpartitioningsettype_(MatPartitioning *part, char *type, PetscErrorCode *ierr, PETSC_FORTRAN_CHARLEN_T len)
37*8be712e4SBarry Smith {
38*8be712e4SBarry Smith   char *t;
39*8be712e4SBarry Smith   FIXCHAR(type, len, t);
40*8be712e4SBarry Smith   *ierr = MatPartitioningSetType(*part, t);
41*8be712e4SBarry Smith   if (*ierr) return;
42*8be712e4SBarry Smith   FREECHAR(type, t);
43*8be712e4SBarry Smith }
44*8be712e4SBarry Smith PETSC_EXTERN void matpartitioningviewfromoptions_(MatPartitioning *ao, PetscObject obj, char *type, PetscErrorCode *ierr, PETSC_FORTRAN_CHARLEN_T len)
45*8be712e4SBarry Smith {
46*8be712e4SBarry Smith   char *t;
47*8be712e4SBarry Smith 
48*8be712e4SBarry Smith   FIXCHAR(type, len, t);
49*8be712e4SBarry Smith   CHKFORTRANNULLOBJECT(obj);
50*8be712e4SBarry Smith   *ierr = MatPartitioningViewFromOptions(*ao, obj, t);
51*8be712e4SBarry Smith   if (*ierr) return;
52*8be712e4SBarry Smith   FREECHAR(type, t);
53*8be712e4SBarry Smith }
54