48 lines
1.7 KiB
Ruby
48 lines
1.7 KiB
Ruby
class Petsc < Formula
|
|
desc "Portable, Extensible Toolkit for Scientific Computation (real)"
|
|
homepage "https://www.mcs.anl.gov/petsc/"
|
|
url "http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-lite-3.12.4.tar.gz"
|
|
sha256 "800a965dd01adac099a186588cda68e4fcb224af326d8aaf55978361c019258f"
|
|
|
|
bottle do
|
|
sha256 "ea846dbba27d24855346acaf8f9ebd78d55c7cce8a0dbe0cc455d7b85957afc8" => :catalina
|
|
sha256 "57b1473d78b74bfda4c463fc590bbe0da7cf2befe9ac46303f919376c2a2b706" => :mojave
|
|
sha256 "e8c6a95f1fcd959e880548bf1ae7aa2c49a8d49a7ed58eec245c5673a0a6f2cb" => :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
|
|
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
|