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.11.3.tar.gz" sha256 "8bee4a5ad37af85938ae755be182dcea255888b4f8b3d976bedc57e959280622" revision 2 bottle do sha256 "d24505c95e3a9e5fff871d7d902a7347d21afad81263f47b7af436cc15c3a02f" => :catalina sha256 "a5523aa2e3aa39e59c5b167677f92adeb00c3256c35334ce07a2094d9f3c0f12" => :mojave sha256 "bfb9d19b954a7fbefee250f34e9c1bca91064b98d873f8024a75ce1d19c093e0" => :high_sierra sha256 "361141ddfbbce125ae403f327b5fa5fdd4838b97be5dec04ab907ccace210154" => :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