homebrew-core/Formula/petsc.rb

59 lines
2.2 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.13.5.tar.gz"
sha256 "10fc542dab961c8b17db35ad3a208cb184c237fc84e183817e38e6c7ab4b8732"
license "BSD-2-Clause"
livecheck do
url "https://www.mcs.anl.gov/petsc/download/index.html"
regex(/href=.*?petsc-lite[._-]v?(\d+(?:\.\d+)+)\.t/i)
end
bottle do
sha256 "abec654e141659c7e5cd3f0af53aa8ce749a99f6dff1921de17301da2dafa756" => :catalina
sha256 "ff5e68fe44cfe9ddd8cad5880e209ade58778cb722808712e4c7b846d523512e" => :mojave
sha256 "58fedc8046a041fb44e2c40f71f7468ae1e8cbc2fc96251e74586cc51a421623" => :high_sierra
end
depends_on "hdf5"
depends_on "hwloc"
depends_on "metis"
depends_on "netcdf"
depends_on "open-mpi"
depends_on "scalapack"
depends_on "suite-sparse"
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"
inreplace lib/"petsc/conf/petscvariables", "#{HOMEBREW_SHIMS_PATH}/mac/super/", ""
end
test do
test_case = "#{pkgshare}/examples/src/ksp/ksp/tutorials/ex1.c"
system "mpicc", test_case, "-I#{include}", "-L#{lib}", "-lpetsc", "-o", "test"
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