69 lines
2.6 KiB
Ruby
69 lines
2.6 KiB
Ruby
class PetscComplex < Formula
|
|
desc "Portable, Extensible Toolkit for Scientific Computation (complex)"
|
|
homepage "https://petsc.org/"
|
|
url "https://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-lite-3.17.4.tar.gz"
|
|
sha256 "99c127486722a3ffd95a268b4ceb0976cbf217926c681a9631bd7246eab8cb2a"
|
|
license "BSD-2-Clause"
|
|
|
|
livecheck do
|
|
formula "petsc"
|
|
end
|
|
|
|
bottle do
|
|
sha256 arm64_monterey: "c37605edacdff6c34abc0d25568e4150c805eb8cde38cc14f19bb83766e62695"
|
|
sha256 arm64_big_sur: "461e5917ffa2f8cc66a2436a0749d90ba396e8c51483a8509c64ccef02519e34"
|
|
sha256 monterey: "97525809053c56281cffaf2087e8746760327b59640079768560c92b1d7849df"
|
|
sha256 big_sur: "729dad0081625b186e00e230598796fbbbdd0699dfac0485223a5b3a2cdbd0ca"
|
|
sha256 catalina: "075f167f50b088e9a20aaec1b2d0e7d1cea62e16f1510eb39a24ebfd249da6d4"
|
|
sha256 x86_64_linux: "d29d36898ce7a21d1eb564061eed9ffaccdedc0973869fe519aa60876d75eacc"
|
|
end
|
|
|
|
depends_on "hdf5"
|
|
depends_on "hwloc"
|
|
depends_on "metis"
|
|
depends_on "netcdf"
|
|
depends_on "open-mpi"
|
|
depends_on "openblas"
|
|
depends_on "python@3.10"
|
|
depends_on "scalapack"
|
|
depends_on "suite-sparse"
|
|
|
|
uses_from_macos "python" => :build
|
|
|
|
conflicts_with "petsc", 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=complex",
|
|
"--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", share/"petsc/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
|