xref: /petsc/src/mat/graphops/partition/ftn-custom/zpartitionf.c (revision fb3cba250866195917cae43976dd632954847ed0)
18be712e4SBarry Smith #include <../src/mat/impls/adj/mpi/mpiadj.h>
28be712e4SBarry Smith #include <petsc/private/fortranimpl.h>
38be712e4SBarry Smith #include <petscmat.h>
48be712e4SBarry Smith 
58be712e4SBarry Smith #if defined(PETSC_HAVE_FORTRAN_CAPS)
68be712e4SBarry Smith   #define matpartitioningsetvertexweights_ MATPARTITIONINGSETVERTEXWEIGHTS
78be712e4SBarry Smith   #define matpartitioningview_             MATPARTITIONINGVIEW
88be712e4SBarry Smith   #define matpartitioningsettype_          MATPARTITIONINGSETTYPE
98be712e4SBarry Smith   #define matpartitioningviewfromoptions_  MATPARTITIONINGVIEWFROMOPTIONS
108be712e4SBarry Smith #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
118be712e4SBarry Smith   #define matpartitioningsetvertexweights_ matpartitioningsetvertexweights
128be712e4SBarry Smith   #define matpartitioningview_             matpartitioningview
138be712e4SBarry Smith   #define matpartitioningsettype_          matpartitioningsettype
148be712e4SBarry Smith   #define matpartitioningviewfromoptions_  matpartitioningviewfromoptions
158be712e4SBarry Smith #endif
168be712e4SBarry Smith 
178be712e4SBarry Smith PETSC_EXTERN void matpartitioningsetvertexweights_(MatPartitioning *part, const PetscInt weights[], PetscErrorCode *ierr)
188be712e4SBarry Smith {
198be712e4SBarry Smith   PetscInt  len;
208be712e4SBarry Smith   PetscInt *array;
21*fb3cba25SSatish Balay   *ierr = MatGetLocalSize((*part)->adj, &len, NULL);
228be712e4SBarry Smith   if (*ierr) return;
238be712e4SBarry Smith   *ierr = PetscMalloc1(len, &array);
248be712e4SBarry Smith   if (*ierr) return;
258be712e4SBarry Smith   *ierr = PetscArraycpy(array, weights, len);
268be712e4SBarry Smith   if (*ierr) return;
278be712e4SBarry Smith   *ierr = MatPartitioningSetVertexWeights(*part, array);
288be712e4SBarry Smith }
298be712e4SBarry Smith PETSC_EXTERN void matpartitioningview_(MatPartitioning *part, PetscViewer *viewer, PetscErrorCode *ierr)
308be712e4SBarry Smith {
318be712e4SBarry Smith   PetscViewer v;
328be712e4SBarry Smith   PetscPatchDefaultViewers_Fortran(viewer, v);
338be712e4SBarry Smith   *ierr = MatPartitioningView(*part, v);
348be712e4SBarry Smith }
358be712e4SBarry Smith 
368be712e4SBarry Smith PETSC_EXTERN void matpartitioningsettype_(MatPartitioning *part, char *type, PetscErrorCode *ierr, PETSC_FORTRAN_CHARLEN_T len)
378be712e4SBarry Smith {
388be712e4SBarry Smith   char *t;
398be712e4SBarry Smith   FIXCHAR(type, len, t);
408be712e4SBarry Smith   *ierr = MatPartitioningSetType(*part, t);
418be712e4SBarry Smith   if (*ierr) return;
428be712e4SBarry Smith   FREECHAR(type, t);
438be712e4SBarry Smith }
448be712e4SBarry Smith PETSC_EXTERN void matpartitioningviewfromoptions_(MatPartitioning *ao, PetscObject obj, char *type, PetscErrorCode *ierr, PETSC_FORTRAN_CHARLEN_T len)
458be712e4SBarry Smith {
468be712e4SBarry Smith   char *t;
478be712e4SBarry Smith 
488be712e4SBarry Smith   FIXCHAR(type, len, t);
498be712e4SBarry Smith   CHKFORTRANNULLOBJECT(obj);
508be712e4SBarry Smith   *ierr = MatPartitioningViewFromOptions(*ao, obj, t);
518be712e4SBarry Smith   if (*ierr) return;
528be712e4SBarry Smith   FREECHAR(type, t);
538be712e4SBarry Smith }
54