forked from ahmadia/homebrew-science
-
Notifications
You must be signed in to change notification settings - Fork 0
/
abinit.rb
113 lines (97 loc) · 3.9 KB
/
abinit.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
class Abinit < Formula
desc "Atomic-scale first-principles simulation software"
homepage "http://www.abinit.org"
url "http://ftp.abinit.org/abinit-8.0.8b.tar.gz"
sha256 "37ad5f0f215d2a36e596383cb6e54de3313842a0390ce8d6b48a423d3ee25af2"
revision 1
# tag "chemistry"
# doi "10.1016/j.cpc.2009.07.007"
bottle do
cellar :any
sha256 "9c99ddd1f1ec9bd49990a49902f245b6203e1f46a292352544c917978a7ce7e2" => :sierra
sha256 "5d202860620d02d4002dbc8d43ad2cae55118752077129a2abc8f6af31d074cf" => :el_capitan
sha256 "643e9c0f20abe93f18a7d89968a37a6b4209b4d7c0c1ba6164a114047bb6d42a" => :yosemite
end
option "with-openmp", "Enable OpenMP multithreading"
option "without-test", "Skip build-time tests (not recommended)"
option "with-testsuite", "Run full test suite (time consuming)"
deprecated_option "without-check" => "without-test"
depends_on :mpi => [:cc, :cxx, :f77, :f90]
depends_on :fortran
depends_on "veclibfort"
depends_on "scalapack" => :recommended
depends_on "fftw" => ["with-mpi", "with-fortran", :recommended]
depends_on "netcdf" => ["with-fortran", :recommended]
depends_on "etsf_io" => :recommended
depends_on "gsl" => :recommended
needs :openmp if build.with? "openmp"
def install
# Environment variables CC, CXX, etc. will be ignored.
ENV.delete "CC"
ENV.delete "CXX"
ENV.delete "F77"
ENV.delete "FC"
args = %W[
CC=#{ENV["MPICC"]}
CXX=#{ENV["MPICXX"]}
F77=#{ENV["MPIF77"]}
FC=#{ENV["MPIFC"]}
--prefix=#{prefix}
--enable-mpi=yes
--with-mpi-prefix=#{HOMEBREW_PREFIX}
--enable-optim=safe
--enable-gw-dpc
--with-dft-flavor=none
]
args << ("--enable-openmp=" + (build.with?("openmp") ? "yes" : "no"))
trio_flavor = "none"
if build.with? "scalapack"
args << "--with-linalg-flavor=custom+scalapack"
args << "--with-linalg-libs=-L#{Formula["veclibfort"].opt_lib} -lvecLibFort -L#{Formula["scalapack"].opt_lib} -lscalapack"
else
args << "--with-linalg-flavor=custom"
args << "--with-linalg-libs=-L#{Formula["veclibfort"].opt_lib} -lvecLibFort"
end
if build.with? "etsf_io"
raise "Building with etsf_io support requires netcdf" if build.without? "netcdf"
trio_flavor = "netcdf+etsf_io"
args << "--with-etsf-io-incs=-I#{Formula["etsf_io"].opt_include}"
args << "--with-etsf-io-libs=-L#{Formula["etsf_io"].opt_lib} -letsf_io_low_level -letsf_io_utils -letsf_io"
args << "--with-netcdf-incs=-I#{Formula["netcdf"].opt_include}"
args << "--with-netcdf-libs=-L#{Formula["netcdf"].opt_lib} -lnetcdff -lnetcdf"
elsif build.with? "netcdf"
trio_flavor = "netcdf"
args << "--with-netcdf-incs=-I#{Formula["netcdf"].opt_include}"
args << "--with-netcdf-libs=-L#{Formula["netcdf"].opt_lib} -lnetcdff -lnetcdf"
end
if build.with? "gsl"
args << "--with-math-flavor=gsl"
args << "--with-math-incs=-I#{Formula["gsl"].opt_include}"
args << "--with-math-libs=-L#{Formula["gsl"].opt_lib} -lgsl"
end
# need to link against single precision as well, see https://trac.macports.org/ticket/45617 and http://forum.abinit.org/viewtopic.php?f=3&t=2631
if build.with? "fftw"
args << "--with-fft-flavor=fftw3"
args << "--with-fft-incs=-I#{Formula["fftw"].opt_include}"
args << "--with-fft-libs=-L#{Formula["fftw"].opt_lib} -lfftw3 -lfftw3f -lfftw3_mpi -lfftw3f_mpi"
end
args << "--with-trio-flavor=#{trio_flavor}"
system "./configure", *args
system "make"
if build.with? "test"
cd "tests"
if build.with? "testsuite"
system "./runtests.py 2>&1 | tee make-check.log"
else
system "./runtests.py built-in fast 2>&1 | tee make-check.log"
end
ohai `grep ", succeeded:" "make-check.log"`.chomp
prefix.install "make-check.log"
cd ".."
end
system "make", "install"
end
test do
system "#{bin}/abinit", "-b"
end
end