forked from ahmadia/homebrew-science
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmumps.rb
111 lines (93 loc) · 3.83 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
require 'formula'
class Mumps < Formula
homepage 'http://mumps.enseeiht.fr'
url 'http://mumps.enseeiht.fr/MUMPS_4.10.0.tar.gz'
mirror 'http://graal.ens-lyon.fr/MUMPS/MUMPS_4.10.0.tar.gz'
sha1 '904b1d816272d99f1f53913cbd4789a5be1838f7'
depends_on 'scotch5' => :optional # Scotch 6 support currently broken.
depends_on 'openblas' => :optional
depends_on :mpi => [:cc, :cxx, :f90, :recommended]
if build.with? 'mpi'
depends_on 'scalapack' => (build.with? 'openblas') ? ['with-openblas'] : :build
end
depends_on 'metis4' => :optional if build.without? :mpi
depends_on :fortran
def install
make_args = ["LIBEXT=.dylib",
"AR=$(FL) -shared -Wl,-install_name -Wl,#{lib}/$(notdir $@) -undefined dynamic_lookup -o ", # Must have a trailing whitespace!
"RANLIB=echo"]
orderingsf = "-Dpord"
makefile = (build.with? :mpi) ? "Makefile.gfortran.PAR" : "Makefile.gfortran.SEQ"
cp "Make.inc/" + makefile, "Makefile.inc"
if build.with? 'scotch5'
make_args += ["SCOTCHDIR=#{Formula['scotch5'].prefix}",
"ISCOTCH=-I#{Formula["scotch5"].include}"]
if build.with? :mpi
make_args << "LSCOTCH=-L$(SCOTCHDIR)/lib -lptesmumps -lptscotch -lptscotcherr"
orderingsf << " -Dptscotch"
else
make_args << "LSCOTCH=-L$(SCOTCHDIR) -lesmumps -lscotch -lscotcherr"
orderingsf << " -Dscotch"
end
end
if build.with? "metis4"
make_args += ["LMETISDIR=#{Formula["metis4"].lib}",
"IMETIS=#{Formula["metis4"].include}",
"LMETIS=-L#{Formula["metis4"].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",
"SCALAP=-L#{Formula["scalapack"].lib} -lscalapack",
"INCPAR=-I#{Formula["open-mpi"].include}",
"LIBPAR=$(SCALAP) -L#{Formula["open-mpi"].lib} -lmpi -lmpi_mpifh"]
else
make_args += ["CC=#{ENV['CC']} -fPIC",
"FC=#{ENV['FC']} -fPIC",
"FL=#{ENV['FC']} -fPIC"]
end
if build.with? 'openblas'
make_args << "LIBBLAS=-L#{Formula["openblas"].lib} -lopenblas"
else
make_args << "LIBBLAS=-lblas -llapack"
end
ENV.deparallelize # Build fails in parallel on Mavericks.
system "make", "all", *make_args
lib.install Dir['lib/*']
if build.with? :mpi
include.install Dir['include/*']
else
lib.install 'libseq/libmpiseq.dylib'
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
(share + 'doc').install Dir['doc/*.pdf']
(share + 'examples').install Dir['examples/*[^.o]']
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
return s
end
def test
cmd = (Tab.for_formula(self).used_options.include? 'without-mpi') ? '' : 'mpirun -np 2'
system "#{cmd} #{share}/examples/ssimpletest < #{share}/examples/input_simpletest_real"
system "#{cmd} #{share}/examples/dsimpletest < #{share}/examples/input_simpletest_real"
system "#{cmd} #{share}/examples/csimpletest < #{share}/examples/input_simpletest_cmplx"
system "#{cmd} #{share}/examples/zsimpletest < #{share}/examples/input_simpletest_cmplx"
system "#{cmd} #{share}/examples/c_example"
ohai "Test results are in ~/Library/Logs/Homebrew/mumps"
end
end