From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 14 19:07:54 2017 Received: (at 28045) by debbugs.gnu.org; 14 Aug 2017 23:07:54 +0000 Received: from localhost ([127.0.0.1]:37488 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dhOSc-0001bY-Qr for submit@debbugs.gnu.org; Mon, 14 Aug 2017 19:07:54 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:34631) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dhOSa-0001bQ-22 for 28045@debbugs.gnu.org; Mon, 14 Aug 2017 19:07:49 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id DF43A20A76; Mon, 14 Aug 2017 19:07:45 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute5.internal (MEProxy); Mon, 14 Aug 2017 19:07:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.com; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc :x-sasl-enc; s=fm1; bh=1FLcXAi4V/NDBvqsTmySNrF1nd3oqonpA3KrDSxxF QQ=; b=bbjVgWoWEpA1+IuBJGasNdBjOQ0ubRPmkDWDKPb5ovcs3IVofM8FtU6WA 6aOvJSlYw94scsjkpBGJSQGkV5GMEWLObxzMTlmKauQrccABcB3dXm7ddKynovRq /h6UanBK36hJgXOu2sYAoZTFARaN5hpbn0O/9tz59eDjEfdWlf8W+se0DT0jGwSQ fdLvJ7ytY7qyskvnl43kOTKubNtb2ohanjiP25s81tCDls9g4esHLdL5jk6gPBo3 dlHXo6JZWQqoRCb455ZmGq6pvNB1lst40PXNvtIiwc32JyEmkG9E1QJNkgPDwvyX SraOaU+RT55yP3Kw10XdZHIcBBxIQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=fm1; bh=1FLcXAi4V/NDBvqsTm ySNrF1nd3oqonpA3KrDSxxFQQ=; b=sIX/nBuXqVhZ9QMvKk/XM/wNPjtyPy8bRw f+Nyek92XNItX2LJetp1UW4U3OutOh2Yvh9RzmP5rzAUO+dnSwZMClK170DbQRJM DQ/vJHkRKSevVZ/VXTxJVT/JIN+pgzB4JKSEFPPojWA86WeJZiYHPiXBil3FH7lL JM7BIBqJkUg972qQXtycKCEYkx6A34/lWDqyILQrXlm/wyI5h5W/49ZbnCqne2Fh ofgEeqYuq94T/Z8BJO/qk1LRtFgc3IyCcE5OEBt+VCo/CJzxCE/ICtMZMg1Zvcrk tAp5hkwelE5YCuXzvbKlKb33PblKw4tHYFa6elm2pdh2xxgbsTxw== X-ME-Sender: X-Sasl-enc: XIwQCEUMHikrVhXVdg9Zvt0e48tHZALBSFGIPaZ59/88 1502752065 Received: from localhost (unknown [188.113.81.93]) by mail.messagingengine.com (Postfix) with ESMTPA id 5DB63240B1; Mon, 14 Aug 2017 19:07:45 -0400 (EDT) From: Marius Bakke To: Paul Garlick , 28045@debbugs.gnu.org Subject: Re: [bug#28045] [PATCH] gnu: Add openfoam In-Reply-To: <20170811110636.23339-1-pgarlick@tourbillion-technology.com> References: <20170811110636.23339-1-pgarlick@tourbillion-technology.com> User-Agent: Notmuch/0.25 (https://notmuchmail.org) Emacs/25.2.1 (x86_64-unknown-linux-gnu) Date: Tue, 15 Aug 2017 01:07:28 +0200 Message-ID: <87fuct21fz.fsf@fastmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 28045 Cc: Paul Garlick X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Paul Garlick writes: > * gnu/packages/simulation.scm: New file > * gnu/packages/patches/openfoam-cleanup.patch: New file > * gnu/local.mk(GNU_SYSTEM_MODULES): Add module > (dist_patch_DATA): Add patch Thanks a lot for this! The patch does not apply for me, can you rebase this on current 'master'? Meanwhile, some comments... > +diff -ur OpenFOAM-4.x-version-4.1.org/wmake/src/Makefile OpenFOAM-4.x-ve= rsion-4.1/wmake/src/Makefile > +--- OpenFOAM-4.x-version-4.1.org/wmake/src/Makefile > ++++ OpenFOAM-4.x-version-4.1/wmake/src/Makefile > +@@ -33,7 +33,7 @@ > + # The Makefile use a POSIX shell > + #----------------------------------------------------------------------= -------- > +=20 > +-SHELL =3D /bin/sh > ++# SHELL =3D /bin/sh This particular hunk is not necessary since gnu-build-system will search for Makefiles and adjust SHELL as needed. > +diff -ur OpenFOAM-4.x-version-4.1.org/wmake/makefiles/general OpenFOAM-4= .x-version-4.1/wmake/makefiles/general > +--- OpenFOAM-4.x-version-4.1.org/wmake/makefiles/general > ++++ OpenFOAM-4.x-version-4.1/wmake/makefiles/general > +@@ -33,7 +33,7 @@ > + # The Makefile uses a POSIX shell > + #----------------------------------------------------------------------= -------- > +=20 > +-SHELL =3D /bin/sh > ++# SHELL =3D /bin/sh ...although this file named "general" would not be patched automatically. > + #----------------------------------------------------------------------= -------- > +diff -ur OpenFOAM-4.x-version-4.1.org/wmake/wmake OpenFOAM-4.x-version-4= .1/wmake/wmake > +--- OpenFOAM-4.x-version-4.1.org/wmake/wmake > ++++ OpenFOAM-4.x-version-4.1/wmake/wmake > +@@ -163,7 +163,7 @@ > + then > + if [ "$WM_NCOMPPROCS" -gt 1 -a ! "$MAKEFLAGS" ] > + then > +- lockDir=3D$HOME/.$WM_PROJECT/.wmake > ++ lockDir=3D$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P)/.$WM_PR= OJECT/.wmake > +=20 > + if [ -d $lockDir ] > + then > +diff -ur OpenFOAM-4.x-version-4.1.org/wmake/wmakeScheduler OpenFOAM-4.x-= version-4.1/wmake/wmakeScheduler > +--- OpenFOAM-4.x-version-4.1.org/wmake/wmakeScheduler > ++++ OpenFOAM-4.x-version-4.1/wmake/wmakeScheduler > +@@ -53,7 +53,7 @@ > + # csh sets HOST, bash sets HOSTNAME > + : ${HOST:=3D$HOSTNAME} > +=20 > +-lockDir=3D$HOME/.$WM_PROJECT/.wmake > ++lockDir=3D$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P)/.$WM_PROJECT/.w= make > +=20 > + # Fallback - 1 core on current host > + : ${WM_HOSTS:=3D$HOST:1} > +diff -ur OpenFOAM-4.x-version-4.1.org/wmake/wmakeSchedulerUptime OpenFOA= M-4.x-version-4.1/wmake/wmakeSchedulerUptime > +--- OpenFOAM-4.x-version-4.1.org/wmake/wmakeSchedulerUptime > ++++ OpenFOAM-4.x-version-4.1/wmake/wmakeSchedulerUptime > +@@ -53,7 +53,7 @@ > + # csh sets HOST, bash sets HOSTNAME > + : ${HOST:=3D$HOSTNAME} > +=20 > +-lockDir=3D$HOME/.$WM_PROJECT/.wmake > ++lockDir=3D$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P)/.$WM_PROJECT/.w= make > + # Fallback - 1 core on current host > + : ${WM_HOSTS:=3D$HOST:1} Maybe these could be replaced with something like... (substitute* (find-files "." "^\\.wmake$") (("\\$HOME) (getenv "PWD"))) $PWD is initially the source directory, which I think is what the $(dirname $BASH_SOURCE ...) is aiming for(?). > +diff -ur OpenFOAM-4.x-version-4.1.org/src/parallel/decompose/metisDecomp= /metisDecomp.C OpenFOAM-4.x-version-4.1/src/parallel/decompose/metisDecomp/= metisDecomp.C > +--- OpenFOAM-4.x-version-4.1.org/src/parallel/decompose/metisDecomp/meti= sDecomp.C > ++++ OpenFOAM-4.x-version-4.1/src/parallel/decompose/metisDecomp/metisDec= omp.C > +@@ -67,7 +67,7 @@ > +=20 > + // Processor weights initialised with no size, only used if specifi= ed in > + // a file > +- Field processorWeights; > ++ Field processorWeights; This seems unrelated to unbundling :) Is this a known issue? > diff --git a/gnu/packages/simulation.scm b/gnu/packages/simulation.scm > new file mode 100644 > index 000000000..5aa5f8f03 > --- /dev/null > +++ b/gnu/packages/simulation.scm > @@ -0,0 +1,197 @@ > +;;; GNU Guix --- Functional package management for GNU > +;;; Copyright =C2=A9 2017 Paul Garlick > +;;; > +;;; This file is part of GNU Guix. > +;;; > +;;; GNU Guix is free software; you can redistribute it and/or modify it > +;;; under the terms of the GNU General Public License as published by > +;;; the Free Software Foundation; either version 3 of the License, or (at > +;;; your option) any later version. > +;;; > +;;; GNU Guix is distributed in the hope that it will be useful, but > +;;; WITHOUT ANY WARRANTY; without even the implied warranty of > +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +;;; GNU General Public License for more details. > +;;; > +;;; You should have received a copy of the GNU General Public License > +;;; along with GNU Guix. If not, see . > + > +(define-module (gnu packages simulation) > + #:use-module (gnu packages) > + #:use-module (gnu packages base) > + #:use-module (gnu packages bash) > + #:use-module (gnu packages bison) > + #:use-module (gnu packages boost) > + #:use-module (gnu packages compression) > + #:use-module (gnu packages flex) > + #:use-module (gnu packages gettext) > + #:use-module (gnu packages gcc) > + #:use-module (gnu packages gl) > + #:use-module (gnu packages graphics) > + #:use-module (gnu packages gtk) > + #:use-module (gnu packages linux) > + #:use-module (gnu packages m4) > + #:use-module (gnu packages maths) > + #:use-module (gnu packages mpi) > + #:use-module (gnu packages multiprecision) > + #:use-module (gnu packages ncurses) > + #:use-module (gnu packages readline) > + #:use-module (gnu packages tls) > + #:use-module (gnu packages version-control) > + #:use-module (gnu packages xml) > + #:use-module (gnu packages xorg) > + #:use-module (guix download) > + #:use-module (guix build utils) > + #:use-module (guix build-system gnu) > + #:use-module ((guix licenses) #:prefix license:) > + #:use-module (guix packages) > + #:use-module (guix utils) > + #:use-module (ice-9 ftw) > + #:use-module (ice-9 regex) > + #:use-module (srfi srfi-1)) > + > +(define-public openfoam > + (package > + (name "openfoam") > + (version "4.1") > + (source > + (origin > + (method url-fetch) > + (uri (string-append > + "http://dl.openfoam.org/source/" > + (string-replace-substring version "." "-"))) > + (file-name (string-append name "-" version ".tar.gz")) > + (sha256 > + (base32 "1hgh2kw7fqv4bfachhbjhw16v8j35jbv6s576fmz4ka2q4ks4wg3")) > + (patches (search-patches "openfoam-cleanup.patch")) > + (modules '((guix build utils))))) > + (build-system gnu-build-system) > + (native-inputs > + `(("bison" ,bison))) > + (propagated-inputs > + `(("boost" ,boost) > + ("cgal" ,cgal) > + ("flex" ,flex) > + ("git" ,git) > + ("gmp" ,gmp) > + ("gzip" ,gzip) > + ("gnuplot" ,gnuplot) > + ("libxt" ,libxt) > + ("metis" ,metis) > + ("mpfr" ,mpfr) > + ("ncurses" ,ncurses) > + ("openmpi" ,openmpi) > + ("readline" ,readline) > + ("scotch" ,pt-scotch) > + ("zlib" ,zlib))) We try to avoid propagating inputs to minimize risk of profile conflicts. Typically, the linker will add things to RUNPATH as necessary and then we only have to fully qualify command-line references and e.g. dlopen()'d solibs. Can you try making these normal inputs? If the dependencies show up in "guix gc -R $(./pre-inst-env guix build openfoam)" when added as regular inputs, propagation is usually not necessary. > + (arguments > + `(;; executable files and shared libraries are located in the 'plat= forms' > + ;; subdirectory > + #:strip-directories (list (string-append > + "OpenFOAM-" ,version > + "/platforms/linux64GccDPInt32Opt/bin") > + (string-append > + "OpenFOAM-" ,version > + "/platforms/linux64GccDPInt32Opt/lib")) > + ;; '#:elf-directories' is not recognised here so skip validation = phase > + #:validate-runpath? #f I don't suppose it's easy to move everything up to the top store level, which is already in a versioned directory and would allow these phases to proceed normally? > + #:phases (modify-phases %standard-phases > + (add-after 'unpack 'rename-build-directory > + (lambda _ > + (use-modules (ice-9 ftw)) > + (use-modules (ice-9 regex)) > + (chdir "..") > + ;; use 'OpenFOAM-version' convention to match path name > + ;; expectations in the build phase > + (let ((unpack-dir (string-append > + (getcwd) "/" > + (list-ref (scandir (getcwd) (lambda (name) > + (string-match "^OpenFOAM" name))) 0))) > + (build-dir (string-append > + (getcwd) "/OpenFOAM-" ,version))) > + ;; re-name build directory > + (rename-file unpack-dir build-dir) > + ;; move to build directory > + (chdir (basename build-dir))))) Nit-pick: (chdir ...) (and setenv below) have unspecified return values, so please add an explicit #t at the end of such phases for determinism. Consult the Guile manual when unsure if a return value can be "trusted". > + (add-after 'patch-source-shebangs 'set-environment-variables > + (lambda _ > + (let ((libraries '("boost" "cgal" "gmp" "metis" "mpfr" "scot= ch"))) > + ;; set variables to define store paths > + (for-each (lambda (library) > + (setenv (string-append > + (string-upcase library) "_ROOT") > + (assoc-ref %build-inputs library))) libr= aries)) > + ;; set variables to define package versions > + (setenv "SCOTCHVERSION" ,(package-version scotch)) > + (setenv "METISVERSION" ,(package-version metis)))) > + (delete 'configure) ; no configure phase > + (delete 'patch-generated-file-shebangs) ; no generated files Does this phase fail somehow, or is it deleted simply because it's not needed? Just curious :-) > + (replace 'build > + (lambda _ > + ;; compile OpenFOAM libraries and applications > + (zero? (system (format #f > + "source ./etc/bashrc && ./Allwmake -j~a" > + (parallel-job-count)))))) > + (add-after 'build 'update-configuration-files > + (lambda _=20 > + ;; record store paths and package versions in configuration = files > + (zero? (system (format #f "sed -i 's|~a|'~:*~s'|' ~a" > + "$CGAL_ROOT" "etc/config.sh/CGAL"))) > + (zero? (system (format #f "sed -i 's|~a|'~:*~s'|' ~a" > + "$BOOST_ROOT" "etc/config.sh/CGAL"))) > + (zero? (system (format #f "sed -i 's|~a|'~:*~s'|' ~a" > + "$METIS_ROOT" "etc/config.sh/metis"))) > + (zero? (system (format #f "sed -i 's|~a|'~:*~s'|' ~a" > + "$METISVERSION" "etc/config.sh/metis"))) > + (zero? (system (format #f "sed -i 's|~a|'~:*~s'|' ~a" > + "$SCOTCH_ROOT" "etc/config.sh/scotch"))) > + (zero? (system (format #f "sed -i 's|~a|'~:*~s'|' ~a" > + "$SCOTCHVERSION" "etc/config.sh/scotch"))) > + (zero? (system (format #f "sed -i 's|~a|'~:*~s'|' ~a" > + "$GMP_ROOT" "etc/config.sh/settings"))) > + (zero? (system (format #f "sed -i 's|~a|'~:*~s'|' ~a" > + "$MPFR_ROOT" "etc/config.sh/settings"))))) Can you try to use (substitute* ...) here instead? I failed to parse the four single quotes in the sed expression in the format string :-/ > + (delete 'check) ; no tests to run You can set #:tests? #f instead of deleting this phase. > + (replace 'install > + (lambda _ > + ;; use 'OpenFOAM-version' convention > + (let ((install-dir (string-append > + %output "/OpenFOAM-" ,version))) > + ;; create install directory > + (mkdir-p install-dir) > + ;; move contents of build directory to install directory > + (copy-recursively "." install-dir))))))) Related to the earlier question, but it would be nice if we could just copy the contents of platforms/linux64GccDPInt32Opt to %output directly. > + ;; Note: tutorial files are installed read-only in /gnu/store. > + ;; To allow write permissions on files copied from the store a > + ;; 'chmod' step is needed before running the applications. For > + ;; example, from a user's login: > + ;; $ source $GUIX_PROFILE/OpenFOAM-4.1/etc/bashrc > + ;; $ mkdir -p $FOAM_RUN > + ;; $ cd $FOAM_RUN > + ;; $ cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/pitzdaily . > + ;; $ cd pitzdaily > + ;; $ chmod -R u+w . > + ;; $ blockMesh > + (native-search-paths > + ;; define the FOAM_INST_DIR variable > + (list (search-path-specification > + (variable "FOAM_INST_DIR") > + (files '("."))))) ...maybe by utilizing this variable? It would also be better to wrap the binaries with it, instead of depending on it being in a profile. > + (synopsis "Framework for numerical simulation of fluid flow") > + (description "OpenFOAM provides a set of solvers and methods for tac= kling > +problems in the field of Computational Fluid Dynamics (CFD). It is writ= ten in > +C++. Complex governing equations such as the Navier-Stokes equations ca= n be > +solved in integral form. Physical processes such as phase change, dropl= et > +transport and chemical reaction can be modelled. Numerical methods are > +included to deal with sharp gradients, such as those encountered in flow= s with > +shock waves and flows with gas/liquid interfaces. > + > +OpenFOAM implements the Finite Volume Method for discretizing the spacial > +dimensions. Computational grids defining geometries in two- and=20 > +three-dimensional domains may be generated by the included blockMesh and > +snappyHexMesh routines or imported from external grid-generation package= s. > +Grids may be unstructured in layout and may contain any combination of > +polyhedral cells. Large problems may be split into smaller, connected > +problems for efficient solution on parallel systems") Missing ".' ---> ^^^ Having packaged a fair share of academic software myself, I fully expect that some of the suggestions above are overly optimistic, but had to ask regardless ;-) Hopefully it didn't sound too demanding. Can you send an updated patch please? :-) --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEu7At3yzq9qgNHeZDoqBt8qM6VPoFAlmSLTAACgkQoqBt8qM6 VPpQAQf/aIj1UBkFCnUgJbXIu29mOWQk4MXlZlweQrnhcerliEHQTFvNnNs2IOnv KUDs1QT8fE+dbk9ImafTosK6k0VTWcM0kT6RuWUuxXrvtWM6X5CQAjoAs7e99kaL i+kL5tGVamyBpB6RfC0DT+fadb+RUc/bRvIP/HE/NfbHKN8Efv7dN3hxz5qQvo0o H+RkNXsIbhXXDC5oJFwZxDDMxiYXMIarovdg7UMq3m+VGrE5NjIIOXe3c/7s7FwV H9bHbl4jY7WUMekAJIIeIW6lbQApCIsOqoMw/p/7lq1YGc1zMI8pBquvY5xpN1fF XabiUZBRxb5UcERl8B3IgJ2Xccf4Mw== =Iodq -----END PGP SIGNATURE----- --=-=-=--