1 2 #include <petsc/private/petscimpl.h> /*I "petscsys.h" I*/ 3 4 /*@C 5 PetscHasExternalPackage - Determine whether PETSc has been configured with the given package 6 7 Not Collective 8 9 Input Parameters: 10 . pkg - external package name 11 12 Output Parameters: 13 . has - PETSC_TRUE if PETSc is configured with the given package, else PETSC_FALSE. 14 15 Level: intermediate 16 17 Notes: 18 This is basically an alternative for PETSC_HAVE_XXX whenever a preprocessor macro is not available/desirable, e.g. in Python. 19 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. 22 23 The lookup is case insensitive, i.e. looking for "HDF5" or "hdf5" is the same. 24 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; 32 33 PetscFunctionBegin; 34 ierr = PetscSNPrintfCount(pkgstr,sizeof(pkgstr),":%s:",&cnt,pkg);CHKERRQ(ierr); 35 if (cnt >= sizeof(pkgstr)) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_SUP, "Package name is too long: \"%s\"", pkg); 36 ierr = PetscStrtolower(pkgstr);CHKERRQ(ierr); 37 #if defined(PETSC_HAVE_PACKAGES) 38 ierr = PetscStrstr(PETSC_HAVE_PACKAGES, pkgstr, &loc);CHKERRQ(ierr); 39 #else 40 #error "PETSC_HAVE_PACKAGES macro undefined. Please reconfigure" 41 #endif 42 *has = loc ? PETSC_TRUE : PETSC_FALSE; 43 PetscFunctionReturn(0); 44 } 45