forked from ahmadia/homebrew-science
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabinit.rb
158 lines (138 loc) · 5.57 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
class Abinit < Formula
homepage "http://www.abinit.org"
url "http://ftp.abinit.org/abinit-7.10.2.tar.gz"
sha256 "cbead80096d97f1c8d08ccb3b9b2851ac1e56accaebe551d9ab29757e9cd531e"
revision 1
bottle do
root_url "https://homebrew.bintray.com/bottles-science"
sha256 "c6589a26acfdabb5c90786a35083ac7d69a11dfdd004d656443cd0d3dc62df23" => :yosemite
sha256 "1be9246057cd984978fc0e739f9c73b6739be2ee37ceff21b2f9926f4a5f438a" => :mavericks
sha256 "1e89a2320d9c6edb71d50e44dd16d561694abf0826846e31fb7f5c941e8df501" => :mountain_lion
end
option "without-check", "Skip build-time tests (not recommended)"
option "with-testsuite", "Run full test suite (time consuming)"
depends_on "cmake" => :build
depends_on :python => :build
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 "libxc" => :recommended
depends_on "netcdf" => ["with-fortran", :recommended]
depends_on "gsl" => :recommended
# Patch:
# Correct a bug when NetCDF is used without ETSF_IO library.
# This bug has been committed upstream; to be removed for ABINIT 7.10.4+
patch :DATA
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-openmp=no
--enable-gw-dpc
]
dft_flavor = "none"
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? "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
if build.with? "libxc"
dft_flavor = "libxc"
args << "--with-libxc-incs=-I#{Formula["libxc"].opt_include}"
args << "--with-libxc-libs=-L#{Formula["libxc"].opt_lib} -lxc -lxcf90"
# Patch to make libXC 2.2+ supported by Abinit 7.10;
# libXC 2.2 will be supported in Abinit 8.0
inreplace "configure", "(major != 2) || (minor < 0) || (minor > 1)",
"(major != 2) || (minor < 2) || (minor > 3)"
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-dft-flavor=#{dft_flavor}"
args << "--with-trio-flavor=#{trio_flavor}"
system "./configure", *args
system "make"
if build.with? "check"
cd "tests"
if build.with? "testsuite"
system "./runtests.py -n 3 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
# Eliminate this patch for Abinit v7.10.4+
__END__
diff --git a/src/57_iovars/outvars.F90 b/src/57_iovars/outvars.F90
index 558b783..5ec12f5 100644
--- a/src/57_iovars/outvars.F90
+++ b/src/57_iovars/outvars.F90
@@ -352,7 +352,7 @@ subroutine outvars(choice,dmatpuflag,dtsets,filnam4,iout,&
#if defined HAVE_TRIO_ETSF_IO
call etsf_io_low_close(abs(ncid), lstat)
-#elif defined HAVE_TRIO_NETCDF
+#elif 0
ncerr=nf90_close(ncid)
if (ncerr/=nf90_NoErr) then
message='Netcdf Error while closing the OUT.nc file: '//trim(nf90_strerror(ncerr))
diff --git a/src/57_iovars/write_var_netcdf.F90 b/src/57_iovars/write_var_netcdf.F90
index e0e3400..fe5f190 100644
--- a/src/57_iovars/write_var_netcdf.F90
+++ b/src/57_iovars/write_var_netcdf.F90
@@ -116,7 +116,7 @@ type(etsf_io_low_error) :: error_data
end if
end if
-#elif defined HAVE_TRIO_NETCDF
+#elif 0
if (ncid>0) then
! ### Put the file in definition mode
ncerr=nf90_redef(ncid)
diff --git a/src/94_scfcv/outscfcv.F90 b/src/94_scfcv/outscfcv.F90
index 92fcc52..7d51105 100644
--- a/src/94_scfcv/outscfcv.F90
+++ b/src/94_scfcv/outscfcv.F90
@@ -1080,7 +1080,7 @@ subroutine outscfcv(atindx1,cg,compch_fft,compch_sph,cprj,dimcprj,dtefield,dtfil
if (isalchemical(Crystal)) then
MSG_WARNING("Alchemical pseudos are not supported by ETSF-IO, GSR file won't be produced")
else
-#ifdef HAVE_TRIO_NETCDF
+#ifdef HAVE_TRIO_ETSF_IO
NCF_CHECK(ncfile_create(ncf,fname,NF90_CLOBBER),"Creating GSR file")
call crystal_ncwrite(Crystal,ncf%ncid)
call ebands_ncwrite(Bands,dtset%nshiftk_orig,dtset%shiftk_orig,dtset%nshiftk,dtset%shiftk,dtset%ngkpt,dtset%kptrlatt,ncf%ncid)