2017-12-19 14:23:27 +00:00
|
|
|
class Cp2k < Formula
|
|
|
|
desc "Quantum chemistry and solid state physics software package"
|
|
|
|
homepage "https://www.cp2k.org/"
|
|
|
|
url "https://downloads.sourceforge.net/project/cp2k/cp2k-5.1.tar.bz2"
|
|
|
|
sha256 "e23613b593354fa82e0b8410e17d94c607a0b8c6d9b5d843528403ab09904412"
|
2018-01-13 15:27:11 +00:00
|
|
|
revision 1
|
2017-12-19 14:23:27 +00:00
|
|
|
|
2017-12-21 21:19:18 +00:00
|
|
|
bottle do
|
2018-01-13 19:27:56 +00:00
|
|
|
sha256 "85d3a5ad5abc2e16391d30ad91ebe10517652598f17beac62265bd66f67a1eef" => :high_sierra
|
|
|
|
sha256 "9b516e4a0764b18f236a369b8f884d877a4ab08bf4fdfe66a29004f61695116b" => :sierra
|
|
|
|
sha256 "0f1e0c6fd23c666c9b6b253d9c6e035d1e973ea4dd6f65d02211e38be65700c1" => :el_capitan
|
2017-12-21 21:19:18 +00:00
|
|
|
end
|
|
|
|
|
2017-12-19 14:23:27 +00:00
|
|
|
depends_on "fftw"
|
2018-01-13 15:27:11 +00:00
|
|
|
depends_on "gcc" # for gfortran
|
2017-12-19 14:23:27 +00:00
|
|
|
depends_on "libxc"
|
2018-01-13 15:27:11 +00:00
|
|
|
depends_on "open-mpi"
|
2017-12-19 14:23:27 +00:00
|
|
|
depends_on "scalapack"
|
|
|
|
|
2018-01-13 15:27:11 +00:00
|
|
|
fails_with :clang # needs OpenMP support
|
2017-12-19 14:23:27 +00:00
|
|
|
|
|
|
|
resource "libint" do
|
|
|
|
url "https://downloads.sourceforge.net/project/libint/v1-releases/libint-1.1.5.tar.gz"
|
|
|
|
sha256 "31d7dd553c7b1a773863fcddc15ba9358bdcc58f5962c9fcee1cd24f309c4198"
|
|
|
|
end
|
|
|
|
|
|
|
|
def install
|
|
|
|
resource("libint").stage do
|
|
|
|
system "./configure", "--prefix=#{libexec}"
|
|
|
|
system "make"
|
2018-01-13 15:27:11 +00:00
|
|
|
ENV.deparallelize { system "make", "install" }
|
2017-12-19 14:23:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
fcflags = %W[
|
|
|
|
-I#{Formula["libxc"].opt_include}
|
|
|
|
-I#{Formula["fftw"].opt_include}
|
|
|
|
-I#{libexec}/include
|
|
|
|
]
|
|
|
|
|
|
|
|
libs = %W[
|
|
|
|
-L#{Formula["libxc"].opt_lib}
|
|
|
|
-lxcf90
|
|
|
|
-lxc
|
|
|
|
-L#{libexec}/lib
|
|
|
|
-lderiv
|
|
|
|
-lint
|
|
|
|
-L#{Formula["fftw"].opt_lib}
|
|
|
|
-lfftw3
|
|
|
|
]
|
|
|
|
|
|
|
|
# CP2K configuration is done through editing of arch files
|
|
|
|
inreplace Dir["arch/Darwin-IntelMacintosh-gfortran.*"].each do |s|
|
|
|
|
s.gsub! /DFLAGS *=/, "DFLAGS = -D__LIBXC -D__FFTW3 -D__LIBINT"
|
|
|
|
s.gsub! /FCFLAGS *=/, "FCFLAGS = #{fcflags.join(" ")}"
|
|
|
|
s.gsub! /LIBS *=/, "LIBS = #{libs.join(" ")}"
|
|
|
|
end
|
|
|
|
|
|
|
|
# MPI versions link to scalapack
|
|
|
|
inreplace Dir["arch/Darwin-IntelMacintosh-gfortran.p*"],
|
|
|
|
/LIBS *=/, "LIBS = -L#{Formula["scalapack"].opt_prefix}/lib"
|
|
|
|
|
|
|
|
# OpenMP versions link to specific fftw3 library
|
|
|
|
inreplace Dir["arch/Darwin-IntelMacintosh-gfortran.*smp"],
|
|
|
|
"-lfftw3", "-lfftw3 -lfftw3_threads"
|
|
|
|
|
|
|
|
# Now we build
|
|
|
|
cd "makefiles" do
|
|
|
|
%w[sopt ssmp popt psmp].each do |exe|
|
|
|
|
system "make", "ARCH=Darwin-IntelMacintosh-gfortran", "VERSION=#{exe}"
|
|
|
|
bin.install "../exe/Darwin-IntelMacintosh-gfortran/cp2k.#{exe}"
|
|
|
|
bin.install "../exe/Darwin-IntelMacintosh-gfortran/cp2k_shell.#{exe}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
(pkgshare/"tests").install "tests/Fist/water512.inp"
|
|
|
|
end
|
|
|
|
|
|
|
|
test do
|
|
|
|
system "#{bin}/cp2k.sopt", "#{pkgshare}/tests/water512.inp"
|
|
|
|
system "#{bin}/cp2k.ssmp", "#{pkgshare}/tests/water512.inp"
|
|
|
|
system "mpirun", "#{bin}/cp2k.popt", "#{pkgshare}/tests/water512.inp"
|
|
|
|
system "mpirun", "#{bin}/cp2k.psmp", "#{pkgshare}/tests/water512.inp"
|
|
|
|
end
|
|
|
|
end
|