-
Notifications
You must be signed in to change notification settings - Fork 1
/
mumps.rb
184 lines (159 loc) · 7.23 KB
/
mumps.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
require_relative "requirements/blas_requirement"
class Mumps < Formula
desc "Parallel Sparse Direct Solver"
homepage "http://mumps-solver.org"
url "http://mumps.enseeiht.fr/MUMPS_5.0.1.tar.gz"
mirror "http://graal.ens-lyon.fr/MUMPS/MUMPS_5.0.1.tar.gz"
sha256 "50355b2e67873e2239b4998a46f2bbf83f70cdad6517730ab287ae3aae9340a0"
revision 1
bottle do
cellar :any
sha256 "3775325ee7e6e8d2506023cb32adea9a13aec34760fffd7768b31be14e5c2987" => :yosemite
sha256 "77df4c32a5262bd7d8b49ec8b32cb8e1384e11e8139cc1e5bdb43720f17d4f46" => :mavericks
sha256 "d3de4a5d9a53c417139472a511211531bf5ce2b6b856622444d68629c15fb918" => :mountain_lion
end
depends_on :mpi => [:cc, :cxx, :f90, :recommended]
depends_on "scalapack" if build.with? "mpi"
depends_on "metis" => :optional if build.without? "mpi"
depends_on "parmetis" => :optional if build.with? "mpi"
#-depends_on "scotch5" => :optional
#-depends_on "scotch" => :optional
depends_on BlasRequirement
depends_on :fortran
resource "mumps_simple" do
url "https://github.com/dpo/mumps_simple/archive/v0.4.tar.gz"
sha256 "87d1fc87eb04cfa1cba0ca0a18f051b348a93b0b2c2e97279b23994664ee437e"
end
def install
if OS.mac?
# Building dylibs with mpif90 causes segfaults on 10.8 and 10.10. Use gfortran.
make_args = ["LIBEXT=.dylib",
"AR=#{ENV["FC"]} -dynamiclib -Wl,-install_name -Wl,#{opt_prefix}/lib/$(notdir $@) -undefined dynamic_lookup -o ",
"RANLIB=echo"]
else
make_args = ["LIBEXT=.so", "AR=$(FL) -shared -Wl,-soname -Wl,#{opt_prefix}/lib/$(notdir $@) -o ", "RANLIB=echo"]
end
make_args += ["OPTF=-O", "CDEFS=-DAdd_"]
orderingsf = "-Dpord"
makefile = (build.with? "mpi") ? "Makefile.G95.PAR" : "Makefile.G95.SEQ"
cp "Make.inc/" + makefile, "Makefile.inc"
if build.with? "scotch5"
make_args += ["SCOTCHDIR=#{Formula["scotch5"].opt_prefix}",
"ISCOTCH=-I#{Formula["scotch5"].opt_include}"]
if build.with? "mpi"
scotch_libs = "LSCOTCH=-L$(SCOTCHDIR)/lib -lptesmumps -lptscotch -lptscotcherr"
scotch_libs += " -lptscotchparmetis" if build.with? "parmetis"
make_args << scotch_libs
orderingsf << " -Dptscotch"
else
scotch_libs = "LSCOTCH=-L$(SCOTCHDIR) -lesmumps -lscotch -lscotcherr"
scotch_libs += " -lscotchmetis" if build.with? "metis"
make_args << scotch_libs
orderingsf << " -Dscotch"
end
elsif build.with? "scotch"
make_args += ["SCOTCHDIR=#{Formula["scotch"].opt_prefix}",
"ISCOTCH=-I#{Formula["scotch"].opt_include}"]
if build.with? "mpi"
scotch_libs = "LSCOTCH=-L$(SCOTCHDIR)/lib -lptscotch -lptscotcherr -lptscotcherrexit -lscotch"
scotch_libs += "-lptscotchparmetis" if build.with? "parmetis"
make_args << scotch_libs
orderingsf << " -Dptscotch"
else
scotch_libs = "LSCOTCH=-L$(SCOTCHDIR) -lscotch -lscotcherr -lscotcherrexit"
scotch_libs += "-lscotchmetis" if build.with? "metis"
make_args << scotch_libs
orderingsf << " -Dscotch"
end
end
if build.with? "parmetis"
make_args += ["LMETISDIR=#{Formula["parmetis"].opt_lib}",
"IMETIS=#{Formula["parmetis"].opt_include}",
"LMETIS=-L#{Formula["parmetis"].opt_lib} -lparmetis -L#{Formula["metis"].opt_lib} -lmetis"]
orderingsf << " -Dparmetis"
elsif build.with? "metis"
make_args += ["LMETISDIR=#{Formula["metis"].opt_lib}",
"IMETIS=#{Formula["metis"].opt_include}",
"LMETIS=-L#{Formula["metis"].opt_lib} -lmetis"]
orderingsf << " -Dmetis"
end
make_args << "ORDERINGSF=#{orderingsf}"
if build.with? "mpi"
make_args += ["CC=#{ENV["MPICC"]} -fPIC",
"FC=#{ENV["MPIFC"]} -fPIC",
"FL=#{ENV["MPIFC"]} -fPIC",
"INCPAR=", # Let MPI compilers fill in the blanks.
"LIBPAR=$(SCALAP)"]
make_args += ["SCALAP=-L#{Formula["scalapack"].opt_lib} -Wl,-rpath,#{Formula["scalapack"].opt_lib} -lscalapack"]
else
make_args += ["CC=#{ENV["CC"]} -fPIC",
"FC=#{ENV["FC"]} -fPIC",
"FL=#{ENV["FC"]} -fPIC"]
end
ldflags = BlasRequirement.ldflags(ENV["HOMEBREW_BLASLAPACK_LIB"],ENV["HOMEBREW_BLASLAPACK_NAMES"],ENV["HOMEBREW_BLASLAPACK_EXTRA"])
make_args << "LIBBLAS=#{ldflags}"
ENV.deparallelize # Build fails in parallel on Mavericks.
# First build libs, install them, and then link example programs.
system "make", "alllib", *make_args
lib.install Dir["lib/*"]
lib.install ("libseq/libmpiseq" + ((OS.mac?) ? ".dylib" : ".so")) if build.without? "mpi"
inreplace "examples/Makefile" do |s|
s.change_make_var! "libdir", lib
end
system "make", "all", *make_args # Build examples.
if build.with? "mpi"
include.install Dir["include/*"]
else
libexec.install "include"
include.install_symlink Dir[libexec / "include/*"]
# The following .h files may conflict with others related to MPI
# in /usr/local/include. Do not symlink them.
(libexec / "include").install Dir["libseq/*.h"]
end
doc.install Dir["doc/*.pdf"]
(pkgshare + "examples").install Dir["examples/*[^.o]"]
prefix.install "Makefile.inc" # For the record.
File.open(prefix / "make_args.txt", "w") do |f|
f.puts(make_args.join(" ")) # Record options passed to make.
end
if build.with? "mpi"
resource("mumps_simple").stage do
simple_args = ["CC=#{ENV["MPICC"]}", "prefix=#{prefix}", "mumps_prefix=#{prefix}"]
simple_args +=["scalapack_libdir=#{Formula["scalapack"].opt_lib}"]
if build.with? "scotch5"
simple_args += ["scotch_libdir=#{Formula["scotch5"].opt_lib}",
"scotch_libs=-L$(scotch_libdir) -lptesmumps -lptscotch -lptscotcherr"]
elsif build.with? "scotch"
simple_args += ["scotch_libdir=#{Formula["scotch"].opt_lib}",
"scotch_libs=-L$(scotch_libdir) -lptscotch -lptscotcherr -lscotch"]
end
blas_lib = ENV["HOMEBREW_BLASLAPACK_LIB"]
simple_args += ["blas_libdir=#{blas_lib}",
"blas_libs=#{ldflags}"]
system "make", "SHELL=/bin/bash", *simple_args
lib.install ("libmumps_simple." + ((OS.mac?) ? "dylib" : "so"))
include.install "mumps_simple.h"
end
end
end
def caveats
s = ""
if build.without? "mpi"
s += <<-EOS.undent
You built a sequential MUMPS library.
Please add #{libexec}/include to the include path
when building software that depends on MUMPS.
EOS
end
s
end
test do
cmd = build.without?("mpi") ? "" : "mpirun -np 2"
system "#{cmd} #{pkgshare}/examples/ssimpletest < #{pkgshare}/examples/input_simpletest_real"
system "#{cmd} #{pkgshare}/examples/dsimpletest < #{pkgshare}/examples/input_simpletest_real"
system "#{cmd} #{pkgshare}/examples/csimpletest < #{pkgshare}/examples/input_simpletest_cmplx"
system "#{cmd} #{pkgshare}/examples/zsimpletest < #{pkgshare}/examples/input_simpletest_cmplx"
system "#{cmd} #{pkgshare}/examples/c_example"
ohai "Test results are in ~/Library/Logs/Homebrew/mumps"
end
end