homebrew-core/Formula/petsc-complex.rb
2019-10-19 18:39:33 +02: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.12.0.tar.gz"
sha256 "a2a17264a5bbcf9daacae317d2751dae4fef18e641245242ab157ca9fceed019"
bottle do
sha256 "ff1249d8c61098941420538757f5e1fd138e820af9be910467bf1f7bb82ce9d4" => :catalina
sha256 "9bb27b7c4095abf24ca20cca262cf7e1e5011332ea48964f5eb3ceea0e26bd67" => :mojave
sha256 "39321c3becdeb05582bcea6d3ffb58eb9a240a722c7e1e8a57c5c9397eef1c8f" => :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
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