gnu: Edit synopses of petsc packages.
[jackhill/guix/guix.git] / gnu / packages / maths.scm
CommitLineData
8f8b2451 1;;; GNU Guix --- Functional package management for GNU
06ed5982 2;;; Copyright © 2013, 2014 Andreas Enge <andreas@enge.fr>
da95c817 3;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
668c06ac 4;;; Copyright © 2014 John Darrington <jmd@gnu.org>
f5d5a346 5;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
8f8b2451
AE
6;;;
7;;; This file is part of GNU Guix.
8;;;
9;;; GNU Guix is free software; you can redistribute it and/or modify it
10;;; under the terms of the GNU General Public License as published by
11;;; the Free Software Foundation; either version 3 of the License, or (at
12;;; your option) any later version.
13;;;
14;;; GNU Guix is distributed in the hope that it will be useful, but
15;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17;;; GNU General Public License for more details.
18;;;
19;;; You should have received a copy of the GNU General Public License
20;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21
22(define-module (gnu packages maths)
23 #:use-module (gnu packages)
24 #:use-module ((guix licenses)
25 #:renamer (symbol-prefix-proc 'license:))
26 #:use-module (guix packages)
27 #:use-module (guix download)
0e2672ae 28 #:use-module (guix utils)
da95c817 29 #:use-module (guix build-system cmake)
c9dfa3c7 30 #:use-module (guix build-system gnu)
3de01d3f
EB
31 #:use-module (gnu packages algebra)
32 #:use-module (gnu packages bison)
33 #:use-module (gnu packages cmake)
c9dfa3c7 34 #:use-module (gnu packages compression)
668c06ac 35 #:use-module (gnu packages curl)
57e544e8 36 #:use-module (gnu packages elf)
3de01d3f 37 #:use-module (gnu packages flex)
668c06ac 38 #:use-module (gnu packages fltk)
f3929800 39 #:use-module (gnu packages fontutils)
1dba6407 40 #:use-module (gnu packages gettext)
da95c817 41 #:use-module (gnu packages gcc)
73fed4f8 42 #:use-module (gnu packages gd)
668c06ac 43 #:use-module (gnu packages ghostscript)
f3929800 44 #:use-module (gnu packages gtk)
668c06ac
JD
45 #:use-module (gnu packages less)
46 #:use-module (gnu packages xorg)
47 #:use-module (gnu packages gl)
d8c7eeb9 48 #:use-module (gnu packages mpi)
b92eee75 49 #:use-module (gnu packages multiprecision)
668c06ac 50 #:use-module (gnu packages pcre)
c9dfa3c7
AE
51 #:use-module (gnu packages perl)
52 #:use-module (gnu packages pkg-config)
da95c817 53 #:use-module (gnu packages python)
c9dfa3c7 54 #:use-module (gnu packages readline)
183e44ae 55 #:use-module (gnu packages tcsh)
668c06ac 56 #:use-module (gnu packages texinfo)
73fed4f8 57 #:use-module (gnu packages texlive)
c9dfa3c7 58 #:use-module (gnu packages xml))
8f8b2451
AE
59
60(define-public units
61 (package
62 (name "units")
983815c8 63 (version "2.11")
8f8b2451
AE
64 (source (origin
65 (method url-fetch)
66 (uri (string-append "mirror://gnu/units/units-" version
67 ".tar.gz"))
68 (sha256 (base32
983815c8 69 "1gjs3wc212aaiq4r76hx9nl1h3fa39n0ljwl9420d6ixl3rdmdjk"))))
8f8b2451
AE
70 (build-system gnu-build-system)
71 (synopsis "Conversion between thousands of scales")
72 (description
574e86f9
LC
73 "GNU Units converts numeric quantities between units of measure. It
74can handle scale changes through adaptive usage of standard scale prefixes
75(micro-, kilo-, etc.). It can also handle nonlinear conversions such as
76Fahrenheit to Celsius. Its interpreter is powerful enough to be used
77effectively as a scientific calculator.")
8f8b2451
AE
78 (license license:gpl3+)
79 (home-page "http://www.gnu.org/software/units/")))
c9dfa3c7 80
88bd1804
AE
81(define-public gsl
82 (package
83 (name "gsl")
487da565 84 (version "1.16")
88bd1804
AE
85 (source
86 (origin
87 (method url-fetch)
88 (uri (string-append "mirror://gnu/gsl/gsl-"
89 version ".tar.gz"))
90 (sha256
91 (base32
487da565 92 "0lrgipi0z6559jqh82yx8n4xgnxkhzj46v96dl77hahdp58jzg3k"))))
88bd1804 93 (build-system gnu-build-system)
71e0f288 94 (arguments
487da565
AE
95 `(#:parallel-tests? #f
96 #:phases
71e0f288
AE
97 (alist-replace
98 'configure
99 (lambda* (#:key target system outputs #:allow-other-keys #:rest args)
100 (let ((configure (assoc-ref %standard-phases 'configure)))
101 ;; disable numerically unstable test on i686, see thread at
102 ;; http://lists.gnu.org/archive/html/bug-gsl/2011-11/msg00019.html
103 (if (string=? (or target system) "i686-linux")
104 (substitute* "ode-initval2/Makefile.in"
105 (("TESTS = \\$\\(check_PROGRAMS\\)") "TESTS =")))
106 (apply configure args)))
107 %standard-phases)))
88bd1804
AE
108 (home-page "http://www.gnu.org/software/gsl/")
109 (synopsis "Numerical library for C and C++")
110 (description
a22dc0c4
LC
111 "The GNU Scientific Library is a library for numerical analysis in C
112and C++. It includes a wide range of mathematical routines, with over 1000
113functions in total. Subject areas covered by the library include:
114differential equations, linear algebra, Fast Fourier Transforms and random
115numbers.")
88bd1804
AE
116 (license license:gpl3+)))
117
b92eee75
AE
118(define-public glpk
119 (package
120 (name "glpk")
1f1c0aff 121 (version "4.54")
b92eee75
AE
122 (source
123 (origin
124 (method url-fetch)
125 (uri (string-append "mirror://gnu/glpk/glpk-"
126 version ".tar.gz"))
127 (sha256
128 (base32
1f1c0aff 129 "18gr2anv8gyps6j9f22k7li6w07glvww666sdqblvlq2hh3whwmb"))))
b92eee75
AE
130 (build-system gnu-build-system)
131 (inputs
132 `(("gmp" ,gmp)))
133 (arguments
134 `(#:configure-flags '("--with-gmp")))
135 (home-page "http://www.gnu.org/software/glpk/")
79c311b8 136 (synopsis "GNU Linear Programming Kit, supporting the MathProg language")
b92eee75
AE
137 (description
138 "GLPK is a C library for solving large-scale linear programming (LP),
139mixed integer programming (MIP), and other related problems. It supports the
140GNU MathProg modeling language, a subset of the AMPL language, and features a
141translator for the language. In addition to the C library, a stand-alone
142LP/MIP solver is included in the package.")
143 (license license:gpl3+)))
144
c9dfa3c7
AE
145(define-public pspp
146 (package
147 (name "pspp")
7e0c23fb 148 (version "0.8.3")
c9dfa3c7
AE
149 (source
150 (origin
151 (method url-fetch)
152 (uri (string-append "mirror://gnu/pspp/pspp-"
153 version ".tar.gz"))
154 (sha256
155 (base32
7e0c23fb 156 "0vri2pzvmm38qaihfvwlry30f40lcnps4blg59ixic4q20ldxf5d"))))
c9dfa3c7
AE
157 (build-system gnu-build-system)
158 (inputs
f3929800
AE
159 `(("cairo" ,cairo)
160 ("fontconfig" ,fontconfig)
1dba6407 161 ("gettext" ,gnu-gettext)
c9dfa3c7
AE
162 ("gsl" ,gsl)
163 ("libxml2" ,libxml2)
f3929800 164 ("pango" ,pango)
c9dfa3c7 165 ("readline" ,readline)
e6a5ce8e
JD
166 ("gtk" ,gtk+-2)
167 ("gtksourceview" ,gtksourceview)
c9dfa3c7
AE
168 ("zlib" ,zlib)))
169 (native-inputs
170 `(("perl" ,perl)
171 ("pkg-config" ,pkg-config)))
c9dfa3c7
AE
172 (home-page "http://www.gnu.org/software/pspp/")
173 (synopsis "Statistical analysis")
174 (description
79c311b8
LC
175 "GNU PSPP is a statistical analysis program. It can perform
176descriptive statistics, T-tests, linear regression and non-parametric tests.
177It features both a graphical interface as well as command-line input. PSPP is
178designed to interoperate with Gnumeric, LibreOffice and OpenOffice. Data can
179be imported from spreadsheets, text files and database sources and it can be
180output in text, PostScript, PDF or HTML.")
c9dfa3c7 181 (license license:gpl3+)))
da95c817
NK
182
183(define-public lapack
184 (package
185 (name "lapack")
566146ab 186 (version "3.5.0")
da95c817
NK
187 (source
188 (origin
189 (method url-fetch)
190 (uri (string-append "http://www.netlib.org/lapack/lapack-"
191 version ".tgz"))
192 (sha256
193 (base32
566146ab 194 "0lk3f97i9imqascnlf6wr5mjpyxqcdj73pgj97dj2mgvyg9z1n4s"))))
da95c817
NK
195 (build-system cmake-build-system)
196 (home-page "http://www.netlib.org/lapack/")
57e544e8 197 (native-inputs `(("patchelf" ,patchelf))) ;for augment-rpath
da95c817
NK
198 (inputs `(("fortran" ,gfortran-4.8)
199 ("python" ,python-2)))
200 (arguments
06ed5982 201 `(#:configure-flags '("-DBUILD_SHARED_LIBS:BOOL=YES")
da95c817 202 #:phases (alist-cons-before
6a995754
LC
203 'check 'patch-python
204 (lambda* (#:key inputs #:allow-other-keys)
205 (let ((python (assoc-ref inputs "python")))
206 (substitute* "lapack_testing.py"
207 (("/usr/bin/env python") python))))
06ed5982 208 %standard-phases)))
da95c817
NK
209 (synopsis "Library for numerical linear algebra")
210 (description
211 "LAPACK is a Fortran 90 library for solving the most commonly occurring
212problems in numerical linear algebra.")
213 (license (license:bsd-style "file://LICENSE"
214 "See LICENSE in the distribution."))))
73fed4f8
JD
215
216(define-public gnuplot
217 (package
218 (name "gnuplot")
219 (version "4.6.3")
220 (source
221 (origin
222 (method url-fetch)
223 (uri (string-append "mirror://sourceforge/gnuplot/gnuplot/"
224 version "/gnuplot-" version ".tar.gz"))
225 (sha256
226 (base32
227 "1xd7gqdhlk7k1p9yyqf9vkk811nadc7m4si0q3nb6cpv4pxglpyz"))))
228 (build-system gnu-build-system)
229 (inputs `(("readline" ,readline)
230 ("cairo" ,cairo)
231 ("pango" ,pango)
232 ("gd" ,gd)))
233 (native-inputs `(("texlive" ,texlive)
234 ("pkg-config" ,pkg-config)))
235 (home-page "http://www.gnuplot.info")
236 (synopsis "Command-line driven graphing utility")
237 (description "Gnuplot is a portable command-line driven graphing
238utility. It was originally created to allow scientists and students to
239visualize mathematical functions and data interactively, but has grown to
240support many non-interactive uses such as web scripting. It is also used as a
241plotting engine by third-party applications like Octave.")
242 ;; X11 Style with the additional restriction that derived works may only be
243 ;; distributed as patches to the original.
244 (license (license:fsf-free
668c06ac
JD
245 "http://gnuplot.cvs.sourceforge.net/gnuplot/gnuplot/Copyright"))))
246
7ee3f1a2
JD
247(define-public hdf5
248 (package
249 (name "hdf5")
250 (version "1.8.12")
251 (source
252 (origin
253 (method url-fetch)
254 (uri (string-append "http://www.hdfgroup.org/ftp/HDF5/current/src/hdf5-"
255 version ".tar.bz2"))
256 (sha256
257 (base32 "0f9n0v3p3lwc7564791a39c6cn1d3dbrn7d1j3ikqsi27a8hy23d"))))
258 (build-system gnu-build-system)
259 (arguments
260 `(#:phases
d4bf49b1
EB
261 (alist-cons-before
262 'configure 'patch-configure
263 (lambda _
264 (substitute* "configure"
265 (("/bin/mv") "mv")))
7ee3f1a2
JD
266 %standard-phases)))
267 (outputs '("out" "bin" "lib" "include"))
268 (home-page "http://www.hdfgroup.org")
269 (synopsis "Management suite for extremely large and complex data")
270 (description "HDF5 is a suite that makes possible the management of
271extremely large and complex data collections.")
d4bf49b1
EB
272 (license (license:x11-style
273 "http://www.hdfgroup.org/ftp/HDF5/current/src/unpacked/COPYING"))))
7ee3f1a2
JD
274
275
668c06ac
JD
276;; For a fully featured Octave, users are strongly recommended also to install
277;; the following packages: texinfo, less, ghostscript, gnuplot.
278(define-public octave
279 (package
280 (name "octave")
281 (version "3.8.0")
282 (source
283 (origin
284 (method url-fetch)
285 (uri (string-append "mirror://gnu/octave/octave-"
286 version ".tar.gz"))
287 (sha256
288 (base32
289 "0ks9pr154syw0vb3jn6xsnrkkrbvf9y7i7gaxa28rz6ngxbxvq9l"))))
290 (build-system gnu-build-system)
291 (inputs
292 `(("lapack" ,lapack)
293 ("readline" ,readline)
294 ("glpk" ,glpk)
295 ("curl" ,curl)
296 ("pcre" ,pcre)
297 ("fltk" ,fltk)
298 ("fontconfig" ,fontconfig)
299 ("freetype" ,freetype)
7ee3f1a2
JD
300 ("hdf5-lib" ,hdf5 "lib")
301 ("hdf5-include" ,hdf5 "include")
668c06ac
JD
302 ("libxft" ,libxft)
303 ("mesa" ,mesa)
304 ("zlib" ,zlib)))
305 (native-inputs
306 `(("gfortran" ,gfortran-4.8)
307 ("pkg-config" ,pkg-config)
308 ("perl" ,perl)
309 ;; The following inputs are not actually used in the build process. However, the
310 ;; ./configure gratuitously tests for their existence and assumes that programs not
311 ;; present at build time are also not, and can never be, available at run time!
312 ;; If these inputs are therefore not present, support for them will be built out.
313 ;; However, Octave will still run without them, albeit without the features they
314 ;; provide.
315 ("less" ,less)
316 ("texinfo" ,texinfo)
317 ("ghostscript" ,ghostscript)
318 ("gnuplot" ,gnuplot)))
319 (arguments
320 `(#:configure-flags (list (string-append "--with-shell="
321 (assoc-ref %build-inputs "bash")
322 "/bin/sh"))))
323 (home-page "http://www.gnu.org/software/octave/")
324 (synopsis "High-level language for numerical computation")
325 (description "GNU Octave is a high-level interpreted language that is specialized
326for numerical computations. It can be used for both linear and non-linear
327applications and it provides great support for visualizing results. Work may
328be performed both at the interactive command-line as well as via script
329files.")
330 (license license:gpl3+)))
3de01d3f
EB
331
332(define-public gmsh
333 (package
334 (name "gmsh")
335 (version "2.8.4")
336 (source
337 (origin
338 (method url-fetch)
339 (uri (string-append "http://www.geuz.org/gmsh/src/gmsh-"
340 version "-source.tgz"))
341 (sha256
342 (base32 "0jv2yvk28w86rx5mvjkb0w12ff2jxih7axnpvznpd295lg5jg7hr"))
343 (modules '((guix build utils)))
344 (snippet
345 ;; Remove non-free METIS code
346 '(delete-file-recursively "contrib/Metis"))))
347 (build-system cmake-build-system)
348 (native-inputs `(("patchelf" ,patchelf))) ;for augment-rpath
349 (propagated-inputs
350 `(("fltk" ,fltk)
351 ("gfortran" ,gfortran-4.8)
352 ("gmp" ,gmp)
353 ("hdf5-lib" ,hdf5 "lib")
354 ("hdf5-include" ,hdf5 "include")
355 ("lapack" ,lapack)
356 ("mesa" ,mesa)
357 ("libx11" ,libx11)
358 ("libxext" ,libxext)))
359 (arguments
360 `(#:configure-flags `("-DENABLE_METIS:BOOL=OFF"
361 "-DENABLE_BUILD_SHARED:BOOL=ON"
362 "-DENABLE_BUILD_DYNAMIC:BOOL=ON")))
363 (home-page "http://www.geuz.org/gmsh/")
364 (synopsis "3D finite element grid generator")
edf684ef
EB
365 (description "Gmsh is a 3D finite element grid generator with a built-in
366CAD engine and post-processor. Its design goal is to provide a fast, light
367and user-friendly meshing tool with parametric input and advanced
368visualization capabilities. Gmsh is built around four modules: geometry,
369mesh, solver and post-processing. The specification of any input to these
370modules is done either interactively using the graphical user interface or in
371ASCII text files using Gmsh's own scripting language.")
3de01d3f 372 (license license:gpl2+)))
b9100e2f
EB
373
374(define-public petsc
375 (package
376 (name "petsc")
377 (version "3.4.4")
378 (source
379 (origin
380 (method url-fetch)
381 ;; The *-lite-* tarball does not contain the *large* documentation
382 (uri (string-append "http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/"
383 "petsc-lite-" version ".tar.gz"))
384 (sha256
385 (base32 "0v5dg6dhdjpi5ianvd4mm6hsvxzv1bsxwnh9f9myag0a0d9xk9iv"))
386 (patches
387 (list (search-patch "petsc-fix-threadcomm.patch")))))
388 (build-system gnu-build-system)
389 (native-inputs
390 `(("python" ,python-2)
391 ("perl" ,perl)))
392 (inputs
393 `(("gfortran" ,gfortran-4.8)
394 ("lapack" ,lapack)
f258212d 395 ("superlu" ,superlu)
b9100e2f
EB
396 ;; leaving out hdf5 and fftw, as petsc expects them to be built with mpi
397 ;; leaving out opengl, as configuration seems to only be for mac
398 ))
399 (arguments
400 `(#:test-target "test"
401 #:parallel-build? #f
402 #:configure-flags
403 `("--with-mpi=0"
f258212d
EB
404 "--with-openmp=1"
405 "--with-superlu=1"
406 ,(string-append "--with-superlu-include="
407 (assoc-ref %build-inputs "superlu") "/include")
408 ,(string-append "--with-superlu-lib="
409 (assoc-ref %build-inputs "superlu") "/lib/libsuperlu.a"))
b9100e2f
EB
410 #:phases
411 (alist-replace
412 'configure
413 ;; PETSc's configure script is actually a python script, so we can't
414 ;; run it with bash.
415 (lambda* (#:key outputs (configure-flags '())
416 #:allow-other-keys)
417 (let* ((prefix (assoc-ref outputs "out"))
418 (flags `(,(string-append "--prefix=" prefix)
419 ,@configure-flags)))
420 (format #t "build directory: ~s~%" (getcwd))
421 (format #t "configure flags: ~s~%" flags)
422 (zero? (apply system* "./configure" flags))))
423 (alist-cons-after
10b11968
EB
424 'configure 'clean-local-references
425 ;; Try to keep build directory names from leaking into compiled code
b9100e2f 426 (lambda* (#:key inputs outputs #:allow-other-keys)
10b11968
EB
427 (let ((out (assoc-ref outputs "out")))
428 (substitute* (find-files "." "^petsc(conf|machineinfo).h$")
429 (((getcwd)) out))))
430 (alist-cons-after
431 'install 'clean-install
432 ;; Try to keep installed files from leaking build directory names.
433 (lambda* (#:key inputs outputs #:allow-other-keys)
434 (let ((out (assoc-ref outputs "out"))
435 (fortran (assoc-ref inputs "gfortran")))
436 (substitute* (map (lambda (file)
437 (string-append out "/" file))
438 '("conf/petscvariables"
439 "conf/PETScConfig.cmake"))
440 (((getcwd)) out))
441 ;; Make compiler references point to the store
442 (substitute* (string-append out "/conf/petscvariables")
443 (("= g(cc|\\+\\+|fortran)" _ suffix)
444 (string-append "= " fortran "/bin/g" suffix)))
445 ;; PETSc installs some build logs, which aren't necessary.
446 (for-each (lambda (file)
447 (let ((f (string-append out "/" file)))
448 (when (file-exists? f)
449 (delete-file f))))
450 '("conf/configure.log"
451 "conf/make.log"
452 "conf/test.log"
453 "conf/error.log"
454 "conf/RDict.db"
455 ;; Once installed, should uninstall with Guix
456 "conf/uninstall.py"))))
457 %standard-phases)))))
b9100e2f 458 (home-page "http://www.mcs.anl.gov/petsc")
16ecf3ff 459 (synopsis "Library to solve PDEs")
b9100e2f
EB
460 (description "PETSc, pronounced PET-see (the S is silent), is a suite of
461data structures and routines for the scalable (parallel) solution of
462scientific applications modeled by partial differential equations.")
463 (license (license:bsd-style
464 "http://www.mcs.anl.gov/petsc/documentation/copyright.html"))))
465
466(define-public petsc-complex
467 (package (inherit petsc)
468 (name "petsc-complex")
469 (arguments
470 (substitute-keyword-arguments (package-arguments petsc)
471 ((#:configure-flags cf)
472 `(cons "--with-scalar-type=complex" ,cf))))
16ecf3ff 473 (synopsis "Library to solve PDEs (with complex scalars)")))
183e44ae 474
d8c7eeb9
EB
475(define-public petsc-openmpi
476 (package (inherit petsc)
477 (name "petsc-openmpi")
478 (inputs
479 `(("openmpi" ,openmpi)
480 ,@(package-inputs petsc)))
481 (arguments
482 (substitute-keyword-arguments (package-arguments petsc)
483 ((#:configure-flags cf)
484 ``("--with-mpiexec=mpirun"
485 ,(string-append "--with-mpi-dir="
486 (assoc-ref %build-inputs "openmpi"))
487 ,@(delete "--with-mpi=0" ,cf)))))
16ecf3ff 488 (synopsis "Library to solve PDEs (with MPI support)")))
d8c7eeb9
EB
489
490(define-public petsc-complex-openmpi
491 (package (inherit petsc-complex)
492 (name "petsc-complex-openmpi")
493 (inputs
494 `(("openmpi" ,openmpi)
495 ,@(package-inputs petsc-complex)))
496 (arguments
497 (substitute-keyword-arguments (package-arguments petsc-complex)
498 ((#:configure-flags cf)
499 ``("--with-mpiexec=mpirun"
500 ,(string-append "--with-mpi-dir="
501 (assoc-ref %build-inputs "openmpi"))
502 ,@(delete "--with-mpi=0" ,cf)))))
16ecf3ff 503 (synopsis "Library to solve PDEs (with complex scalars and MPI support)")))
d8c7eeb9 504
183e44ae
EB
505(define-public superlu
506 (package
507 (name "superlu")
508 (version "4.3")
509 (source
510 (origin
511 (method url-fetch)
512 (uri (string-append "http://crd-legacy.lbl.gov/~xiaoye/SuperLU/"
513 "superlu_" version ".tar.gz"))
514 (sha256
515 (base32 "10b785s9s4x0m9q7ihap09275pq4km3k2hk76jiwdfdr5qr2168n"))))
516 (build-system gnu-build-system)
517 (native-inputs
518 `(("tcsh" ,tcsh)))
519 (inputs
520 `(("lapack" ,lapack)
521 ("gfortran" ,gfortran-4.8)))
522 (arguments
523 `(#:parallel-build? #f
524 #:tests? #f ;tests are run as part of `make all`
525 #:phases
526 (alist-replace
527 'configure
528 (lambda* (#:key inputs outputs #:allow-other-keys)
529 (call-with-output-file "make.inc"
530 (lambda (port)
531 (format port "
532PLAT =
533SuperLUroot = ~a
534SUPERLULIB = ~a/lib/libsuperlu.a
535TMGLIB = libtmglib.a
536BLASDEF = -DUSE_VENDOR_BLAS
537BLASLIB = -L~a/lib -lblas
538LIBS = $(SUPERLULIB) $(BLASLIB)
539ARCH = ar
540ARCHFLAGS = cr
541RANLIB = ranlib
542CC = gcc
543PIC = -fPIC
544CFLAGS = -O3 -DPRNTlevel=0 $(PIC)
545NOOPTS = -O0 $(PIC)
546FORTRAN = gfortran
547FFLAGS = -O2 $(PIC)
548LOADER = $(CC)
549CDEFS = -DAdd_"
550 (getcwd)
551 (assoc-ref outputs "out")
552 (assoc-ref inputs "lapack")))))
553 (alist-cons-before
554 'build 'create-install-directories
555 (lambda* (#:key outputs #:allow-other-keys)
556 (for-each
557 (lambda (dir)
558 (mkdir-p (string-append (assoc-ref outputs "out")
559 "/" dir)))
560 '("lib" "include")))
561 (alist-replace
562 'install
563 (lambda* (#:key outputs #:allow-other-keys)
564 ;; Library is placed in lib during the build phase. Copy over
565 ;; headers to include.
566 (let* ((out (assoc-ref outputs "out"))
567 (incdir (string-append out "/include")))
568 (for-each (lambda (file)
569 (let ((base (basename file)))
570 (format #t "installing `~a' to `~a'~%"
571 base incdir)
572 (copy-file file
573 (string-append incdir "/" base))))
574 (find-files "SRC" ".*\\.h$"))))
575 %standard-phases)))))
576 (home-page "http://crd-legacy.lbl.gov/~xiaoye/SuperLU/")
577 (synopsis "Supernodal direct solver for sparse linear systems")
578 (description
579 "SuperLU is a general purpose library for the direct solution of large,
580sparse, nonsymmetric systems of linear equations on high performance machines.
581The library is written in C and is callable from either C or Fortran. The
582library routines perform an LU decomposition with partial pivoting and
583triangular system solves through forward and back substitution. The library
584also provides threshold-based ILU factorization preconditioners.")
585 (license license:bsd-3)))
f8ed036a 586
a54aefea
EB
587(define-public superlu-dist
588 (package
589 (name "superlu-dist")
590 (version "3.3")
591 (source
592 (origin
593 (method url-fetch)
594 (uri (string-append "http://crd-legacy.lbl.gov/~xiaoye/SuperLU/"
595 "superlu_dist_" version ".tar.gz"))
596 (sha256
597 (base32 "1hnak09yxxp026blq8zhrl7685yip16svwngh1wysqxf8z48vzfj"))
598 (patches (list (search-patch "superlu-dist-scotchmetis.patch")))))
599 (build-system gnu-build-system)
600 (native-inputs
601 `(("tcsh" ,tcsh)))
602 (inputs
603 `(("gfortran" ,gfortran-4.8)))
604 (propagated-inputs
605 `(("openmpi" ,openmpi) ;headers include MPI heades
606 ("lapack" ,lapack) ;required to link with output library
607 ("pt-scotch" ,pt-scotch))) ;same
608 (arguments
609 `(#:parallel-build? #f ;race conditions using ar
610 #:phases
611 (alist-replace
612 'configure
613 (lambda* (#:key inputs outputs #:allow-other-keys)
614 (call-with-output-file "make.inc"
615 (lambda (port)
616 (format port "
617PLAT =
618DSuperLUroot = ~a
619DSUPERLULIB = ~a/lib/libsuperlu_dist.a
620BLASDEF = -DUSE_VENDOR_BLAS
621BLASLIB = -L~a/lib -lblas
622PARMETISLIB = -L~a/lib \
623 -lptscotchparmetis -lptscotch -lptscotcherr -lptscotcherrexit \
624 -lscotch -lscotcherr -lscotcherrexit
625METISLIB = -L~:*~a/lib \
626 -lscotchmetis -lscotch -lscotcherr -lscotcherrexit
627LIBS = $(DSUPERLULIB) $(PARMETISLIB) $(METISLIB) $(BLASLIB)
628ARCH = ar
629ARCHFLAGS = cr
630RANLIB = ranlib
631CC = mpicc
632PIC = -fPIC
633CFLAGS = -O3 -g -DPRNTlevel=0 $(PIC)
634NOOPTS = -O0 -g $(PIC)
635FORTRAN = mpifort
636FFLAGS = -O2 -g $(PIC)
637LOADER = $(CC)
638CDEFS = -DAdd_"
639 (getcwd)
640 (assoc-ref outputs "out")
641 (assoc-ref inputs "lapack")
642 (assoc-ref inputs "pt-scotch")))))
643 (alist-cons-after
644 'unpack 'remove-broken-symlinks
645 (lambda _
646 (for-each delete-file
647 (find-files "MAKE_INC" "\\.#make\\..*")))
648 (alist-cons-before
649 'build 'create-install-directories
650 (lambda* (#:key outputs #:allow-other-keys)
651 (for-each
652 (lambda (dir)
653 (mkdir-p (string-append (assoc-ref outputs "out")
654 "/" dir)))
655 '("lib" "include")))
656 (alist-replace
657 'check
658 (lambda _
659 (with-directory-excursion "EXAMPLE"
660 (and
661 (zero? (system* "mpirun" "-n" "2"
662 "./pddrive" "-r" "1" "-c" "2" "g20.rua"))
663 (zero? (system* "mpirun" "-n" "2"
664 "./pzdrive" "-r" "1" "-c" "2" "cg20.cua")))))
665 (alist-replace
666 'install
667 (lambda* (#:key outputs #:allow-other-keys)
668 ;; Library is placed in lib during the build phase. Copy over
669 ;; headers to include.
670 (let* ((out (assoc-ref outputs "out"))
671 (incdir (string-append out "/include")))
672 (for-each (lambda (file)
673 (let ((base (basename file)))
674 (format #t "installing `~a' to `~a'~%"
675 base incdir)
676 (copy-file file
677 (string-append incdir "/" base))))
678 (find-files "SRC" ".*\\.h$"))))
679 %standard-phases)))))))
680 (home-page (package-home-page superlu))
681 (synopsis "Parallel supernodal direct solver")
682 (description
683 "SuperLU_DIST is a parallel extension to the serial SuperLU library.
684It is targeted for distributed memory parallel machines. SuperLU_DIST is
685implemented in ANSI C, and MPI for communications.")
686 (license license:bsd-3)))
687
f8ed036a
EB
688(define-public scotch
689 (package
690 (name "scotch")
691 (version "6.0.0")
692 (source
693 (origin
694 (method url-fetch)
695 (uri (string-append "https://gforge.inria.fr/frs/download.php/31831/"
696 "scotch_" version ".tar.gz"))
697 (sha256
698 (base32 "0yfqf9lk7chb3h42777x42x4adx0v3n0b41q0cdqrdmscp4iczp5"))
699 (patches (list (search-patch "scotch-test-threading.patch")))))
700 (build-system gnu-build-system)
701 (inputs
702 `(("zlib" ,zlib)
703 ("flex" ,flex)
704 ("bison" ,bison)))
705 (arguments
706 `(#:phases
707 (alist-cons-after
708 'unpack 'chdir-to-src
709 (lambda _ (chdir "src"))
710 (alist-replace
711 'configure
712 (lambda _
713 (call-with-output-file "Makefile.inc"
714 (lambda (port)
715 (format port "
716EXE =
717LIB = .a
718OBJ = .o
719MAKE = make
720AR = ar
721ARFLAGS = -ruv
722CCS = gcc
723CCP = mpicc
724CCD = gcc
725CPPFLAGS =~{ -D~a~}
726CFLAGS = -O2 -g $(CPPFLAGS)
727LDFLAGS = -lz -lm -lrt -lpthread
728CP = cp
729LEX = flex -Pscotchyy -olex.yy.c
730LN = ln
731MKDIR = mkdir
732MV = mv
733RANLIB = ranlib
734YACC = bison -pscotchyy -y -b y
735"
736 '("COMMON_FILE_COMPRESS_GZ"
737 "COMMON_PTHREAD"
738 "COMMON_RANDOM_FIXED_SEED"
739 ;; TODO: Define once our MPI supports
740 ;; MPI_THREAD_MULTIPLE
741 ;; "SCOTCH_PTHREAD"
742 ;; "SCOTCH_PTHREAD_NUMBER=2"
743 "restrict=__restrict")))))
744 (alist-replace
745 'install
746 (lambda* (#:key outputs #:allow-other-keys)
747 (let ((out (assoc-ref outputs "out")))
748 (mkdir out)
749 (zero? (system* "make"
750 (string-append "prefix=" out)
751 "install"))))
752 %standard-phases)))))
753 (home-page "http://www.labri.fr/perso/pelegrin/scotch/")
754 (synopsis "Programs and libraries for graph algorithms")
755 (description "SCOTCH is a set of programs and libraries which implement
756the static mapping and sparse matrix reordering algorithms developed within
757the SCOTCH project. Its purpose is to apply graph theory, with a divide and
758conquer approach, to scientific computing problems such as graph and mesh
759partitioning, static mapping, and sparse matrix ordering, in application
760domains ranging from structural mechanics to operating systems or
761bio-chemistry.")
762 ;; See LICENSE_en.txt
763 (license license:cecill-c)))
6acb4adb
EB
764
765(define-public pt-scotch
766 (package (inherit scotch)
767 (name "pt-scotch")
768 (propagated-inputs
769 `(("openmpi" ,openmpi))) ;Headers include MPI headers
770 (arguments
771 (substitute-keyword-arguments (package-arguments scotch)
772 ((#:phases scotch-phases)
773 `(alist-replace
774 'build
775 ;; TODO: Would like to add parallelism here
776 (lambda _
777 (and
778 (zero? (system* "make" "ptscotch"))
779 ;; Install the serial metis compatibility library
780 (zero? (system* "make" "-C" "libscotchmetis" "install"))))
781 (alist-replace
782 'check
783 (lambda _ (zero? (system* "make" "ptcheck")))
784 (alist-replace
785 'install
786 (lambda* (#:key outputs #:allow-other-keys)
787 (let ((out (assoc-ref outputs "out")))
788 (mkdir out)
789 (zero? (system* "make"
790 (string-append "prefix=" out)
791 "install"))))
792 ,scotch-phases))))))
793 (synopsis "Programs and libraries for graph algorithms (with MPI)")))