Actual source code: package.c

      2: #include <petsc/private/petscimpl.h>

      4: /*@C
      5:    PetscHasExternalPackage - Determine whether PETSc has been configured with the given package

      7:    Not Collective

      9:    Input Parameters:
     10: .  pkg - external package name

     12:    Output Parameters:
     13: .  has - PETSC_TRUE if PETSc is configured with the given package, else PETSC_FALSE.

     15:    Level: intermediate

     17:    Notes:
     18:    This is basically an alternative for PETSC_HAVE_XXX whenever a preprocessor macro is not available/desirable, e.g. in Python.

     20:    The external package name pkg is e.g. "hdf5", "yaml", "parmetis".
     21:    It should correspond to the name listed in  ./configure --help  or e.g. in PetscViewerType, MatPartitioningType, MatSolverType.

     23:    The lookup is case insensitive, i.e. looking for "HDF5" or "hdf5" is the same.

     25: .seealso: PetscViewerType, MatPartitioningType, MatSolverType
     26: @*/
     27: PetscErrorCode  PetscHasExternalPackage(const char pkg[], PetscBool *has)
     28: {
     29:   char                  pkgstr[128], *loc;
     30:   size_t                cnt;
     31:   PetscErrorCode        ierr;

     34:   PetscSNPrintfCount(pkgstr,sizeof(pkgstr),":%s:",&cnt,pkg);
     35:   if (cnt >= sizeof(pkgstr)) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_SUP, "Package name is too long: \"%s\"", pkg);
     36:   PetscStrtolower(pkgstr);
     37: #if defined(PETSC_HAVE_PACKAGES)
     38:   PetscStrstr(PETSC_HAVE_PACKAGES, pkgstr, &loc);
     39: #else
     40: #error "PETSC_HAVE_PACKAGES macro undefined. Please reconfigure"
     41: #endif
     42:   *has = loc ? PETSC_TRUE : PETSC_FALSE;
     43:   return(0);
     44: }