Subject: [bug#56831] [PATCH] gnu: mumps: Update to 5.5.1

From: FELŠÖCI Marek <[email-masked]>
Date: Fri, 29 Jul 2022 17:44:11 +0200

---
 gnu/packages/maths.scm | 227 +++++++++++++++++++++++------------------
 1 file changed, 125 insertions(+), 102 deletions(-)

diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index 6a84f47468..983e8bf87a 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -52,6 +52,7 @@
 ;;; Copyright © 2021 Pierre-Antoine Bouttier <[email-masked]>
 ;;; Copyright © 2022 Zhu Zihao <[email-masked]>
 ;;; Copyright © 2022 Sharlatan Hellseher <[email-masked]>
+;;; Copyright © 2022 Marek Felšöci <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -3681,19 +3682,15 @@ language understood by many solvers.")
 (define-public mumps
   (package
     (name "mumps")
-    (version "5.2.1")
+    (version "5.5.1")
     (source
      (origin
        (method url-fetch)
-       (uri (string-append "http://mumps.enseeiht.fr/MUMPS_"
-                           version ".tar.gz"))
+       (uri
+        (string-append "http://mumps.enseeiht.fr/MUMPS_" version ".tar.gz"))
        (sha256
         (base32
-         "0jklh54x4y3ik1zkw6db7766kakjm5910diyaghfxxf8vwsgr26r"))
-       (patches (search-patches "mumps-build-parallelism.patch"
-                                "mumps-shared-libseq.patch"
-                                "mumps-shared-mumps.patch"
-                                "mumps-shared-pord.patch"))))
+         "05gs2i8b76m9flm1826fxpyfnwibjjawbmfza3ylrvj7zaag5gqs"))))
     (build-system gnu-build-system)
     (inputs
      (list gfortran
@@ -3703,105 +3700,131 @@ language understood by many solvers.")
            metis
            scotch))
     (arguments
-     `(#:modules ((ice-9 match)
-                  (ice-9 popen)
-                  (srfi srfi-1)
-                  ,@%gnu-build-system-modules)
+     `(#:modules
+       ((ice-9 match)
+        (ice-9 popen)
+        (srfi srfi-1)
+        ,@%gnu-build-system-modules)
        #:phases
        (modify-phases %standard-phases
          (replace 'configure
-          (lambda* (#:key inputs #:allow-other-keys)
-            (call-with-output-file "Makefile.inc"
-              (lambda (port)
-                (format port "
-PLAT         =
-LIBEXT       = .a
-OUTC         = -o
-OUTF         = -o
-RM           = rm -f~:[
-CC           = gcc
-FC           = gfortran
-FL           = gfortran
-INCSEQ       = -I$(topdir)/libseq
-LIBSEQ       = $(topdir)/libseq/libmpiseq.a
-LIBSEQNEEDED = libseqneeded~;
-CC           = mpicc
-FC           = mpifort
-FL           = mpifort~]
-AR           = ar vr # rules require trailing space, ugh...
-RANLIB       = ranlib
-BLASDIR      = ~a
-LIBBLAS      = -Wl,-rpath=$(BLASDIR) -Wl,-rpath='$$ORIGIN' -L$(BLASDIR) -lopenblas~@[
-SCALAPDIR    = ~a
-SCALAP       = -Wl,-rpath=$(SCALAPDIR) -Wl,-rpath='$$ORIGIN' -L$(SCALAPDIR) -lscalapack~]
-LIBOTHERS    = -pthread
-CDEFS        = -DAdd_
-PIC          = -fPIC
-OPTF         = -O2 -DALLOW_NON_INIT -fallow-argument-mismatch $(PIC)
-OPTL         = -O2 $(PIC)
-OPTC         = -O2 $(PIC)
-INCS         = $(INCSEQ)
-LIBS         = $(SCALAP) $(LIBSEQ)
-LPORDDIR     = $(topdir)/PORD/lib
-IPORD        = -I$(topdir)/PORD/include
-LPORD        = $(LPORDDIR)/libpord.a
-ORDERINGSF   = -Dpord~@[
-METISDIR     = ~a
-IMETIS       = -I$(METISDIR)/include
-LMETIS       = -Wl,-rpath $(METISDIR)/lib -L$(METISDIR)/lib -lmetis
-ORDERINGSF  += -Dmetis~]~@[~:{
-SCOTCHDIR    = ~a
-ISCOTCH      = -I$(SCOTCHDIR)/include
-LSCOTCH      = -Wl,-rpath $(SCOTCHDIR)/lib -L$(SCOTCHDIR)/lib ~a-lesmumps -lscotch -lscotcherr
-ORDERINGSF  += ~a~}~]
-ORDERINGSC   = $(ORDERINGSF)
-LORDERINGS   = $(LPORD) $(LMETIS) $(LSCOTCH) $(LIBSEQ)
-IORDERINGSF  = $(ISCOTCH)
-IORDERINGSC  = $(IPORD) $(IMETIS) $(ISCOTCH)"
-                        (->bool (which "mpicc"))  ;MPI support enabled?
-                        (dirname
-                         (dirname (search-input-file inputs "/include/cblas.h")))
-                        (assoc-ref inputs "scalapack")
-                        (assoc-ref inputs "metis")
-                        (match (list (assoc-ref inputs "pt-scotch")
-                                     (assoc-ref inputs "scotch"))
-                          ((#f #f)
-                           #f)
-                          ((#f scotch)
-                           `((,scotch "" "-Dscotch")))
-                          ((ptscotch _)
-                           `((,ptscotch
-                              "-lesmumps -lptscotch -lptscotcherr "
-                              "-Dptscotch")))))))))
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (call-with-output-file "Makefile.inc"
+               (lambda (port)
+                 (format port "
+PLAT          =
+LIBEXT        = .a
+LIBEXT_SHARED = .so
+OUTC          = -o
+OUTF          = -o
+BLASDIR       = ~a
+LIBBLAS       = -Wl,-rpath=$(BLASDIR)/lib -Wl,-rpath='$$ORIGIN'
+LIBBLAS      += -L$(BLASDIR)/lib~:[
+LIBBLAS      += -lopenblas
+OPTF          = ~;
+LIBBLAS      += -L${BLASDIR}/lib/intel64 -Wl,--no-as-needed -lmkl_gf_lp64
+LIBBLAS      += -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl
+OPTF          = -DGEMMT_AVAILABLE~]~@[
+SCALAPDIR     = ~a
+SCALAP        = -Wl,-rpath=$(SCALAPDIR)/lib -Wl,-rpath='$$ORIGIN'
+SCALAP       += -L$(SCALAPDIR)/lib -lscalapack~]
+RM            = rm -f~:[
+CC            = gcc
+FC            = gfortran
+FL            = gfortran
+INCSEQ        = -I$(topdir)/libseq
+LIBSEQ        = $(LAPACK) -L$(topdir)/libseq -lmpiseq
+LIBSEQNEEDED  = libseqneeded
+INCS          = $(INCSEQ)
+LIBS          = $(LIBSEQ)~;
+CC            = mpicc
+FC            = mpifort
+FL            = mpifort
+INCPAR        =
+LIBPAR        = $(SCALAP) $(LAPACK)
+LIBSEQNEEDED  = 
+INCS          = $(INCPAR)
+LIBS          = $(LIBPAR)~]
+AR            = ar vr # rules require trailing space, ugh...
+RANLIB        = ranlib
+LIBOTHERS     = -pthread
+CDEFS         = -DAdd_
+PIC           = -fPIC
+FPIC_OPT      = $(PIC)
+RPATH_OPT     = -Wl,-rpath,~a/lib
+OPTF         += -O2 -fopenmp -DMUMPS_USE_BLAS2 -DALLOW_NON_INIT -DBLR_MT
+OPTF         += -fallow-argument-mismatch $(PIC)
+OPTL          = -O2 -fopenmp $(PIC)
+OPTC          = -O2 -fopenmp $(PIC)
+LPORDDIR      = $(topdir)/PORD/lib
+IPORD         = -I$(topdir)/PORD/include
+LPORD         = $(LPORDDIR)/libpord.a
+ORDERINGSF    = -Dpord~@[
+METISDIR      = ~a
+IMETIS        = -I$(METISDIR)/include
+LMETIS        = -Wl,-rpath $(METISDIR)/lib -L$(METISDIR)/lib -lmetis
+ORDERINGSF   += -Dmetis~]~@[~:{
+SCOTCHDIR     = ~a
+ISCOTCH       = -I$(SCOTCHDIR)/include
+LSCOTCH       = -Wl,-rpath $(SCOTCHDIR)/lib -L$(SCOTCHDIR)/lib ~a -lesmumps
+LSCOTCH      += -lscotch -lscotcherr
+ORDERINGSF   += ~a~}~]
+ORDERINGSC    = $(ORDERINGSF)
+LORDERINGS    = $(LPORD) $(LMETIS) $(LSCOTCH)
+IORDERINGSF   = $(ISCOTCH)
+IORDERINGSC   = $(IPORD) $(IMETIS) $(ISCOTCH)"
+                         (assoc-ref inputs "openblas")
+                         (->bool ;; OpenBLAS or MKL?
+                          (file-exists?
+                           (string-append
+                            (assoc-ref inputs "openblas")
+                            "/include/mkl_cblas.h")))
+                         (assoc-ref inputs "scalapack")
+                         (->bool (which "mpicc"))  ;; MPI support enabled?
+                         (assoc-ref outputs "out")
+                         (assoc-ref inputs "metis")
+                         (match (list (assoc-ref inputs "pt-scotch")
+                                      (assoc-ref inputs "scotch"))
+                                ((#f #f)
+                                 #f)
+                                ((#f scotch)
+                                 `((,scotch "" "-Dscotch")))
+                                ((ptscotch _)
+                                 `((,ptscotch
+                                    "-lesmumps -lptscotch -lptscotcherr "
+                                    "-Dptscotch")))))))))
          (replace 'build
-          ;; By default only the d-precision library is built.  Make with "all"
-          ;; target so that all precision libraries and examples are built.
-          (lambda _
-            (invoke "make" "all"
-                    (format #f "-j~a" (parallel-job-count)))))
+           ;; By default only the d-precision library is built. Make with "all"
+           ;; target so that all precision libraries and examples are built.
+           ;; Then, "make allshared" builts equivalent shared libraries as well.
+           (lambda _
+             (invoke "make" "all"
+                     (format #f "-j~a" (parallel-job-count)))
+             (invoke "make" "allshared"
+                     (format #f "-j~a" (parallel-job-count)))))
          (replace 'check
-          ;; Run the simple test drivers, which read test input from stdin:
-          ;; from the "real" input for the single- and double-precision
-          ;; testers, and from the "cmplx" input for complex-precision
-          ;; testers.  The EXEC-PREFIX key is used by the mumps-openmpi
-          ;; package to prefix execution with "mpirun".
-          (lambda* (#:key (exec-prefix '()) #:allow-other-keys)
-            (with-directory-excursion "examples"
-              (every
-               (lambda (prec type)
-                 (let ((tester (apply open-pipe*
-                                      `(,OPEN_WRITE
-                                        ,@exec-prefix
-                                        ,(string-append "./" prec
-                                                        "simpletest"))))
-                       (input  (open-input-file
-                                (string-append "input_simpletest_" type))))
-                   (begin
-                     (dump-port input tester)
-                     (close-port input)
-                     (zero? (close-pipe tester)))))
-               '("s" "d" "c" "z")
-               '("real" "real" "cmplx" "cmplx")))))
+           ;; Run the simple test drivers, which read test input from stdin:
+           ;; from the "real" input for the single- and double-precision
+           ;; testers, and from the "cmplx" input for complex-precision
+           ;; testers.  The EXEC-PREFIX key is used by the mumps-openmpi
+           ;; package to prefix execution with "mpirun".
+           (lambda* (#:key (exec-prefix '()) #:allow-other-keys)
+             (with-directory-excursion "examples"
+               (every
+                (lambda (prec type)
+                  (let ((tester (apply open-pipe*
+                                       `(,OPEN_WRITE
+                                         ,@exec-prefix
+                                         ,(string-append "./" prec
+                                                         "simpletest"))))
+                        (input  (open-input-file
+                                 (string-append "input_simpletest_" type))))
+                    (begin
+                      (dump-port input tester)
+                      (close-port input)
+                      (zero? (close-pipe tester)))))
+                '("s" "d" "c" "z")
+                '("real" "real" "cmplx" "cmplx")))))
          (replace 'install
            (lambda* (#:key outputs #:allow-other-keys)
              (let* ((out (assoc-ref outputs "out"))
-- 
2.20.1