homebrew-core/Formula/petsc-complex.rb
2019-07-15 08:36:05 +08:00

47 lines
1.8 KiB
Ruby

class PetscComplex < Formula
desc "Portable, Extensible Toolkit for Scientific Computation (complex)"
homepage "https://www.mcs.anl.gov/petsc/"
url "http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-lite-3.11.3.tar.gz"
sha256 "8bee4a5ad37af85938ae755be182dcea255888b4f8b3d976bedc57e959280622"
bottle do
sha256 "c70dd12b2c8b3b19c27f5b458e98cfe54d839db48b8a98418ad58f866a678b8d" => :mojave
sha256 "a03bd437afefea39a50cd723a4cc12a502eec8eae156be6e8ac9be9c5f228948" => :high_sierra
sha256 "48de6e22992586a02b383561e4de77f7f40c8d2423f79b748b9ef932dec2b473" => :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
ENV["CC"] = "mpicc"
ENV["CXX"] = "mpicxx"
ENV["F77"] = "mpif77"
ENV["FC"] = "mpif90"
system "./configure", "--prefix=#{prefix}",
"--with-debugging=0",
"--with-scalar-type=complex",
"--with-x=0"
system "make", "all"
system "make", "install"
end
test do
test_case = "#{share}/petsc/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