<commit_before>require 'formula'

class Petsc < Formula
  homepage 'http://www.mcs.anl.gov/petsc/index.html'
  url 'http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-lite-3.4.4.tar.gz'
  sha1 '2f507195a3142eb0599e78a909446175a597480a'
  head 'https://bitbucket.org/petsc/petsc', :using => :git

  option 'without-check', 'Skip build-time tests (not recommended)'

  depends_on :mpi => :cc
  depends_on :fortran
  depends_on :x11 => :optional

  def install
    ENV.deparallelize

    petsc_arch = 'arch-darwin-c-opt'
    args = ["--with-debugging=0", "--with-shared-libraries=1", "--prefix=#{prefix}/#{petsc_arch}"]
    args << "--with-x=0" if build.without? 'x11'
    ENV['PETSC_DIR'] = Dir.getwd  # configure fails if those vars are set differently.
    ENV['PETSC_ARCH'] = petsc_arch
    system "./configure", *args
    system "make all"
    system "make test" if build.with? "check"
    system "make install"

    # Link only what we want.
    include.install_symlink Dir["#{prefix}/#{petsc_arch}/include/*h"], "#{prefix}/#{petsc_arch}/include/finclude", "#{prefix}/#{petsc_arch}/include/petsc-private"
    prefix.install_symlink "#{prefix}/#{petsc_arch}/conf"
    lib.install_symlink Dir["#{prefix}/#{petsc_arch}/lib/*.a"], Dir["#{prefix}/#{petsc_arch}/lib/*.dylib"]
    share.install_symlink Dir["#{prefix}/#{petsc_arch}/share/*"]
  end

  def caveats; <<-EOS
    Set PETSC_DIR to #{prefix}
    and PETSC_ARCH to arch-darwin-c-opt.
    Fortran module files are in #{prefix}/arch-darwin-c-opt/include.
    EOS
  end
end<commit_msg>Petsc 3.5.2<commit_after>require "formula"

class Petsc < Formula
  homepage "http://www.mcs.anl.gov/petsc/index.html"
  url "http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-lite-3.5.2.tar.gz"
  sha1 "d60d1735762f2e398774514451e137580bb2c7bb"
  head "https://bitbucket.org/petsc/petsc", :using => :git

  option "without-check", "Skip build-time tests (not recommended)"
  option "complex", "Use complex version by default. Otherwise, real-valued version will be symlinked"
  option "debug", "Compile debug version"

  depends_on :mpi => :cc
  depends_on :fortran
  depends_on :x11 => :optional
  depends_on "cmake" => :build

  depends_on "openssl"
  depends_on "superlu_dist" => :recommended
  depends_on "metis"        => :recommended
  depends_on "parmetis"     => :recommended
  depends_on "scalapack"    => :recommended
  depends_on "mumps"        => :recommended
  depends_on "hypre"        => :optional  #compile error here

  def install
    ENV.deparallelize

    petsc_arch_real="real"
    petsc_arch_complex="complex"

    args = %W[
      --with-shared-libraries=1
    ]
    args << ( (build.include? "debug") ? "--with-debugging=1" : "--with-debugging=0" )

    args << "--with-superlu_dist-include=#{Formula["superlu_dist"].include}/superlu_dist" << "--with-superlu_dist-lib=#{Formula["superlu_dist"].lib}/libsuperlu_dist.a" if build.with? "superlu_dist"
    args << "--with-metis-dir=#{Formula["metis"].prefix}" if build.with? "metis"
    args << "--with-parmetis-dir=#{Formula["parmetis"].prefix}" if build.with? "parmetis"
    args << "--with-scalapack-dir=#{Formula["scalapack"].prefix}" if build.with? "scalapack"
    args << "--with-mumps-dir=#{Formula["mumps"].prefix}" if build.with? "mumps"
    args << "--with-x=0" if build.without? "x11"

    ENV["PETSC_DIR"] = Dir.getwd  # configure fails if those vars are set differently.

    # real-valued case:
    ENV["PETSC_ARCH"] = petsc_arch_real
    system "./configure", *args, "--prefix=#{prefix}/#{petsc_arch_real}", "--with-scalar-type=real", ("--with-hypre-dir=#{Formula["hypre"].prefix}" if build.with? "hypre")
    system "make all"
    system "make test" if build.with? "check"
    system "make install"

    # complex-valued case:
    ENV["PETSC_ARCH"] = petsc_arch_complex
    system "./configure", *args, "--prefix=#{prefix}/#{petsc_arch_complex}", "--with-scalar-type=complex"
    system "make all"
    system "make test" if build.with? "check"
    system "make install"

    # Link only what we want.
    petsc_arch = ((build.include? "complex") ? petsc_arch_complex : petsc_arch_real)

    include.install_symlink Dir["#{prefix}/#{petsc_arch}/include/*h"], "#{prefix}/#{petsc_arch}/include/finclude", "#{prefix}/#{petsc_arch}/include/petsc-private"
    prefix.install_symlink "#{prefix}/#{petsc_arch}/conf"
    lib.install_symlink Dir["#{prefix}/#{petsc_arch}/lib/*.a"], Dir["#{prefix}/#{petsc_arch}/lib/*.dylib"]
    share.install_symlink Dir["#{prefix}/#{petsc_arch}/share/*"]
  end

  def caveats; <<-EOS
    Set PETSC_DIR to #{prefix}/real or #{prefix}/complex.
    Fortran module files are in #{prefix}/real/include and #{prefix}/complex/include
    EOS
  end
end
{'fraction_non_alphanumeric': 0.1742826780021254, 'fraction_numerical': 0.018703506907545166, 'mean_word_length': 3.9174503657262276, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 16, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6016460', 'n_tokens_mistral': 1753, 'n_tokens_neox': 1701, 'n_words': 324}