homebrew-core/Formula/petsc.rb
2018-05-21 22:24:04 -07:00

45 lines
1.6 KiB
Ruby

class Petsc < Formula
desc "Portable, Extensible Toolkit for Scientific Computation"
homepage "https://www.mcs.anl.gov/petsc/"
url "http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-lite-3.9.2.tar.gz"
sha256 "65100189796f05991bb2e746f56eec27f8425f6eb901f8f08459ffd2a5e6c69a"
bottle do
sha256 "9564f387895efdb466fa1046d653fded244981f24df1e0e2b11f2a915473ba30" => :high_sierra
sha256 "0e67b175ec324cf89fba1bc2eadc393bb059946a8e75105ee72dd404635282bb" => :sierra
sha256 "7f76b7f77d10e4c544f52403d83aea9c224b14a5cb8fc26bfc20a784fa27857a" => :el_capitan
end
depends_on "hdf5"
depends_on "hwloc"
depends_on "metis"
depends_on "netcdf"
depends_on "open-mpi"
depends_on "scalapack"
depends_on "suite-sparse"
def install
ENV["CC"] = "mpicc"
ENV["CXX"] = "mpicxx"
ENV["F77"] = "mpif77"
ENV["FC"] = "mpif90"
system "./configure", "--prefix=#{prefix}",
"--with-debugging=0",
"--with-scalar-type=real",
"--with-x=0"
system "make", "all"
system "make", "install"
end
test do
test_case = "#{pkgshare}/examples/src/ksp/ksp/examples/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