69 lines
2.7 KiB
Ruby
69 lines
2.7 KiB
Ruby
class Petsc < Formula
|
|
desc "Portable, Extensible Toolkit for Scientific Computation (real)"
|
|
homepage "https://www.mcs.anl.gov/petsc/"
|
|
url "https://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-lite-3.17.1.tar.gz"
|
|
sha256 "c504609d9f532327c20b6363d6a6c7647ebd3c98acfb382c28fcd3852300ddd1"
|
|
license "BSD-2-Clause"
|
|
|
|
livecheck do
|
|
url "https://ftp.mcs.anl.gov/pub/petsc/release-snapshots/"
|
|
regex(/href=.*?petsc-lite[._-]v?(\d+(?:\.\d+)+)\.t/i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 arm64_monterey: "5ed7b9355caea82a5afa4e68700c7d95ef2a2abfddec79df2ee3eafae4776f64"
|
|
sha256 arm64_big_sur: "5aa76d2d6163f06a54cb10bae3cf3d30c0f3455acdacbd87268acec8b6f96a51"
|
|
sha256 monterey: "70604fa3e8e39e4f0f587a42be0780fe056178466872aea2d116a0ed5d315c9b"
|
|
sha256 big_sur: "80fc9343424453c935388479a833f39437d667812024519a418d7a625a625921"
|
|
sha256 catalina: "a7b4114d60180ba4b51de64694c252dd3aae007212121dc35ac486c86766b262"
|
|
sha256 x86_64_linux: "2f2dab10315ddd4a559cb5fdbd51eccf9b183bc89ac4744507e2e7fa3e4642e7"
|
|
end
|
|
|
|
depends_on "hdf5"
|
|
depends_on "hwloc"
|
|
depends_on "metis"
|
|
depends_on "netcdf"
|
|
depends_on "open-mpi"
|
|
depends_on "openblas"
|
|
depends_on "scalapack"
|
|
depends_on "suite-sparse"
|
|
|
|
uses_from_macos "python" => :build
|
|
|
|
conflicts_with "petsc-complex", because: "petsc must be installed with either real or complex support, not both"
|
|
|
|
def install
|
|
system "./configure", "--prefix=#{prefix}",
|
|
"--with-debugging=0",
|
|
"--with-scalar-type=real",
|
|
"--with-x=0",
|
|
"--CC=mpicc",
|
|
"--CXX=mpicxx",
|
|
"--F77=mpif77",
|
|
"--FC=mpif90",
|
|
"MAKEFLAGS=$MAKEFLAGS"
|
|
system "make", "all"
|
|
system "make", "install"
|
|
|
|
# Avoid references to Homebrew shims
|
|
rm_f lib/"petsc/conf/configure-hash"
|
|
|
|
if OS.mac? || File.foreach("#{lib}/petsc/conf/petscvariables").any? { |l| l[Superenv.shims_path.to_s] }
|
|
inreplace lib/"petsc/conf/petscvariables", "#{Superenv.shims_path}/", ""
|
|
end
|
|
end
|
|
|
|
test do
|
|
flags = %W[-I#{include} -L#{lib} -lpetsc]
|
|
flags << "-Wl,-rpath,#{lib}" if OS.linux?
|
|
system "mpicc", pkgshare/"examples/src/ksp/ksp/tutorials/ex1.c", "-o", "test", *flags
|
|
output = shell_output("./test")
|
|
# This PETSc example prints several lines of output. The last line contains
|
|
# an error norm, expected to be small.
|
|
line = output.lines.last
|
|
assert_match(/^Norm of error .+, Iterations/, line, "Unexpected output format")
|
|
error = line.split[3].to_f
|
|
assert (error >= 0.0 && error < 1.0e-13), "Error norm too large"
|
|
end
|
|
end
|