55 lines
2.1 KiB
Ruby
55 lines
2.1 KiB
Ruby
class PetscComplex < Formula
|
|
desc "Portable, Extensible Toolkit for Scientific Computation (complex)"
|
|
homepage "https://www.mcs.anl.gov/petsc/"
|
|
url "https://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-lite-3.14.1.tar.gz"
|
|
sha256 "0b4681165a9af96594c794b97ac6993452ec902726679f6b50bb450f89d230ed"
|
|
license "BSD-2-Clause"
|
|
|
|
bottle do
|
|
sha256 "3a330b6463417ea3bdd67df14d7f13b1950339b85b26213c8f8cda8e30c15d87" => :big_sur
|
|
sha256 "37c4464703e7c4cdb6fef406f046aaa9a21c57d1ca514e33650f0f5af90ff2c4" => :catalina
|
|
sha256 "2128291c8151ed900e9fc93bddc97a5f79730a6a0d3382aab2683728f63014b7" => :mojave
|
|
sha256 "ebb3d6850a04a637792f4656c220881584d1b2c8ce897300328c58591349d909" => :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", 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"
|
|
inreplace lib/"petsc/conf/petscvariables", "#{HOMEBREW_SHIMS_PATH}/mac/super/", ""
|
|
end
|
|
|
|
test do
|
|
test_case = "#{share}/petsc/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
|