forked from ahmadia/homebrew-science
-
Notifications
You must be signed in to change notification settings - Fork 0
/
abinit.rb
114 lines (97 loc) · 3.64 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
114
class Abinit < Formula
desc "Atomic-scale first-principles simulation software"
homepage "https://www.abinit.org/"
url "https://www.abinit.org/sites/default/files/packages/abinit-8.4.4.tar.gz"
sha256 "ebf63b842810c65d83939cf04058d7bdedc9874ee662f59af45cb29de41e2a8c"
revision 1
# tag "chemistry"
# doi "10.1016/j.cpc.2009.07.007"
bottle :disable, "needs to be rebuilt with latest open-mpi"
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 "fftw" => ["with-mpi", "with-fortran", :recommended]
depends_on "netcdf" => :recommended
depends_on "gsl" => :recommended
if OS.mac?
depends_on "veclibfort"
depends_on "scalapack" => :recommended
end
needs :openmp if build.with? "openmp"
def install
if OS.mac?
# call random_seed(put=seed)
# Error: Size of 'put' argument of 'random_seed' intrinsic at (1) too small (12/33)
# Reported upstream: https://forum.abinit.org/viewtopic.php?f=3&t=3615
inreplace "src/67_common/m_vcoul.F90", "integer :: seed(12)=0", "integer :: seed(33)=0"
inreplace "src/67_common/m_vcoul.F90", "do i1=1,12", "do i1=1,33"
end
# 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 OS.mac?
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
else
args << "--with-linalg-flavor=none"
end
if 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