-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmumps-seq.rb
136 lines (116 loc) · 5.59 KB
/
mumps-seq.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
class MumpsSeq < Formula
desc "Sequential Sparse Direct Solver"
homepage "http://mumps-solver.org"
url "https://graal.ens-lyon.fr/MUMPS/MUMPS_5.5.1.tar.gz"
mirror "http://mumps.enseeiht.fr/MUMPS_5.5.1.tar.gz"
sha256 "1abff294fa47ee4cfd50dfd5c595942b72ebfcedce08142a75a99ab35014fa15"
revision 1
bottle do
root_url "https://github.com/coin-or-tools/homebrew-coinor/releases/download/mumps-seq-5.5.1_1"
sha256 cellar: :any, arm64_sonoma: "a9f2c8660ad094f56d44bde66d9f6200a79354c521ebe8d2d14c1d21428d007a"
sha256 cellar: :any, ventura: "37a08558c70b1458be6bcb41645bacd870aac2f00030b34f3fd33e4eeedf966f"
sha256 cellar: :any_skip_relocation, x86_64_linux: "b7cfca4980b2ff8deab1deb97f10f641724f1bad016a6950a7faaa159544cd81"
end
keg_only "conflicts with parallel builds of MUMPS"
depends_on "gcc"
depends_on "metis"
depends_on "openblas" => :recommended
fails_with :clang # because we use OpenMP
def install
# MUMPS >= 5.3.4 does not compile with gfortran10. Allow some errors to go through.
# see https://listes.ens-lyon.fr/sympa/arc/mumps-users/2020-10/msg00002.html
make_args = ["RANLIB=echo", "CDEFS=-DAdd_"]
optf = ["OPTF=-O3"]
gcc_major_ver = Formula["gcc"].any_installed_version.major
optf << "-fallow-argument-mismatch" if gcc_major_ver >= 10
make_args << optf.join(" ")
makefile = "Makefile.G95.SEQ"
cp "Make.inc/" + makefile, "Makefile.inc"
lib_args = []
metis_libs = ["-L#{Formula["metis"].opt_lib}", "-lmetis"]
make_args += ["LMETISDIR=#{Formula["metis"].opt_lib}",
"IMETIS=-I#{Formula["metis"].opt_include}",
"LMETIS=#{metis_libs.join(" ")}"]
lib_args += metis_libs
orderingsf = "-Dpord"
orderingsf << " -Dmetis"
make_args << "ORDERINGSF=#{orderingsf}"
make_args += ["CC=gcc -fPIC",
"FC=gfortran -fPIC",
"FL=gfortran -fPIC"]
blas_lib = ["-L#{Formula["openblas"].opt_lib}", "-lopenblas"]
make_args << "LIBBLAS=#{blas_lib.join(" ")}"
make_args << "LAPACK=#{blas_lib.join(" ")}"
lib_args += blas_lib
ENV.deparallelize
system "make", "all", *make_args
# make shared lib
so = OS.mac? ? "dylib" : "so"
all_load = OS.mac? ? "-all_load" : "--whole-archive"
noall_load = OS.mac? ? "" : "--no-whole-archive"
shopts = OS.mac? ? ["-undefined", "dynamic_lookup"] : []
install_name = ->(libname) { OS.mac? ? ["-Wl,-install_name", "-Wl,#{lib}/#{libname}.#{so}"] : [] }
cd "lib" do
libpord_install_name = install_name.call("libpord")
system "gfortran", "-fPIC", "-shared", "-Wl,#{all_load}", "libpord.a", *lib_args, \
"-Wl,#{noall_load}", *libpord_install_name, *shopts, "-o", "libpord.#{so}"
lib.install "libpord.#{so}"
libmumps_common_install_name = install_name.call("libmumps_common")
system "gfortran", "-fPIC", "-shared", "-Wl,#{all_load}", "libmumps_common.a", *lib_args, \
"-L#{lib}", "-lpord", "-Wl,#{noall_load}", *libmumps_common_install_name, \
*shopts, "-o", "libmumps_common.#{so}"
lib.install "libmumps_common.#{so}"
%w[libsmumps libdmumps libcmumps libzmumps].each do |l|
libinstall_name = install_name.call(l)
system "gfortran", "-fPIC", "-shared", "-Wl,#{all_load}", "#{l}.a", *lib_args, \
"-L#{lib}", "-lpord", "-lmumps_common", "-Wl,#{noall_load}", *libinstall_name, \
*shopts, "-o", "#{l}.#{so}"
lib.install "#{l}.#{so}"
end
end
cd "libseq" do
libmpiseq_install_name = install_name.call("libmpiseq")
system "gfortran", "-fPIC", "-shared", "-Wl,#{all_load}", "libmpiseq.a", *lib_args, \
"-Wl,#{noall_load}", *libmpiseq_install_name, *shopts, "-o", "libmpiseq.#{so}"
lib.install "libmpiseq.#{so}"
end
inreplace "examples/Makefile" do |s|
s.change_make_var! "libdir", lib
end
libexec.install "include"
(libexec/"include").install Dir["libseq/*.h"]
include.install_symlink Dir[libexec/"include/*"]
doc.install Dir["doc/*.pdf"]
pkgshare.install "examples"
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
end
test do
ENV.prepend_path "LD_LIBRARY_PATH", lib unless OS.mac?
cp_r pkgshare/"examples", testpath
opts = ["-fopenmp"]
includes = "-I#{opt_include}"
ENV.prepend_path "LD_LIBRARY_PATH", Formula["metis"].opt_lib unless OS.mac?
opts << "-L#{Formula["metis"].opt_lib}" << "-lmetis"
opts << "-lmumps_common" << "-lpord" << "-lmpiseq"
opts << "-L#{Formula["openblas"].opt_lib}" << "-lopenblas"
cd testpath/"examples" do
system "gfortran", "-o", "ssimpletest", "ssimpletest.F", "-L#{opt_lib}", "-lsmumps", includes, *opts
system "./ssimpletest < input_simpletest_real"
system "gfortran", "-o", "dsimpletest", "dsimpletest.F", "-L#{opt_lib}", "-ldmumps", includes, *opts
system "./dsimpletest < input_simpletest_real"
system "gfortran", "-o", "csimpletest", "csimpletest.F", "-L#{opt_lib}", "-lcmumps", includes, *opts
system "./csimpletest < input_simpletest_cmplx"
system "gfortran", "-o", "zsimpletest", "zsimpletest.F", "-L#{opt_lib}", "-lzmumps", includes, *opts
system "./zsimpletest < input_simpletest_cmplx"
if OS.mac?
# fails on linux: gcc-5 not found
system ENV.cc, "-c", "c_example.c", includes
system "gfortran", "-o", "c_example", "c_example.o", "-L#{opt_lib}", "-ldmumps", *opts
system "./c_example", *opts
end
end
end
end