[PATCH] gnu: Add openfoam

  • Done
  • quality assurance status badge
Details
5 participants
  • Eric Bavier
  • Ludovic Courtès
  • Marius Bakke
  • Paul Garlick
  • Ricardo Wurmus
Owner
unassigned
Submitted by
Paul Garlick
Severity
normal
P
P
Paul Garlick wrote on 11 Aug 2017 13:06
(address . guix-patches@gnu.org)(name . Paul Garlick)(address . pgarlick@tourbillion-technology.com)
20170811110636.23339-1-pgarlick@tourbillion-technology.com
* 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
---
gnu/local.mk | 2 +
gnu/packages/patches/openfoam-cleanup.patch | 251 ++++++++++++++++++++++++++++
gnu/packages/simulation.scm | 197 ++++++++++++++++++++++
3 files changed, 450 insertions(+)
create mode 100644 gnu/packages/patches/openfoam-cleanup.patch
create mode 100644 gnu/packages/simulation.scm

Toggle diff (449 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index 4b2bdfe37..b00ec1ac7 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -357,6 +357,7 @@ GNU_SYSTEM_MODULES = \
%D%/packages/shells.scm \
%D%/packages/shellutils.scm \
%D%/packages/simh.scm \
+ %D%/packages/simulation.scm \
%D%/packages/skarnet.scm \
%D%/packages/skribilo.scm \
%D%/packages/slang.scm \
@@ -866,6 +867,7 @@ dist_patch_DATA = \
%D%/packages/patches/ola-readdir-r.patch \
%D%/packages/patches/openscenegraph-ffmpeg3.patch \
%D%/packages/patches/openexr-missing-samples.patch \
+ %D%/packages/patches/openfoam-cleanup.patch \
%D%/packages/patches/openjpeg-CVE-2016-9850-CVE-2016-9851.patch \
%D%/packages/patches/openjpeg-CVE-2016-9572-CVE-2016-9573.patch \
%D%/packages/patches/openldap-CVE-2017-9287.patch \
diff --git a/gnu/packages/patches/openfoam-cleanup.patch b/gnu/packages/patches/openfoam-cleanup.patch
new file mode 100644
index 000000000..b2c0ddcd1
--- /dev/null
+++ b/gnu/packages/patches/openfoam-cleanup.patch
@@ -0,0 +1,251 @@
+# This patch removes all need for the ThirdParty files of OpenFOAM
+
+# Derived from easybuild patch: Ward Poelmans <wpoely86@gmail.com>
+# Modified for GNU Guix: Paul Garlick <pgarlick@tourbillion-technology.com>
+
+diff -ur OpenFOAM-4.x-version-4.1.org/applications/utilities/mesh/manipulation/setSet/Allwmake OpenFOAM-4.x-version-4.1/applications/utilities/mesh/manipulation/setSet/Allwmake
+--- OpenFOAM-4.x-version-4.1.org/applications/utilities/mesh/manipulation/setSet/Allwmake
++++ OpenFOAM-4.x-version-4.1/applications/utilities/mesh/manipulation/setSet/Allwmake
+@@ -9,7 +9,7 @@
+ #
+ # use readline if available
+ #
+-if [ -f /usr/include/readline/readline.h ]
++if true
+ then
+ echo "Found <readline/readline.h> -- enabling readline support."
+ export COMP_FLAGS="-DHAS_READLINE"
+diff -ur OpenFOAM-4.x-version-4.1.org/etc/bashrc OpenFOAM-4.x-version-4.1/etc/bashrc
+--- OpenFOAM-4.x-version-4.1.org/etc/bashrc
++++ OpenFOAM-4.x-version-4.1/etc/bashrc
+@@ -43,8 +43,10 @@
+ # Please set to the appropriate path if the default is not correct.
+ #
+ [ $BASH_SOURCE ] && \
+-export FOAM_INST_DIR=$(cd ${BASH_SOURCE%/*/*/*} && pwd -P) || \
++export FOAM_INST_DIR=$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P) || \
+ export FOAM_INST_DIR=$HOME/$WM_PROJECT
++# For GNU Guix: set initially for build then re-set at runtime
++#
+ # export FOAM_INST_DIR=~$WM_PROJECT
+ # export FOAM_INST_DIR=/opt/$WM_PROJECT
+ # export FOAM_INST_DIR=/usr/local/$WM_PROJECT
+diff -ur OpenFOAM-4.x-version-4.1.org/etc/config.sh/CGAL OpenFOAM-4.x-version-4.1/etc/config.sh/CGAL
+--- OpenFOAM-4.x-version-4.1.org/etc/config.sh/CGAL
++++ OpenFOAM-4.x-version-4.1/etc/config.sh/CGAL
+@@ -36,37 +36,7 @@
+ #
+ #------------------------------------------------------------------------------
+
+-boost_version=boost-system
+-cgal_version=cgal-system
+-#cgal_version=CGAL-4.8
+-
+-if [ -z "$SOURCE_CGAL_VERSIONS_ONLY" ]
+-then
+-
+- common_path=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER
+-
+- export BOOST_ARCH_PATH=$common_path/$boost_version
+- export CGAL_ARCH_PATH=$common_path/$cgal_version
+-
+- if [ "$FOAM_VERBOSE" -a "$PS1" ]
+- then
+- echo "Using CGAL and boost" 1>&2
+- echo " $cgal_version at $CGAL_ARCH_PATH" 1>&2
+- echo " $boost_version at $BOOST_ARCH_PATH" 1>&2
+- fi
+-
+- if [ -d "$CGAL_ARCH_PATH" -a "$cgal_version" != "cgal-system" ]
+- then
+- _foamAddLib $CGAL_ARCH_PATH/lib
+- fi
+-
+- if [ -d "$BOOST_ARCH_PATH" -a "$boost_version" != "boost-system" ]
+- then
+- _foamAddLib $BOOST_ARCH_PATH/lib
+- fi
+-
+- unset boost_version cgal_version common_path
+-
+-fi
++export CGAL_ARCH_PATH=$CGAL_ROOT
++export BOOST_ARCH_PATH=$BOOST_ROOT
+
+ #------------------------------------------------------------------------------
+diff -ur OpenFOAM-4.x-version-4.1.org/etc/config.sh/gperftools OpenFOAM-4.x-version-4.1/etc/config.sh/gperftools
+--- OpenFOAM-4.x-version-4.1.org/etc/config.sh/gperftools 2016-10-16 16:11:45.000000000 +0200
++++ OpenFOAM-4.x-version-4.1/etc/config.sh/gperftools 2017-04-10 14:51:01.473221230 +0200
+@@ -29,13 +29,13 @@
+ #
+ #------------------------------------------------------------------------------
+
+-version=svn
+-gperftools_install=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER
+-
+-GPERFTOOLS_VERSION=gperftools-$version
+-GPERFTOOLS_ARCH_PATH=$gperftools_install/$GPERFTOOLS_VERSION
+-
+-export PATH=$GPERFTOOLS_ARCH_PATH/bin:$PATH
+-export LD_LIBRARY_PATH=$GPERFTOOLS_ARCH_PATH/lib:$LD_LIBRARY_PATH
++# version=svn
++# gperftools_install=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER
++#
++# GPERFTOOLS_VERSION=gperftools-$version
++# GPERFTOOLS_ARCH_PATH=$gperftools_install/$GPERFTOOLS_VERSION
++#
++# export PATH=$GPERFTOOLS_ARCH_PATH/bin:$PATH
++# export LD_LIBRARY_PATH=$GPERFTOOLS_ARCH_PATH/lib:$LD_LIBRARY_PATH
+
+ #------------------------------------------------------------------------------
+diff -ur OpenFOAM-4.x-version-4.1.org/etc/config.sh/metis OpenFOAM-4.x-version-4.1/etc/config.sh/metis
+--- OpenFOAM-4.x-version-4.1.org/etc/config.sh/metis
++++ OpenFOAM-4.x-version-4.1/etc/config.sh/metis
+@@ -34,7 +34,7 @@
+ #
+ #------------------------------------------------------------------------------
+
+-export METIS_VERSION=metis-5.1.0
+-export METIS_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION/$METIS_VERSION
++export METIS_VERSION=metis-$METISVERSION
++export METIS_ARCH_PATH=$METIS_ROOT
+
+ #------------------------------------------------------------------------------
+diff -ur OpenFOAM-4.x-version-4.1.org/etc/config.sh/scotch OpenFOAM-4.x-version-4.1/etc/config.sh/scotch
+--- OpenFOAM-4.x-version-4.1.org/etc/config.sh/scotch
++++ OpenFOAM-4.x-version-4.1/etc/config.sh/scotch
+@@ -37,7 +37,7 @@
+ #
+ #------------------------------------------------------------------------------
+
+-export SCOTCH_VERSION=scotch_6.0.3
+-export SCOTCH_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION/$SCOTCH_VERSION
++export SCOTCH_VERSION=scotch_$SCOTCHVERSION
++export SCOTCH_ARCH_PATH=$SCOTCH_ROOT
+
+ #------------------------------------------------------------------------------
+diff -ur OpenFOAM-4.x-version-4.1.org/etc/config.sh/settings OpenFOAM-4.x-version-4.1/etc/config.sh/settings
+--- OpenFOAM-4.x-version-4.1.org/etc/config.sh/settings
++++ OpenFOAM-4.x-version-4.1/etc/config.sh/settings
+@@ -279,6 +279,9 @@
+ ;;
+ system)
+ # Use system compiler
++ # Use system GMP and MPFR packages
++ export GMP_ARCH_PATH=$GMP_ROOT
++ export MPFR_ARCH_PATH=$MPFR_ROOT
+ ;;
+ *)
+ echo "Warn: WM_COMPILER_TYPE='$WM_COMPILER_TYPE' is unsupported" 1>&2
+diff -ur OpenFOAM-4.x-version-4.1.org/src/parallel/decompose/ptscotchDecomp/Make/options OpenFOAM-4.x-version-4.1/src/parallel/decompose/ptscotchDecomp/Make/options
+--- OpenFOAM-4.x-version-4.1.org/src/parallel/decompose/ptscotchDecomp/Make/options
++++ OpenFOAM-4.x-version-4.1/src/parallel/decompose/ptscotchDecomp/Make/options
+@@ -5,8 +5,7 @@
+ $(PFLAGS) $(PINC) \
+ -I$(SCOTCH_ROOT)/include \
+ -I$(SCOTCH_ARCH_PATH)/include/$(FOAM_MPI) \
+- -I/usr/include/scotch \
+ -I../decompositionMethods/lnInclude
+
+ LIB_LIBS = \
+- -L$(SCOTCH_ROOT)/lib -L$(FOAM_EXT_LIBBIN)/$(FOAM_MPI) -lptscotch -lptscotcherrexit -lscotch ${LINK_FLAGS} -lrt
++ -L$(SCOTCH_ROOT)/lib -L$(MPI_ARCH_PATH)/lib -lptscotch -lptscotcherrexit -lscotch ${LINK_FLAGS} -lrt
+diff -ur OpenFOAM-4.x-version-4.1.org/src/parallel/decompose/scotchDecomp/Make/options OpenFOAM-4.x-version-4.1/src/parallel/decompose/scotchDecomp/Make/options
+--- OpenFOAM-4.x-version-4.1.org/src/parallel/decompose/scotchDecomp/Make/options
++++ OpenFOAM-4.x-version-4.1/src/parallel/decompose/scotchDecomp/Make/options
+@@ -9,8 +9,7 @@
+ $(PFLAGS) $(PINC) \
+ -I$(SCOTCH_ROOT)/include \
+ -I$(SCOTCH_ARCH_PATH)/include \
+- -I/usr/include/scotch \
+ -I../decompositionMethods/lnInclude
+
+ LIB_LIBS = \
+- -L$(SCOTCH_ROOT)/lib -L$(FOAM_EXT_LIBBIN) -lscotch -lscotcherrexit -lrt
++ -L$(SCOTCH_ROOT)/lib -lscotch -lscotcherrexit -lrt
+diff -ur OpenFOAM-4.x-version-4.1.org/wmake/src/Makefile OpenFOAM-4.x-version-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
+ #------------------------------------------------------------------------------
+
+-SHELL = /bin/sh
++# SHELL = /bin/sh
+
+ #------------------------------------------------------------------------------
+ # Unset suffices list (suffix rules are not used)
+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
+ #------------------------------------------------------------------------------
+
+-SHELL = /bin/sh
++# SHELL = /bin/sh
+
+
+ #------------------------------------------------------------------------------
+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=$HOME/.$WM_PROJECT/.wmake
++ lockDir=$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P)/.$WM_PROJECT/.wmake
+
+ 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:=$HOSTNAME}
+
+-lockDir=$HOME/.$WM_PROJECT/.wmake
++lockDir=$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P)/.$WM_PROJECT/.wmake
+
+ # Fallback - 1 core on current host
+ : ${WM_HOSTS:=$HOST:1}
+diff -ur OpenFOAM-4.x-version-4.1.org/wmake/wmakeSchedulerUptime OpenFOAM-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:=$HOSTNAME}
+
+-lockDir=$HOME/.$WM_PROJECT/.wmake
++lockDir=$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P)/.$WM_PROJECT/.wmake
+ # Fallback - 1 core on current host
+ : ${WM_HOSTS:=$HOST:1}
+
+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/metisDecomp.C
++++ OpenFOAM-4.x-version-4.1/src/parallel/decompose/metisDecomp/metisDecomp.C
+@@ -67,7 +67,7 @@
+
+ // Processor weights initialised with no size, only used if specified in
+ // a file
+- Field<scalar> processorWeights;
++ Field<floatScalar> processorWeights;
+
+ // Cell weights (so on the vertices of the dual)
+ List<label> cellWeights;
+diff -ur OpenFOAM-4.x-version-4.1.org/wmake/rules/General/CGAL OpenFOAM-4.x-version-4.1/wmake/rules/General/CGAL
+--- OpenFOAM-4.x-version-4.1.org/wmake/rules/General/CGAL
++++ OpenFOAM-4.x-version-4.1/wmake/rules/General/CGAL
+@@ -6,8 +6,8 @@
+ -I/usr/include
+
+ CGAL_LIBS = \
+- -L$(MPFR_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \
+- -L$(GMP_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \
++ -L$(MPFR_ARCH_PATH)/lib \
++ -L$(GMP_ARCH_PATH)/lib \
+ -L$(BOOST_ARCH_PATH)/lib \
+ -L$(CGAL_ARCH_PATH)/lib \
+ -lCGAL \
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 © 2017 Paul Garlick <pgarlick@tourbillion-technology.com>
+;;;
+;;; 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 <http://www.gnu.org/licenses/>.
+
+(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)))
+ (arguments
+ `(;; executable files and shared libraries are located in the 'platforms'
+ ;; 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
+ #: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)))))
+ (add-after 'patch-source-shebangs 'set-environment-variables
+ (lambda _
+ (let ((libraries '("boost" "cgal" "gmp" "metis" "mpfr" "scotch")))
+ ;; set variables to define store paths
+ (for-each (lambda (library)
+ (setenv (string-append
+ (string-upcase library) "_ROOT")
+ (assoc-ref %build-inputs library))) libraries))
+ ;; 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
+ (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 _
+ ;; 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")))))
+ (delete 'check) ; no tests to run
+ (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)))))))
+ ;; 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 ru
This message was truncated. Download the full message here.
M
M
Marius Bakke wrote on 15 Aug 2017 01:07
(name . Paul Garlick)(address . pgarlick@tourbillion-technology.com)
87fuct21fz.fsf@fastmail.com
Paul Garlick <pgarlick@tourbillion-technology.com> writes:

Toggle quote (5 lines)
> * 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...

Toggle quote (10 lines)
> +diff -ur OpenFOAM-4.x-version-4.1.org/wmake/src/Makefile OpenFOAM-4.x-version-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
> + #------------------------------------------------------------------------------
> +
> +-SHELL = /bin/sh
> ++# SHELL = /bin/sh

This particular hunk is not necessary since gnu-build-system will search
for Makefiles and adjust SHELL as needed.

Toggle quote (10 lines)
> +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
> + #------------------------------------------------------------------------------
> +
> +-SHELL = /bin/sh
> ++# SHELL = /bin/sh

...although this file named "general" would not be patched automatically.

Toggle quote (37 lines)
> + #------------------------------------------------------------------------------
> +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=$HOME/.$WM_PROJECT/.wmake
> ++ lockDir=$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P)/.$WM_PROJECT/.wmake
> +
> + 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:=$HOSTNAME}
> +
> +-lockDir=$HOME/.$WM_PROJECT/.wmake
> ++lockDir=$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P)/.$WM_PROJECT/.wmake
> +
> + # Fallback - 1 core on current host
> + : ${WM_HOSTS:=$HOST:1}
> +diff -ur OpenFOAM-4.x-version-4.1.org/wmake/wmakeSchedulerUptime OpenFOAM-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:=$HOSTNAME}
> +
> +-lockDir=$HOME/.$WM_PROJECT/.wmake
> ++lockDir=$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P)/.$WM_PROJECT/.wmake
> + # Fallback - 1 core on current host
> + : ${WM_HOSTS:=$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(?).

Toggle quote (10 lines)
> +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/metisDecomp.C
> ++++ OpenFOAM-4.x-version-4.1/src/parallel/decompose/metisDecomp/metisDecomp.C
> +@@ -67,7 +67,7 @@
> +
> + // Processor weights initialised with no size, only used if specified in
> + // a file
> +- Field<scalar> processorWeights;
> ++ Field<floatScalar> processorWeights;

This seems unrelated to unbundling :) Is this a known issue?

Toggle quote (93 lines)
> 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 © 2017 Paul Garlick <pgarlick@tourbillion-technology.com>
> +;;;
> +;;; 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 <http://www.gnu.org/licenses/>.
> +
> +(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.

Toggle quote (12 lines)
> + (arguments
> + `(;; executable files and shared libraries are located in the 'platforms'
> + ;; 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?

Toggle quote (19 lines)
> + #: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".

Toggle quote (14 lines)
> + (add-after 'patch-source-shebangs 'set-environment-variables
> + (lambda _
> + (let ((libraries '("boost" "cgal" "gmp" "metis" "mpfr" "scotch")))
> + ;; set variables to define store paths
> + (for-each (lambda (library)
> + (setenv (string-append
> + (string-upcase library) "_ROOT")
> + (assoc-ref %build-inputs library))) libraries))
> + ;; 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 :-)

Toggle quote (26 lines)
> + (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 _
> + ;; 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 :-/

Toggle quote (2 lines)
> + (delete 'check) ; no tests to run

You can set #:tests? #f instead of deleting this phase.

Toggle quote (10 lines)
> + (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.

Toggle quote (17 lines)
> + ;; 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.

Toggle quote (16 lines)
> + (synopsis "Framework for numerical simulation of fluid flow")
> + (description "OpenFOAM provides a set of solvers and methods for tackling
> +problems in the field of Computational Fluid Dynamics (CFD). It is written in
> +C++. Complex governing equations such as the Navier-Stokes equations can be
> +solved in integral form. Physical processes such as phase change, droplet
> +transport and chemical reaction can be modelled. Numerical methods are
> +included to deal with sharp gradients, such as those encountered in flows 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
> +three-dimensional domains may be generated by the included blockMesh and
> +snappyHexMesh routines or imported from external grid-generation packages.
> +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? :-)
-----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-----

E
E
Eric Bavier wrote on 15 Aug 2017 04:49
(name . Paul Garlick)(address . pgarlick@tourbillion-technology.com)(address . 28045@debbugs.gnu.org)
20170814214925.2cd96b3f@centurylink.net
Hello Paul,

Thank you for the patch!

I started this response before Marius's reply. I hope the two do not
overlap too much:


On Fri, 11 Aug 2017 12:06:36 +0100
Paul Garlick <pgarlick@tourbillion-technology.com> wrote:

Toggle quote (2 lines)
> * gnu/packages/simulation.scm: New file

Would this package not fit nicely in gnu/packages/engineering.scm?

Toggle quote (2 lines)
> * gnu/packages/patches/openfoam-cleanup.patch: New file

See comments below.

Toggle quote (2 lines)
> * gnu/local.mk(GNU_SYSTEM_MODULES): Add module
> (dist_patch_DATA): Add patch
^
ChangeLog conventions would have this opening paren in column 0.

Toggle quote (354 lines)
> ---
> gnu/local.mk | 2 +
> gnu/packages/patches/openfoam-cleanup.patch | 251 ++++++++++++++++++++++++++++
> gnu/packages/simulation.scm | 197 ++++++++++++++++++++++
> 3 files changed, 450 insertions(+)
> create mode 100644 gnu/packages/patches/openfoam-cleanup.patch
> create mode 100644 gnu/packages/simulation.scm
>
> diff --git a/gnu/local.mk b/gnu/local.mk
> index 4b2bdfe37..b00ec1ac7 100644
> --- a/gnu/local.mk
> +++ b/gnu/local.mk
> @@ -357,6 +357,7 @@ GNU_SYSTEM_MODULES = \
> %D%/packages/shells.scm \
> %D%/packages/shellutils.scm \
> %D%/packages/simh.scm \
> + %D%/packages/simulation.scm \
> %D%/packages/skarnet.scm \
> %D%/packages/skribilo.scm \
> %D%/packages/slang.scm \
> @@ -866,6 +867,7 @@ dist_patch_DATA = \
> %D%/packages/patches/ola-readdir-r.patch \
> %D%/packages/patches/openscenegraph-ffmpeg3.patch \
> %D%/packages/patches/openexr-missing-samples.patch \
> + %D%/packages/patches/openfoam-cleanup.patch \
> %D%/packages/patches/openjpeg-CVE-2016-9850-CVE-2016-9851.patch \
> %D%/packages/patches/openjpeg-CVE-2016-9572-CVE-2016-9573.patch \
> %D%/packages/patches/openldap-CVE-2017-9287.patch \
> diff --git a/gnu/packages/patches/openfoam-cleanup.patch b/gnu/packages/patches/openfoam-cleanup.patch
> new file mode 100644
> index 000000000..b2c0ddcd1
> --- /dev/null
> +++ b/gnu/packages/patches/openfoam-cleanup.patch
> @@ -0,0 +1,251 @@
> +# This patch removes all need for the ThirdParty files of OpenFOAM
> +
> +# Derived from easybuild patch: Ward Poelmans <wpoely86@gmail.com>
> +# Modified for GNU Guix: Paul Garlick <pgarlick@tourbillion-technology.com>
> +
> +diff -ur OpenFOAM-4.x-version-4.1.org/applications/utilities/mesh/manipulation/setSet/Allwmake OpenFOAM-4.x-version-4.1/applications/utilities/mesh/manipulation/setSet/Allwmake
> +--- OpenFOAM-4.x-version-4.1.org/applications/utilities/mesh/manipulation/setSet/Allwmake
> ++++ OpenFOAM-4.x-version-4.1/applications/utilities/mesh/manipulation/setSet/Allwmake
> +@@ -9,7 +9,7 @@
> + #
> + # use readline if available
> + #
> +-if [ -f /usr/include/readline/readline.h ]
> ++if true
> + then
> + echo "Found <readline/readline.h> -- enabling readline support."
> + export COMP_FLAGS="-DHAS_READLINE"
> +diff -ur OpenFOAM-4.x-version-4.1.org/etc/bashrc OpenFOAM-4.x-version-4.1/etc/bashrc
> +--- OpenFOAM-4.x-version-4.1.org/etc/bashrc
> ++++ OpenFOAM-4.x-version-4.1/etc/bashrc
> +@@ -43,8 +43,10 @@
> + # Please set to the appropriate path if the default is not correct.
> + #
> + [ $BASH_SOURCE ] && \
> +-export FOAM_INST_DIR=$(cd ${BASH_SOURCE%/*/*/*} && pwd -P) || \
> ++export FOAM_INST_DIR=$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P) || \
> + export FOAM_INST_DIR=$HOME/$WM_PROJECT
> ++# For GNU Guix: set initially for build then re-set at runtime
> ++#
> + # export FOAM_INST_DIR=~$WM_PROJECT
> + # export FOAM_INST_DIR=/opt/$WM_PROJECT
> + # export FOAM_INST_DIR=/usr/local/$WM_PROJECT
> +diff -ur OpenFOAM-4.x-version-4.1.org/etc/config.sh/CGAL OpenFOAM-4.x-version-4.1/etc/config.sh/CGAL
> +--- OpenFOAM-4.x-version-4.1.org/etc/config.sh/CGAL
> ++++ OpenFOAM-4.x-version-4.1/etc/config.sh/CGAL
> +@@ -36,37 +36,7 @@
> + #
> + #------------------------------------------------------------------------------
> +
> +-boost_version=boost-system
> +-cgal_version=cgal-system
> +-#cgal_version=CGAL-4.8
> +-
> +-if [ -z "$SOURCE_CGAL_VERSIONS_ONLY" ]
> +-then
> +-
> +- common_path=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER
> +-
> +- export BOOST_ARCH_PATH=$common_path/$boost_version
> +- export CGAL_ARCH_PATH=$common_path/$cgal_version
> +-
> +- if [ "$FOAM_VERBOSE" -a "$PS1" ]
> +- then
> +- echo "Using CGAL and boost" 1>&2
> +- echo " $cgal_version at $CGAL_ARCH_PATH" 1>&2
> +- echo " $boost_version at $BOOST_ARCH_PATH" 1>&2
> +- fi
> +-
> +- if [ -d "$CGAL_ARCH_PATH" -a "$cgal_version" != "cgal-system" ]
> +- then
> +- _foamAddLib $CGAL_ARCH_PATH/lib
> +- fi
> +-
> +- if [ -d "$BOOST_ARCH_PATH" -a "$boost_version" != "boost-system" ]
> +- then
> +- _foamAddLib $BOOST_ARCH_PATH/lib
> +- fi
> +-
> +- unset boost_version cgal_version common_path
> +-
> +-fi
> ++export CGAL_ARCH_PATH=$CGAL_ROOT
> ++export BOOST_ARCH_PATH=$BOOST_ROOT
> +
> + #------------------------------------------------------------------------------
> +diff -ur OpenFOAM-4.x-version-4.1.org/etc/config.sh/gperftools OpenFOAM-4.x-version-4.1/etc/config.sh/gperftools
> +--- OpenFOAM-4.x-version-4.1.org/etc/config.sh/gperftools 2016-10-16 16:11:45.000000000 +0200
> ++++ OpenFOAM-4.x-version-4.1/etc/config.sh/gperftools 2017-04-10 14:51:01.473221230 +0200
> +@@ -29,13 +29,13 @@
> + #
> + #------------------------------------------------------------------------------
> +
> +-version=svn
> +-gperftools_install=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER
> +-
> +-GPERFTOOLS_VERSION=gperftools-$version
> +-GPERFTOOLS_ARCH_PATH=$gperftools_install/$GPERFTOOLS_VERSION
> +-
> +-export PATH=$GPERFTOOLS_ARCH_PATH/bin:$PATH
> +-export LD_LIBRARY_PATH=$GPERFTOOLS_ARCH_PATH/lib:$LD_LIBRARY_PATH
> ++# version=svn
> ++# gperftools_install=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER
> ++#
> ++# GPERFTOOLS_VERSION=gperftools-$version
> ++# GPERFTOOLS_ARCH_PATH=$gperftools_install/$GPERFTOOLS_VERSION
> ++#
> ++# export PATH=$GPERFTOOLS_ARCH_PATH/bin:$PATH
> ++# export LD_LIBRARY_PATH=$GPERFTOOLS_ARCH_PATH/lib:$LD_LIBRARY_PATH
> +
> + #------------------------------------------------------------------------------
> +diff -ur OpenFOAM-4.x-version-4.1.org/etc/config.sh/metis OpenFOAM-4.x-version-4.1/etc/config.sh/metis
> +--- OpenFOAM-4.x-version-4.1.org/etc/config.sh/metis
> ++++ OpenFOAM-4.x-version-4.1/etc/config.sh/metis
> +@@ -34,7 +34,7 @@
> + #
> + #------------------------------------------------------------------------------
> +
> +-export METIS_VERSION=metis-5.1.0
> +-export METIS_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION/$METIS_VERSION
> ++export METIS_VERSION=metis-$METISVERSION
> ++export METIS_ARCH_PATH=$METIS_ROOT
> +
> + #------------------------------------------------------------------------------
> +diff -ur OpenFOAM-4.x-version-4.1.org/etc/config.sh/scotch OpenFOAM-4.x-version-4.1/etc/config.sh/scotch
> +--- OpenFOAM-4.x-version-4.1.org/etc/config.sh/scotch
> ++++ OpenFOAM-4.x-version-4.1/etc/config.sh/scotch
> +@@ -37,7 +37,7 @@
> + #
> + #------------------------------------------------------------------------------
> +
> +-export SCOTCH_VERSION=scotch_6.0.3
> +-export SCOTCH_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION/$SCOTCH_VERSION
> ++export SCOTCH_VERSION=scotch_$SCOTCHVERSION
> ++export SCOTCH_ARCH_PATH=$SCOTCH_ROOT
> +
> + #------------------------------------------------------------------------------
> +diff -ur OpenFOAM-4.x-version-4.1.org/etc/config.sh/settings OpenFOAM-4.x-version-4.1/etc/config.sh/settings
> +--- OpenFOAM-4.x-version-4.1.org/etc/config.sh/settings
> ++++ OpenFOAM-4.x-version-4.1/etc/config.sh/settings
> +@@ -279,6 +279,9 @@
> + ;;
> + system)
> + # Use system compiler
> ++ # Use system GMP and MPFR packages
> ++ export GMP_ARCH_PATH=$GMP_ROOT
> ++ export MPFR_ARCH_PATH=$MPFR_ROOT
> + ;;
> + *)
> + echo "Warn: WM_COMPILER_TYPE='$WM_COMPILER_TYPE' is unsupported" 1>&2
> +diff -ur OpenFOAM-4.x-version-4.1.org/src/parallel/decompose/ptscotchDecomp/Make/options OpenFOAM-4.x-version-4.1/src/parallel/decompose/ptscotchDecomp/Make/options
> +--- OpenFOAM-4.x-version-4.1.org/src/parallel/decompose/ptscotchDecomp/Make/options
> ++++ OpenFOAM-4.x-version-4.1/src/parallel/decompose/ptscotchDecomp/Make/options
> +@@ -5,8 +5,7 @@
> + $(PFLAGS) $(PINC) \
> + -I$(SCOTCH_ROOT)/include \
> + -I$(SCOTCH_ARCH_PATH)/include/$(FOAM_MPI) \
> +- -I/usr/include/scotch \
> + -I../decompositionMethods/lnInclude
> +
> + LIB_LIBS = \
> +- -L$(SCOTCH_ROOT)/lib -L$(FOAM_EXT_LIBBIN)/$(FOAM_MPI) -lptscotch -lptscotcherrexit -lscotch ${LINK_FLAGS} -lrt
> ++ -L$(SCOTCH_ROOT)/lib -L$(MPI_ARCH_PATH)/lib -lptscotch -lptscotcherrexit -lscotch ${LINK_FLAGS} -lrt
> +diff -ur OpenFOAM-4.x-version-4.1.org/src/parallel/decompose/scotchDecomp/Make/options OpenFOAM-4.x-version-4.1/src/parallel/decompose/scotchDecomp/Make/options
> +--- OpenFOAM-4.x-version-4.1.org/src/parallel/decompose/scotchDecomp/Make/options
> ++++ OpenFOAM-4.x-version-4.1/src/parallel/decompose/scotchDecomp/Make/options
> +@@ -9,8 +9,7 @@
> + $(PFLAGS) $(PINC) \
> + -I$(SCOTCH_ROOT)/include \
> + -I$(SCOTCH_ARCH_PATH)/include \
> +- -I/usr/include/scotch \
> + -I../decompositionMethods/lnInclude
> +
> + LIB_LIBS = \
> +- -L$(SCOTCH_ROOT)/lib -L$(FOAM_EXT_LIBBIN) -lscotch -lscotcherrexit -lrt
> ++ -L$(SCOTCH_ROOT)/lib -lscotch -lscotcherrexit -lrt
> +diff -ur OpenFOAM-4.x-version-4.1.org/wmake/src/Makefile OpenFOAM-4.x-version-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
> + #------------------------------------------------------------------------------
> +
> +-SHELL = /bin/sh
> ++# SHELL = /bin/sh
> +
> + #------------------------------------------------------------------------------
> + # Unset suffices list (suffix rules are not used)
> +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
> + #------------------------------------------------------------------------------
> +
> +-SHELL = /bin/sh
> ++# SHELL = /bin/sh
> +
> +
> + #------------------------------------------------------------------------------
> +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=$HOME/.$WM_PROJECT/.wmake
> ++ lockDir=$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P)/.$WM_PROJECT/.wmake
> +
> + 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:=$HOSTNAME}
> +
> +-lockDir=$HOME/.$WM_PROJECT/.wmake
> ++lockDir=$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P)/.$WM_PROJECT/.wmake
> +
> + # Fallback - 1 core on current host
> + : ${WM_HOSTS:=$HOST:1}
> +diff -ur OpenFOAM-4.x-version-4.1.org/wmake/wmakeSchedulerUptime OpenFOAM-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:=$HOSTNAME}
> +
> +-lockDir=$HOME/.$WM_PROJECT/.wmake
> ++lockDir=$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P)/.$WM_PROJECT/.wmake
> + # Fallback - 1 core on current host
> + : ${WM_HOSTS:=$HOST:1}
> +
> +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/metisDecomp.C
> ++++ OpenFOAM-4.x-version-4.1/src/parallel/decompose/metisDecomp/metisDecomp.C
> +@@ -67,7 +67,7 @@
> +
> + // Processor weights initialised with no size, only used if specified in
> + // a file
> +- Field<scalar> processorWeights;
> ++ Field<floatScalar> processorWeights;
> +
> + // Cell weights (so on the vertices of the dual)
> + List<label> cellWeights;
> +diff -ur OpenFOAM-4.x-version-4.1.org/wmake/rules/General/CGAL OpenFOAM-4.x-version-4.1/wmake/rules/General/CGAL
> +--- OpenFOAM-4.x-version-4.1.org/wmake/rules/General/CGAL
> ++++ OpenFOAM-4.x-version-4.1/wmake/rules/General/CGAL
> +@@ -6,8 +6,8 @@
> + -I/usr/include
> +
> + CGAL_LIBS = \
> +- -L$(MPFR_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \
> +- -L$(GMP_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \
> ++ -L$(MPFR_ARCH_PATH)/lib \
> ++ -L$(GMP_ARCH_PATH)/lib \
> + -L$(BOOST_ARCH_PATH)/lib \
> + -L$(CGAL_ARCH_PATH)/lib \
> + -lCGAL \
> 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 © 2017 Paul Garlick <pgarlick@tourbillion-technology.com>
> +;;;
> +;;; 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 <http://www.gnu.org/licenses/>.
> +
> +(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 "." "-")))

We have a couple other packages that use string-replace-substring, but
I personally think it's overkill for single-character replacements like
this.

FWIW:

scheme@(guile-user)> ,time
(let loop ((i 10000000))
(when (> i 0)
(string-replace-substring version "." "-")
(loop (- i 1)))))
;; 12.317051s real time, 16.041830s run time. 5.452976s spent in GC.
scheme@(guile-user)> ,time
(let loop ((i 10000000))
(when (> i 0)
(string-map (lambda (x) (if (eq? x #\.) #\- x)) version)
(loop (- i 1)))))
;; 3.586351s real time, 4.464542s run time. 1.285729s spent in GC.

Toggle quote (6 lines)
> + (file-name (string-append name "-" version ".tar.gz"))
> + (sha256
> + (base32 "1hgh2kw7fqv4bfachhbjhw16v8j35jbv6s576fmz4ka2q4ks4wg3"))
> + (patches (search-patches "openfoam-cleanup.patch"))
> + (modules '((guix build utils)))))

The modules field is not needed AFAICT. Usually only when a 'snippet'
is used.

Toggle quote (66 lines)
> + (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)))
> + (arguments
> + `(;; executable files and shared libraries are located in the 'platforms'
> + ;; 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
> + #: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)))))
> + (add-after 'patch-source-shebangs 'set-environment-variables
> + (lambda _
> + (let ((libraries '("boost" "cgal" "gmp" "metis" "mpfr" "scotch")))
> + ;; set variables to define store paths
> + (for-each (lambda (library)
> + (setenv (string-append
> + (string-upcase library) "_ROOT")
> + (assoc-ref %build-inputs library))) libraries))
> + ;; 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
> + (replace 'build
> + (lambda _
> + ;; compile OpenFOAM libraries and applications
> + (zero? (system (format #f
> + "source ./etc/bas
This message was truncated. Download the full message here.
R
R
Ricardo Wurmus wrote on 16 Aug 2017 16:03
control message for bug #28045
(address . control@debbugs.gnu.org)
E1dhyub-0006QS-VK@debbugs.gnu.org
tags 28045 moreinfo
P
P
Paul Garlick wrote on 16 Aug 2017 19:52
Re: [bug#28045] [PATCH] gnu: Add openfoam
(address . 28045@debbugs.gnu.org)
1502905946.2548.31.camel@tourbillion-technology.com
Hello Guix,
Thank you Marius and Eric for your reviews and comments.
I have been working through the changes and updating the patch.
 However, in the process of rebasing I have noticed a change in Guix
that impacts on the OpenFOAM definition.  Specifically, a recent commit
(26599d6) has changed the definition of the scotch package so that it
now uses 64bit integers.  In a nutshell, this causes a build failure in
OpenFOAM.
In OpenFOAM, there is a variable to specify the size of the integer
values (32bit or 64bit).  This single variable is used by both metis
and scotch, meaning that they both have to use 32bit integers or both
use 64bit integers.  At present, Guix offers a 64bit scotch and a 32bit
metis.
A straightforward solution would be to add the extra packages, a 32bit
scotch and/or a 64bit metis.  For scotch, that would be the same
definition, except for the 'INTSIZE64' line.  For metis, that would
involve an edit of 'metis.h', setting IDXTYPEWIDTH and REALTYPEWIDTH to
64.
Would you prefer this to be the subject of a separate patch, or
included in the OpenFOAM patch?  There is also a question about how to
name the packages; scotch and scotch32, for example, or scotch and
scotch-64int etc.
Best regards,
Paul
On Mon, 2017-08-14 at 21:49 -0500, Eric Bavier wrote:
Toggle quote (5 lines)
> Hello Paul,
>
> Thank you for the patch!
>
>
Attachment: file
E
E
Eric Bavier wrote on 16 Aug 2017 22:04
(address . 28045@debbugs.gnu.org)
17DA467A-7864-4EED-9F61-16D634A0B976@centurylink.net
Scotch's INTSIZE64 is a bit of a misnomer, as it simply tells scotch to use the 'long' type rather than 'int'. IIRC, Ludovic's rational was that this would be 32 bits or 64 bit integers depending on the platform.

I think this is a reasonable default, but, like you point out, it does mean we need to keep thing consistent across packages. For metis this might mean a build phase that patches metis.h's IDXTYPEWIDTH macro appropriately for the target system. That should be a separate patch.

Thanks for working on it,
`~Eric

On August 16, 2017 12:52:26 PM CDT, Paul Garlick <pgarlick@tourbillion-technology.com> wrote:
Toggle quote (31 lines)
>Hello Guix,
>Thank you Marius and Eric for your reviews and comments.
>I have been working through the changes and updating the patch.
> However, in the process of rebasing I have noticed a change in Guix
>that impacts on the OpenFOAM definition.  Specifically, a recent commit
>(26599d6) has changed the definition of the scotch package so that it
>now uses 64bit integers.  In a nutshell, this causes a build failure in
>OpenFOAM.
>In OpenFOAM, there is a variable to specify the size of the integer
>values (32bit or 64bit).  This single variable is used by both metis
>and scotch, meaning that they both have to use 32bit integers or both
>use 64bit integers.  At present, Guix offers a 64bit scotch and a 32bit
>metis.
>A straightforward solution would be to add the extra packages, a 32bit
>scotch and/or a 64bit metis.  For scotch, that would be the same
>definition, except for the 'INTSIZE64' line.  For metis, that would
>involve an edit of 'metis.h', setting IDXTYPEWIDTH and REALTYPEWIDTH to
>64.
>Would you prefer this to be the subject of a separate patch, or
>included in the OpenFOAM patch?  There is also a question about how to
>name the packages; scotch and scotch32, for example, or scotch and
>scotch-64int etc.
>Best regards,
>Paul
>On Mon, 2017-08-14 at 21:49 -0500, Eric Bavier wrote:
>> Hello Paul,
>>
>> Thank you for the patch!
>>
>>

--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
Attachment: file
P
P
Paul Garlick wrote on 17 Aug 2017 11:42
(address . 28045@debbugs.gnu.org)
1502962978.2875.25.camel@tourbillion-technology.com
Hi Eric,

Toggle quote (3 lines)
> For metis this might mean a build phase that patches metis.h's
> IDXTYPEWIDTH macro appropriately for the target system. 

I think this would work, in the sense of allowing OpenFOAM to build.
 There has been a recent FreeBSD bug report on this issue:



The REALTYPEWIDTH would also need to be set to 64-bit for OpenFOAM to
avoid a related build problem.

However, there could be an argument not to do it this way.  That is,
with this approach the choice between 32bit and 64bit integers is made
according to the system architecture.  For OpenFOAM, and perhaps other
Guix packages too, there is also a consideration of memory usage and
speed.  

The current default in OpenFOAM is to use 32bit integers, even on 64bit
systems.  The reasoning is that the need for indexing beyond the 2^32
limit is restricted to the corner-case of dealing with very large
graphs on single processors.  The computations become very time
consuming and an attractive alternative in many cases is to parallelise
the problem, thereby avoiding the limit.

To stick with the OpenFOAM default a 32bit version of scotch/pt-scotch
would be needed.  This would mean either reverting commit 26599d6, or
introducing a new scotch32 package, the same as the previous
definition, guaranteed to use 32bit integers.

WDYT?

Paul.
L
L
Ludovic Courtès wrote on 22 Aug 2017 15:02
(name . Paul Garlick)(address . pgarlick@tourbillion-technology.com)
87r2w369im.fsf@gnu.org
Hi Paul,

Paul Garlick <pgarlick@tourbillion-technology.com> skribis:

Toggle quote (5 lines)
> To stick with the OpenFOAM default a 32bit version of scotch/pt-scotch
> would be needed.  This would mean either reverting commit 26599d6, or
> introducing a new scotch32 package, the same as the previous
> definition, guaranteed to use 32bit integers.

I think we should introduce a “scotch32” variant (with a clear
explanation of what the “32” means).

Thoughts?

Ludo’.
P
P
Paul Garlick wrote on 22 Aug 2017 19:10
(name . Ludovic Courtès)(address . ludo@gnu.org)
1503421859.3048.11.camel@tourbillion-technology.com
Hi Ludo,

Toggle quote (3 lines)
> I think we should introduce a “scotch32” variant (with a clear
> explanation of what the “32” means).

I think this is the most flexible approach.  Packages could then select
the standard 'scotch' or, if preferred, the 'scotch32' variant, if
memory usage or performance is a concern.

A method of implementing this would be for 'scotch32' to inherit the
'scotch' definition, replacing the configure phase with a similar
section specifying INTSIZE32 instead of INTSIZE64.  This would be
similar to the Debian approach, in which a different Makefile.inc is
used for 32-bit and 64-bit integers.

A new package 'pt-scotch32' would then be the same as 'pt-scotch' but
inherit from 'scotch32' instead of 'scotch'.

Any comments?

Paul.
L
L
Ludovic Courtès wrote on 23 Aug 2017 00:33
(name . Paul Garlick)(address . pgarlick@tourbillion-technology.com)
874lsznsgn.fsf@gnu.org
Hi Paul,

Paul Garlick <pgarlick@tourbillion-technology.com> skribis:

Toggle quote (11 lines)
> A method of implementing this would be for 'scotch32' to inherit the
> 'scotch' definition, replacing the configure phase with a similar
> section specifying INTSIZE32 instead of INTSIZE64.  This would be
> similar to the Debian approach, in which a different Makefile.inc is
> used for 32-bit and 64-bit integers.
>
> A new package 'pt-scotch32' would then be the same as 'pt-scotch' but
> inherit from 'scotch32' instead of 'scotch'.
>
> Any comments?

This sounds like the right approach to me (you could even omit
‘pt-scotch32’ as a first stab if you don’t need it for Openfoam.)

Ludo’.
P
P
Paul Garlick wrote on 30 Aug 2017 17:08
(name . Ludovic Courtès)(address . ludo@gnu.org)
1504105724.3260.10.camel@tourbillion-technology.com
Hi Guix,

Toggle quote (3 lines)
> This sounds like the right approach to me (you could even omit
> ‘pt-scotch32’ as a first stab if you don’t need it for Openfoam.)

I have submitted a patch for 'scotch32' and'pt-scotch32' packages (bugs
#28220 and #28221).  OpenFoam depends on both of them.

After the scotch32 patches have been committed I will rebase again and
re-check that the build succeeds  before re-submitting the OpenFoam
patch.

Best regards,

Paul.
P
P
Paul Garlick wrote on 6 Sep 2017 23:28
[PATCH] gnu: Add openfoam
(address . 28045@debbugs.gnu.org)
20170906212801.4311-1-pgarlick@tourbillion-technology.com
*gnu/packages/patches/openfoam-4.1-cleanup.patch: New file
*gnu/packages/simulation.scm: New file
*gnu/local.mk (GNU_SYSTEM_MODULES): Add module
(dist_patch_DATA): Add patch
---
gnu/local.mk | 2 +
gnu/packages/patches/openfoam-4.1-cleanup.patch | 239 ++++++++++++++++++++++++
gnu/packages/simulation.scm | 198 ++++++++++++++++++++
3 files changed, 439 insertions(+)
create mode 100644 gnu/packages/patches/openfoam-4.1-cleanup.patch
create mode 100644 gnu/packages/simulation.scm

Hello Guix,

Please find the updated patch for OpenFOAM below.

Thank you for the reviews. I have implemented the suggestions made by Ludo,
Eric and Marius, barring a couple of exceptions noted below.

I have also changed the filename for the patch, in order to include the version.
This will allow new versions to have their own patches.

Lastly, I have added a section in the patch to rename the 'lockDir' variable
temporarily for the build phase. It is reset in the 'update-configuration-files'
phase.

In answer to the specific comments:

Toggle quote (5 lines)
>> +- Field<scalar> processorWeights;
>> ++ Field<floatScalar> processorWeights;
>
>This seems unrelated to unbundling :) Is this a known issue?

Yes, this is OpenFOAM bug#0002085. I believe a fix has been implemented so
that this part of the patch will not be needed in future versions.

Toggle quote (6 lines)
>> + #: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?

I think it would be difficult to make a change here, without risking disruption
to internal paths and external (user) scripts.

Toggle quote (8 lines)
>> + ;; 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.

This variable is often used in user aliases and scripts. It is used as the
starting point for navigating the OpenFOAM directory structure. Other
installation methods make the variable immediately available. If it were
missing in the Guix package it would be necessary to add an explanation
of how it should be set.

Toggle quote (4 lines)
>> * gnu/packages/simulation.scm: New file
>
>Would this package not fit nicely in gnu/packages/engineering.scm?

In fact, there was some discussion on this question when I submitted the
original patch:


I think the 'simulation' module is the best idea since there are also many
non-engineering applications such as biomedical and geophysical modelling.

Best regards,

Paul.


Toggle diff (408 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index 643a88db8..048f7aa1c 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -363,6 +363,7 @@ GNU_SYSTEM_MODULES = \
%D%/packages/shells.scm \
%D%/packages/shellutils.scm \
%D%/packages/simh.scm \
+ %D%/packages/simulation.scm \
%D%/packages/skarnet.scm \
%D%/packages/skribilo.scm \
%D%/packages/slang.scm \
@@ -886,6 +887,7 @@ dist_patch_DATA = \
%D%/packages/patches/ola-readdir-r.patch \
%D%/packages/patches/openscenegraph-ffmpeg3.patch \
%D%/packages/patches/openexr-missing-samples.patch \
+ %D%/packages/patches/openfoam-4.1-cleanup.patch \
%D%/packages/patches/openjpeg-CVE-2017-12982.patch \
%D%/packages/patches/openjpeg-CVE-2017-14040.patch \
%D%/packages/patches/openjpeg-CVE-2017-14041.patch \
diff --git a/gnu/packages/patches/openfoam-4.1-cleanup.patch b/gnu/packages/patches/openfoam-4.1-cleanup.patch
new file mode 100644
index 000000000..590db5982
--- /dev/null
+++ b/gnu/packages/patches/openfoam-4.1-cleanup.patch
@@ -0,0 +1,239 @@
+# This patch removes all need for the ThirdParty files of OpenFOAM
+
+# Derived from easybuild patch: Ward Poelmans <wpoely86@gmail.com>
+# Modified for GNU Guix: Paul Garlick <pgarlick@tourbillion-technology.com>
+
+diff -ur OpenFOAM-4.x-version-4.1.org/applications/utilities/mesh/manipulation/setSet/Allwmake OpenFOAM-4.x-version-4.1/applications/utilities/mesh/manipulation/setSet/Allwmake
+--- OpenFOAM-4.x-version-4.1.org/applications/utilities/mesh/manipulation/setSet/Allwmake
++++ OpenFOAM-4.x-version-4.1/applications/utilities/mesh/manipulation/setSet/Allwmake
+@@ -9,7 +9,7 @@
+ #
+ # use readline if available
+ #
+-if [ -f /usr/include/readline/readline.h ]
++if true
+ then
+ echo "Found <readline/readline.h> -- enabling readline support."
+ export COMP_FLAGS="-DHAS_READLINE"
+diff -ur OpenFOAM-4.x-version-4.1.org/etc/bashrc OpenFOAM-4.x-version-4.1/etc/bashrc
+--- OpenFOAM-4.x-version-4.1.org/etc/bashrc
++++ OpenFOAM-4.x-version-4.1/etc/bashrc
+@@ -43,8 +43,10 @@
+ # Please set to the appropriate path if the default is not correct.
+ #
+ [ $BASH_SOURCE ] && \
+-export FOAM_INST_DIR=$(cd ${BASH_SOURCE%/*/*/*} && pwd -P) || \
++export FOAM_INST_DIR=$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P) || \
+ export FOAM_INST_DIR=$HOME/$WM_PROJECT
++# For GNU Guix: set initially for build then re-set at runtime
++#
+ # export FOAM_INST_DIR=~$WM_PROJECT
+ # export FOAM_INST_DIR=/opt/$WM_PROJECT
+ # export FOAM_INST_DIR=/usr/local/$WM_PROJECT
+diff -ur OpenFOAM-4.x-version-4.1.org/etc/config.sh/CGAL OpenFOAM-4.x-version-4.1/etc/config.sh/CGAL
+--- OpenFOAM-4.x-version-4.1.org/etc/config.sh/CGAL
++++ OpenFOAM-4.x-version-4.1/etc/config.sh/CGAL
+@@ -36,37 +36,7 @@
+ #
+ #------------------------------------------------------------------------------
+
+-boost_version=boost-system
+-cgal_version=cgal-system
+-#cgal_version=CGAL-4.8
+-
+-if [ -z "$SOURCE_CGAL_VERSIONS_ONLY" ]
+-then
+-
+- common_path=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER
+-
+- export BOOST_ARCH_PATH=$common_path/$boost_version
+- export CGAL_ARCH_PATH=$common_path/$cgal_version
+-
+- if [ "$FOAM_VERBOSE" -a "$PS1" ]
+- then
+- echo "Using CGAL and boost" 1>&2
+- echo " $cgal_version at $CGAL_ARCH_PATH" 1>&2
+- echo " $boost_version at $BOOST_ARCH_PATH" 1>&2
+- fi
+-
+- if [ -d "$CGAL_ARCH_PATH" -a "$cgal_version" != "cgal-system" ]
+- then
+- _foamAddLib $CGAL_ARCH_PATH/lib
+- fi
+-
+- if [ -d "$BOOST_ARCH_PATH" -a "$boost_version" != "boost-system" ]
+- then
+- _foamAddLib $BOOST_ARCH_PATH/lib
+- fi
+-
+- unset boost_version cgal_version common_path
+-
+-fi
++export CGAL_ARCH_PATH=$CGAL_ROOT
++export BOOST_ARCH_PATH=$BOOST_ROOT
+
+ #------------------------------------------------------------------------------
+diff -ur OpenFOAM-4.x-version-4.1.org/etc/config.sh/gperftools OpenFOAM-4.x-version-4.1/etc/config.sh/gperftools
+--- OpenFOAM-4.x-version-4.1.org/etc/config.sh/gperftools 2016-10-16 16:11:45.000000000 +0200
++++ OpenFOAM-4.x-version-4.1/etc/config.sh/gperftools 2017-04-10 14:51:01.473221230 +0200
+@@ -29,13 +29,13 @@
+ #
+ #------------------------------------------------------------------------------
+
+-version=svn
+-gperftools_install=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER
+-
+-GPERFTOOLS_VERSION=gperftools-$version
+-GPERFTOOLS_ARCH_PATH=$gperftools_install/$GPERFTOOLS_VERSION
+-
+-export PATH=$GPERFTOOLS_ARCH_PATH/bin:$PATH
+-export LD_LIBRARY_PATH=$GPERFTOOLS_ARCH_PATH/lib:$LD_LIBRARY_PATH
++# version=svn
++# gperftools_install=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER
++#
++# GPERFTOOLS_VERSION=gperftools-$version
++# GPERFTOOLS_ARCH_PATH=$gperftools_install/$GPERFTOOLS_VERSION
++#
++# export PATH=$GPERFTOOLS_ARCH_PATH/bin:$PATH
++# export LD_LIBRARY_PATH=$GPERFTOOLS_ARCH_PATH/lib:$LD_LIBRARY_PATH
+
+ #------------------------------------------------------------------------------
+diff -ur OpenFOAM-4.x-version-4.1.org/etc/config.sh/metis OpenFOAM-4.x-version-4.1/etc/config.sh/metis
+--- OpenFOAM-4.x-version-4.1.org/etc/config.sh/metis
++++ OpenFOAM-4.x-version-4.1/etc/config.sh/metis
+@@ -34,7 +34,7 @@
+ #
+ #------------------------------------------------------------------------------
+
+-export METIS_VERSION=metis-5.1.0
+-export METIS_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION/$METIS_VERSION
++export METIS_VERSION=metis-$METISVERSION
++export METIS_ARCH_PATH=$METIS_ROOT
+
+ #------------------------------------------------------------------------------
+diff -ur OpenFOAM-4.x-version-4.1.org/etc/config.sh/scotch OpenFOAM-4.x-version-4.1/etc/config.sh/scotch
+--- OpenFOAM-4.x-version-4.1.org/etc/config.sh/scotch
++++ OpenFOAM-4.x-version-4.1/etc/config.sh/scotch
+@@ -37,7 +37,7 @@
+ #
+ #------------------------------------------------------------------------------
+
+-export SCOTCH_VERSION=scotch_6.0.3
+-export SCOTCH_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION/$SCOTCH_VERSION
++export SCOTCH_VERSION=scotch_$SCOTCHVERSION
++export SCOTCH_ARCH_PATH=$SCOTCH_ROOT
+
+ #------------------------------------------------------------------------------
+diff -ur OpenFOAM-4.x-version-4.1.org/etc/config.sh/settings OpenFOAM-4.x-version-4.1/etc/config.sh/settings
+--- OpenFOAM-4.x-version-4.1.org/etc/config.sh/settings
++++ OpenFOAM-4.x-version-4.1/etc/config.sh/settings
+@@ -279,6 +279,9 @@
+ ;;
+ system)
+ # Use system compiler
++ # Use system GMP and MPFR packages
++ export GMP_ARCH_PATH=$GMP_ROOT
++ export MPFR_ARCH_PATH=$MPFR_ROOT
+ ;;
+ *)
+ echo "Warn: WM_COMPILER_TYPE='$WM_COMPILER_TYPE' is unsupported" 1>&2
+diff -ur OpenFOAM-4.x-version-4.1.org/src/parallel/decompose/ptscotchDecomp/Make/options OpenFOAM-4.x-version-4.1/src/parallel/decompose/ptscotchDecomp/Make/options
+--- OpenFOAM-4.x-version-4.1.org/src/parallel/decompose/ptscotchDecomp/Make/options
++++ OpenFOAM-4.x-version-4.1/src/parallel/decompose/ptscotchDecomp/Make/options
+@@ -5,8 +5,7 @@
+ $(PFLAGS) $(PINC) \
+ -I$(SCOTCH_ROOT)/include \
+ -I$(SCOTCH_ARCH_PATH)/include/$(FOAM_MPI) \
+- -I/usr/include/scotch \
+ -I../decompositionMethods/lnInclude
+
+ LIB_LIBS = \
+- -L$(SCOTCH_ROOT)/lib -L$(FOAM_EXT_LIBBIN)/$(FOAM_MPI) -lptscotch -lptscotcherrexit -lscotch ${LINK_FLAGS} -lrt
++ -L$(SCOTCH_ROOT)/lib -L$(MPI_ARCH_PATH)/lib -lptscotch -lptscotcherrexit -lscotch ${LINK_FLAGS} -lrt
+diff -ur OpenFOAM-4.x-version-4.1.org/src/parallel/decompose/scotchDecomp/Make/options OpenFOAM-4.x-version-4.1/src/parallel/decompose/scotchDecomp/Make/options
+--- OpenFOAM-4.x-version-4.1.org/src/parallel/decompose/scotchDecomp/Make/options
++++ OpenFOAM-4.x-version-4.1/src/parallel/decompose/scotchDecomp/Make/options
+@@ -9,8 +9,7 @@
+ $(PFLAGS) $(PINC) \
+ -I$(SCOTCH_ROOT)/include \
+ -I$(SCOTCH_ARCH_PATH)/include \
+- -I/usr/include/scotch \
+ -I../decompositionMethods/lnInclude
+
+ LIB_LIBS = \
+- -L$(SCOTCH_ROOT)/lib -L$(FOAM_EXT_LIBBIN) -lscotch -lscotcherrexit -lrt
++ -L$(SCOTCH_ROOT)/lib -lscotch -lscotcherrexit -lrt
+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
+ #------------------------------------------------------------------------------
+
+-SHELL = /bin/sh
++# SHELL = /bin/sh
+
+
+ #------------------------------------------------------------------------------
+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=$HOME/.$WM_PROJECT/.wmake
++ lockDir=$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P)/.$WM_PROJECT/.wmake
+
+ 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:=$HOSTNAME}
+
+-lockDir=$HOME/.$WM_PROJECT/.wmake
++lockDir=$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P)/.$WM_PROJECT/.wmake
+
+ # Fallback - 1 core on current host
+ : ${WM_HOSTS:=$HOST:1}
+diff -ur OpenFOAM-4.x-version-4.1.org/wmake/wmakeSchedulerUptime OpenFOAM-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:=$HOSTNAME}
+
+-lockDir=$HOME/.$WM_PROJECT/.wmake
++lockDir=$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P)/.$WM_PROJECT/.wmake
+ # Fallback - 1 core on current host
+ : ${WM_HOSTS:=$HOST:1}
+
+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/metisDecomp.C
++++ OpenFOAM-4.x-version-4.1/src/parallel/decompose/metisDecomp/metisDecomp.C
+@@ -67,7 +67,7 @@
+
+ // Processor weights initialised with no size, only used if specified in
+ // a file
+- Field<scalar> processorWeights;
++ Field<floatScalar> processorWeights;
+
+ // Cell weights (so on the vertices of the dual)
+ List<label> cellWeights;
+diff -ur OpenFOAM-4.x-version-4.1.org/wmake/rules/General/CGAL OpenFOAM-4.x-version-4.1/wmake/rules/General/CGAL
+--- OpenFOAM-4.x-version-4.1.org/wmake/rules/General/CGAL
++++ OpenFOAM-4.x-version-4.1/wmake/rules/General/CGAL
+@@ -6,8 +6,8 @@
+ -I/usr/include
+
+ CGAL_LIBS = \
+- -L$(MPFR_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \
+- -L$(GMP_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \
++ -L$(MPFR_ARCH_PATH)/lib \
++ -L$(GMP_ARCH_PATH)/lib \
+ -L$(BOOST_ARCH_PATH)/lib \
+ -L$(CGAL_ARCH_PATH)/lib \
+ -lCGAL \
diff --git a/gnu/packages/simulation.scm b/gnu/packages/simulation.scm
new file mode 100644
index 000000000..3446d72c6
--- /dev/null
+++ b/gnu/packages/simulation.scm
@@ -0,0 +1,198 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Paul Garlick <pgarlick@tourbillion-technology.com>
+;;;
+;;; 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 <http://www.gnu.org/licenses/>.
+
+(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-map (lambda (x) (if (eq? x #\.) #\- x)) version)))
+ (file-name (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32 "1hgh2kw7fqv4bfachhbjhw16v8j35jbv6s576fmz4ka2q4ks4wg3"))
+ (patches (search-patches "openfoam-4.1-cleanup.patch"))))
+ (build-system gnu-build-system)
+ (inputs
+ `(("boost" ,boost)
+ ("cgal" ,cgal)
+ ("flex" ,flex)
+ ("git" ,git)
+ ("gmp" ,gmp)
+ ("libxt" ,libxt)
+ ("metis" ,metis)
+ ("mpfr" ,mpfr)
+ ("ncurses" ,ncurses)
+ ("readline" ,readline)
+ ("scotch" ,pt-scotch32)
+ ("zlib" ,zlib)))
+ (native-inputs
+ `(("bison" ,bison)))
+ (propagated-inputs
+ `(("gzip" ,gzip)
+ ("gnuplot" ,gnuplot)
+ ("openmpi" ,openmpi)))
+ (arguments
+ `(#:strip-directories (list (string-append
+ "OpenFOAM-" ,version
+ "/platforms/linux64GccDPInt32Opt/bin")
+ (string-append
+ "OpenFOAM-" ,version
+ "/platforms/linux64GccDPInt32Opt/lib"))
+ ; executable files and shared libraries are
+ ; located in the 'platforms' subdirectory
+ #:validate-runpath? #f ; '#:elf-directories' is not recognised here
+ #:tests? #f ; no tests to run
+ #: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 pathname 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)))
+ (rename-file unpack-dir build-dir) ; re-name build directory
+ (chdir (basename build-dir))) ; move to build directory
+ #t))
+ (add-after 'patch-source-shebangs 'set-environment-variables
+ (lambda _
+ (let ((libraries '("boost" "cgal" "gmp" "metis" "mpfr" "scotch")))
+ ;; set variables to define store paths
+ (for-each (lambda (library)
+ (setenv (string-append
+ (string-upcase library) "_ROOT")
+ (assoc-ref %build-inputs library))) libraries))
+ ;; set variables to define package versions
+ (setenv "SCOTCHVERSION" ,(package-version scotch))
+ (setenv "METISVERSION" ,(package-version metis))
+ #t))
+ (delete 'configure) ; no configure phase
+ (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 _
+ ;; record store paths and package versions in configuration files
+
This message was truncated. Download the full message here.
L
L
Ludovic Courtès wrote on 7 Sep 2017 13:57
(name . Paul Garlick)(address . pgarlick@tourbillion-technology.com)
87r2viwwkp.fsf@gnu.org
Hi Paul,

I made the modifications below (mostly cosmetic) and built it locally.

However, the resulting layout, with /OpenFOAM-4.1 at the root and
essentially all the source tree beneath it, is unsatisfying.

Would it be possible to follow a layout closer to what we usually do:

/gnu/store/…-openfoam-4.1
bin/
lib/
share/
etc/

If the answer is “no”, or if that would take an unreasonable amount of
work which should really be upstream’s job, then I can understand and we
can make an exception.

Or perhaps there’s a middle ground we could find? For instance, we
install the tree to lib/openfoam-4.1, and then create bin/ as a symlink
to lib/openfoam-4.1/platforms/linux64GccDPInt32Opt/bin? Would that
work?

Thank you!

Ludo’.
Attachment: file
P
P
Paul Garlick wrote on 8 Sep 2017 00:41
Re: [PATCH] gnu: Add openfoam]
(address . 28045@debbugs.gnu.org)
1504824095.3116.41.camel@tourbillion-technology.com
Hi Ludo,
Thank you for your comments on the OpenFOAM layout.
Toggle quote (2 lines)
>
> Would it be possible to follow a layout closer to what we usually do:
There are some advantages of keeping the standard OpenFOAM layout,
different though it is.  Firstly, if it the layout remains upstream's
responsibility it makes the Guix maintenance task simpler.  Secondly,
OpenFOAM users will immediately recognise the standard structure.
Toggle quote (2 lines)
>
> Or perhaps there’s a middle ground we could find?  
Possibly but we would need to think of a way to avoid version clashes.
 
One objective in packaging OpenFOAM for Guix is to allow users to have
multiple versions of OpenFOAM installed at once.  This is a common
requirement in the OpenFOAM world since user development and upstream
development are independent.  However, it can be difficult to achieve,
especially in a multi-user environment.  Guix can offer an advantage
over alternative methods of installation in this respect.
To explain, imagine two OpenFOAM versions, A and B.  If we use the
OpenFOAM standard layout and install both with Guix we have:
$GUIX_PROFILE/OpenFOAM-A
                                  /OpenFOAM-B
A user might set up an alias to initialize the OpenFOAM environment
variables for version A:
$ alias startOFA='foamDotFile=$FOAM_INST_DIR/OpenFOAM-A/etc/bashrc; [
-f $foamDotFile ] && . $foamDotFile'
Similarly, a 'startOFB' alias could be defined.  The user could then
choose the version for the particular task, or even use both versions
simultaneously in separate shells.
Could we achieve this versatility using a Guix-like layout?  A possible
problem might be executable files in version B clashing with executable
files of the same name in version A, if they both share the
$GUIX_PROFILE/bin directory.
WDYT?
Paul.
Attachment: file
L
L
Ludovic Courtès wrote on 8 Sep 2017 10:23
Re: [PATCH] gnu: Add openfoam
(name . Paul Garlick)(address . pgarlick@tourbillion-technology.com)(address . 28045@debbugs.gnu.org)
87y3ppk39y.fsf@gnu.org
Hi Paul,

Paul Garlick <pgarlick@tourbillion-technology.com> skribis:

Toggle quote (7 lines)
>> Would it be possible to follow a layout closer to what we usually do:
>
> There are some advantages of keeping the standard OpenFOAM layout,
> different though it is.  Firstly, if it the layout remains upstream's
> responsibility it makes the Guix maintenance task simpler.  Secondly,
> OpenFOAM users will immediately recognise the standard structure.

OK, makes sense.

Toggle quote (8 lines)
>> Or perhaps there’s a middle ground we could find?  
>
> Possibly but we would need to think of a way to avoid version clashes.
>  
>
> One objective in packaging OpenFOAM for Guix is to allow users to have
> multiple versions of OpenFOAM installed at once.  This is a common

[...]

Toggle quote (5 lines)
> Could we achieve this versatility using a Guix-like layout?  A possible
> problem might be executable files in version B clashing with executable
> files of the same name in version A, if they both share the
> $GUIX_PROFILE/bin directory.

If we provide a bin/ directory, then trying to install two different
versions in the same profile will lead to a clash (and anyway, Guix
raises an error when trying to install two different packages that have
the same name in the same profile).

However, Guix supports multiple profiles, so one can always do:

guix package -i openfoam@1.2 -p old-openfoam
guix package -i openfoam@2.0 -p new-openfoam

./old-openfoam/bin/openfoam
./new-openfoam/bin/openfoam

Or, alternatively:

$ guix environment --ad-hoc openfoam@3.4
[env]$ $GUIX_PROFILE/bin/…

Does it address the use case you have in mind?

That’s how we deal with conflicting package version requirements in the
vast majority of cases. There are also some packages for which
upstream’s build system explicitly supports “parallel installation” of
different versions (Guile, Python, GLib, etc.).

Thanks,
Ludo’.
P
P
Paul Garlick wrote on 8 Sep 2017 13:32
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 28045@debbugs.gnu.org)
1504870325.2630.39.camel@tourbillion-technology.com
Hi Ludo,


Toggle quote (2 lines)
> Does it address the use case you have in mind?

Yes, I think that both the multiple-profile solution and the 'ad-hoc'
environment will work for Guix/OpenFOAM.  

The traditional method of installing multiple OpenFOAM versions is to
install to a common $FOAM_INST_DIR directory.  However, as you point
out, this is not strictly necessary and does not provide any advantage
in the Guix system.

So, continuing the 'middle road' line of thought, the 'install-dir'
variable would be modified to add a '/lib' element:

-                                %output "/OpenFOAM-" ,version)))
+                                %output "/OpenFOAM-" ,version
"/lib")))

You suggest adding a link between bin and lib/OpenFOAM-
4.1/platforms/linux64GccDPInt32Opt/bin.  What would be the best way to
add this to the package definition?  

There could also be a link between lib and lib/OpenFOAM-
4.1/platforms/linux64GccDPInt32Opt/lib.

The links would allow the runpaths to be validated.  So; 

-       #:validate-runpath? #f ; '#:elf-directories' is not recognised
here

The FOAM_INST_DIR variable would need to be updated:

-            (files '(".")))))
 +          (files '("./lib")))))

WDYT?

Paul.
E
E
Eric Bavier wrote on 8 Sep 2017 17:34
Re: [bug#28045] [PATCH] gnu: Add openfoam
(name . Paul Garlick)(address . pgarlick@tourbillion-technology.com)
513001199.42346965.1504884898846.JavaMail.root@centurylink.net
----- Original Message -----
Toggle quote (42 lines)
> Hi Ludo,
>
>
> > Does it address the use case you have in mind?
>
> Yes, I think that both the multiple-profile solution and the 'ad-hoc'
> environment will work for Guix/OpenFOAM.
>
> The traditional method of installing multiple OpenFOAM versions is to
> install to a common $FOAM_INST_DIR directory.  However, as you point
> out, this is not strictly necessary and does not provide any
> advantage
> in the Guix system.
>
> So, continuing the 'middle road' line of thought, the 'install-dir'
> variable would be modified to add a '/lib' element:
>
> -                                %output "/OpenFOAM-" ,version)))
> +                                %output "/OpenFOAM-" ,version
> "/lib")))
>
> You suggest adding a link between bin and lib/OpenFOAM-
> 4.1/platforms/linux64GccDPInt32Opt/bin.  What would be the best way
> to
> add this to the package definition?
>
> There could also be a link between lib and lib/OpenFOAM-
> 4.1/platforms/linux64GccDPInt32Opt/lib.
>
> The links would allow the runpaths to be validated.  So;
>
> -       #:validate-runpath? #f ; '#:elf-directories' is not
> recognised
> here
>
> The FOAM_INST_DIR variable would need to be updated:
>
> -            (files '(".")))))
>  +          (files '("./lib")))))
>
> WDYT?>

It seems to me that if using Guix's profiles and environments, we could entirely do without OpenFOAM's installation directories and simply install into a standard bin/lib structure. Just install libraries into (string-append %output "/lib") and the binaries into (string-append %output "/bin").

`~Eric
L
L
Ludovic Courtès wrote on 8 Sep 2017 17:39
Re: [PATCH] gnu: Add openfoam
(name . Paul Garlick)(address . pgarlick@tourbillion-technology.com)(address . 28045@debbugs.gnu.org)
87shfx9p43.fsf@gnu.org
Hi Paul,

Paul Garlick <pgarlick@tourbillion-technology.com> skribis:

Toggle quote (5 lines)
>> Does it address the use case you have in mind?
>
> Yes, I think that both the multiple-profile solution and the 'ad-hoc'
> environment will work for Guix/OpenFOAM.  

Good!

Toggle quote (7 lines)
> So, continuing the 'middle road' line of thought, the 'install-dir'
> variable would be modified to add a '/lib' element:
>
> -                                %output "/OpenFOAM-" ,version)))
> +                                %output "/OpenFOAM-" ,version
> "/lib")))

Sounds good.

Toggle quote (4 lines)
> You suggest adding a link between bin and lib/OpenFOAM-
> 4.1/platforms/linux64GccDPInt32Opt/bin.  What would be the best way to
> add this to the package definition?  

Perhaps adding an extra phase at the end that simply calls ‘symlink’?

Toggle quote (3 lines)
> There could also be a link between lib and lib/OpenFOAM-
> 4.1/platforms/linux64GccDPInt32Opt/lib.

Yes.

Toggle quote (5 lines)
> The links would allow the runpaths to be validated.  So; 
>
> -       #:validate-runpath? #f ; '#:elf-directories' is not recognised
> here

That’d be great. If that phase errors out, it probably means that the
binaries won’t work out of the box, so it’s good to fix it.

(BTW, please note that executables should go to bin/, libraries and
other architecture-dependent files to lib/, and share/ is for
architecture-independent stuff. I suppose we’ll only have bin/ and lib/
for a start, that’s OK.)

Toggle quote (5 lines)
> The FOAM_INST_DIR variable would need to be updated:
>
> -            (files '(".")))))
>  +          (files '("./lib")))))

I really dislike this FOAM_INST_DIR variable (usually packages “know”
where they are installed and don’t need an extra variable for that), but
if it has to be there, then so be it. :-)

I think we should be all set? I’ll wait for your hopefully last patch
revision!

Besides, for the future, if you have an opportunity to discuss these
matters with upstream, I’d recommend suggesting the addition of a proper
installation phase (“make install”), and also support at least for an
installation prefix, and ideally for more directory categories (see

Thanks for your patience!

Ludo’.
L
L
Ludovic Courtès wrote on 8 Sep 2017 22:30
Re: [bug#28045] [PATCH] gnu: Add openfoam
(name . Eric Bavier)(address . ericbavier@centurylink.net)
87ingt9blp.fsf@gnu.org
Hi Eric,

Eric Bavier <ericbavier@centurylink.net> skribis:

Toggle quote (2 lines)
> It seems to me that if using Guix's profiles and environments, we could entirely do without OpenFOAM's installation directories and simply install into a standard bin/lib structure. Just install libraries into (string-append %output "/lib") and the binaries into (string-append %output "/bin").

Fair enough. I guess the question is more whether (1) this would work
:-), and (2) whether seasoned OpenFOAM users would be happy with this.

WDYT, Paul?

Ludo’.
P
P
Paul Garlick wrote on 11 Sep 2017 11:18
(address . 28045@debbugs.gnu.org)
1505121536.2356.21.camel@tourbillion-technology.com
Hi Ludo and Eric,
I think it is helpful to consider this question in two ways; thinking
about the short term and the longer term.  I think in the short term it
is best to stick with the OpenFOAM-standard layout, modified in the
'middle-road' way suggested earlier.  On top of the previous points
made, there is an additional advantage to this approach in that the
OpenFOAM-standard layout has been thoroughly tested in production use
over many years.
In the longer term I think it would be possible to develop a Guix-
standard layout.  I cannot see any reason why this would not work.
 However, with a large system such as OpenFOAM, this may not
necessarily be an easy task.  I see this as principally an upstream
job, since they are the most knowledgeable people on the current layout
and are best placed to deal with any subleties involved.  With a
working Guix package in place it will be a good time to contact
upstream and discuss the merits of a new layout.
Today I hope to finish the package definition.  I have placed the tree
under the 'lib' directory and this allows the 'validate-runpath' phase
to run.  The phase currently fails as ld-wrapper does not add the
runpaths of the shared objects in the build tree.  I plan to use
patchelf to fix this.
Paul.
On Fri, 2017-09-08 at 22:30 +0200, Ludovic Courtès wrote:
Toggle quote (18 lines)
> Hi Eric,
>
> Eric Bavier <ericbavier@centurylink.net> skribis:
>
> >
> > It seems to me that if using Guix's profiles and environments, we
> > could entirely do without OpenFOAM's installation directories and
> > simply install into a standard bin/lib structure.  Just install
> > libraries into (string-append %output "/lib") and the binaries into
> > (string-append %output "/bin").
> Fair enough.  I guess the question is more whether (1) this would
> work
> :-), and (2) whether seasoned OpenFOAM users would be happy with
> this.
>
> WDYT, Paul?
>
> Ludo’.
Attachment: file
L
L
Ludovic Courtès wrote on 11 Sep 2017 13:39
(name . Paul Garlick)(address . pgarlick@tourbillion-technology.com)
87mv61a2hn.fsf@gnu.org
Hi Paul,

Paul Garlick <pgarlick@tourbillion-technology.com> skribis:

Toggle quote (7 lines)
> I think it is helpful to consider this question in two ways; thinking about the short term and the longer term. I think in the short term it is best to stick with the OpenFOAM-standard layout, modified in the 'middle-road' way suggested
> earlier. On top of the previous points made, there is an additional advantage to this approach in that the OpenFOAM-standard layout has been thoroughly tested in production use over many years.
>
> In the longer term I think it would be possible to develop a Guix-standard layout. I cannot see any reason why this would not work. However, with a large system such as OpenFOAM, this may not necessarily be an easy task. I see this
> as principally an upstream job, since they are the most knowledgeable people on the current layout and are best placed to deal with any subleties involved. With a working Guix package in place it will be a good time to contact
> upstream and discuss the merits of a new layout.

I agree. So for now, I’d say go with the bin/ symlink, and then start a
discussion with upstream to see how to improve things in the future.

Toggle quote (3 lines)
> Today I hope to finish the package definition. I have placed the tree under the 'lib' directory and this allows the 'validate-runpath' phase to run. The phase currently fails as ld-wrapper does not add the runpaths of the shared objects in
> the build tree. I plan to use patchelf to fix this.

I would refrain from using PatchELF, if possible, by just passing
-Wl,-rpath=DIR at link time, where DIR is the final library directory.

Ludo’.
P
P
Paul Garlick wrote on 14 Sep 2017 17:46
[PATCH] gnu: Add openfoam
(address . ludo@gnu.org)
20170914154621.3196-1-pgarlick@tourbillion-technology.com
*gnu/packages/patches/openfoam-4.1-cleanup.patch: New file
*gnu/packages/simulation.scm: New file
*gnu/local.mk (GNU_SYSTEM_MODULES): Add module
(dist_patch_DATA): Add patch
---

Hi Ludo,

Toggle quote (3 lines)
> I would refrain from using PatchELF, if possible, by just passing
> -Wl,-rpath=DIR at link time, where DIR is the final library directory.

OK, no need for PatchELF. I used the variable LDFLAGS to pass the extra
arguments to the linker.

A change was needed in the 'wmake/rules/linux64Gcc/c++' file to make use of
the extra variable.

An additional change was needed in the 'wmake/rules/General/CGAL' file to add
an entry for the gmp library (referenced by one binary and one shared library).
The runpath addition for gmp is taken care of by ld-wrapper.

The validate-runpath phase now passes and the build succeeds.

Toggle quote (2 lines)
> I really dislike this FOAM_INST_DIR variable

I took another look at this question. As it turns out, from OpenFOAM
version 4.1 onwards this variable is set automatically. A user simply sources
the bashrc file, as detailed in the Note, and the correct path is set. So
we can dispense with this section after all.

Also, I have merged the 'set-environment-variables' phase and the 'build' phase
as there is no need for separate phases.

Paul.

gnu/local.mk | 2 +
gnu/packages/patches/openfoam-4.1-cleanup.patch | 243 ++++++++++++++++++++++++
gnu/packages/simulation.scm | 206 ++++++++++++++++++++
3 files changed, 451 insertions(+)
create mode 100644 gnu/packages/patches/openfoam-4.1-cleanup.patch
create mode 100644 gnu/packages/simulation.scm

Toggle diff (428 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index 643a88db8..048f7aa1c 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -363,6 +363,7 @@ GNU_SYSTEM_MODULES = \
%D%/packages/shells.scm \
%D%/packages/shellutils.scm \
%D%/packages/simh.scm \
+ %D%/packages/simulation.scm \
%D%/packages/skarnet.scm \
%D%/packages/skribilo.scm \
%D%/packages/slang.scm \
@@ -886,6 +887,7 @@ dist_patch_DATA = \
%D%/packages/patches/ola-readdir-r.patch \
%D%/packages/patches/openscenegraph-ffmpeg3.patch \
%D%/packages/patches/openexr-missing-samples.patch \
+ %D%/packages/patches/openfoam-4.1-cleanup.patch \
%D%/packages/patches/openjpeg-CVE-2017-12982.patch \
%D%/packages/patches/openjpeg-CVE-2017-14040.patch \
%D%/packages/patches/openjpeg-CVE-2017-14041.patch \
diff --git a/gnu/packages/patches/openfoam-4.1-cleanup.patch b/gnu/packages/patches/openfoam-4.1-cleanup.patch
new file mode 100644
index 000000000..37effa5c9
--- /dev/null
+++ b/gnu/packages/patches/openfoam-4.1-cleanup.patch
@@ -0,0 +1,243 @@
+# This patch removes all need for the ThirdParty files of OpenFOAM.
+
+# Derived from EasyBuild patch by Ward Poelmans <wpoely86@gmail.com>.
+# Modified for GNU Guix by Paul Garlick <pgarlick@tourbillion-technology.com>.
+
+diff -ur OpenFOAM-4.x-version-4.1.org/applications/utilities/mesh/manipulation/setSet/Allwmake OpenFOAM-4.x-version-4.1/applications/utilities/mesh/manipulation/setSet/Allwmake
+--- OpenFOAM-4.x-version-4.1.org/applications/utilities/mesh/manipulation/setSet/Allwmake
++++ OpenFOAM-4.x-version-4.1/applications/utilities/mesh/manipulation/setSet/Allwmake
+@@ -9,7 +9,7 @@
+ #
+ # use readline if available
+ #
+-if [ -f /usr/include/readline/readline.h ]
++if true
+ then
+ echo "Found <readline/readline.h> -- enabling readline support."
+ export COMP_FLAGS="-DHAS_READLINE"
+diff -ur OpenFOAM-4.x-version-4.1.org/etc/bashrc OpenFOAM-4.x-version-4.1/etc/bashrc
+--- OpenFOAM-4.x-version-4.1.org/etc/bashrc
++++ OpenFOAM-4.x-version-4.1/etc/bashrc
+@@ -43,8 +43,10 @@
+ # Please set to the appropriate path if the default is not correct.
+ #
+ [ $BASH_SOURCE ] && \
+-export FOAM_INST_DIR=$(cd ${BASH_SOURCE%/*/*/*} && pwd -P) || \
++export FOAM_INST_DIR=$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P) || \
+ export FOAM_INST_DIR=$HOME/$WM_PROJECT
++# For GNU Guix: set initially for build then re-set at runtime
++#
+ # export FOAM_INST_DIR=~$WM_PROJECT
+ # export FOAM_INST_DIR=/opt/$WM_PROJECT
+ # export FOAM_INST_DIR=/usr/local/$WM_PROJECT
+diff -ur OpenFOAM-4.x-version-4.1.org/etc/config.sh/CGAL OpenFOAM-4.x-version-4.1/etc/config.sh/CGAL
+--- OpenFOAM-4.x-version-4.1.org/etc/config.sh/CGAL
++++ OpenFOAM-4.x-version-4.1/etc/config.sh/CGAL
+@@ -36,37 +36,7 @@
+ #
+ #------------------------------------------------------------------------------
+
+-boost_version=boost-system
+-cgal_version=cgal-system
+-#cgal_version=CGAL-4.8
+-
+-if [ -z "$SOURCE_CGAL_VERSIONS_ONLY" ]
+-then
+-
+- common_path=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER
+-
+- export BOOST_ARCH_PATH=$common_path/$boost_version
+- export CGAL_ARCH_PATH=$common_path/$cgal_version
+-
+- if [ "$FOAM_VERBOSE" -a "$PS1" ]
+- then
+- echo "Using CGAL and boost" 1>&2
+- echo " $cgal_version at $CGAL_ARCH_PATH" 1>&2
+- echo " $boost_version at $BOOST_ARCH_PATH" 1>&2
+- fi
+-
+- if [ -d "$CGAL_ARCH_PATH" -a "$cgal_version" != "cgal-system" ]
+- then
+- _foamAddLib $CGAL_ARCH_PATH/lib
+- fi
+-
+- if [ -d "$BOOST_ARCH_PATH" -a "$boost_version" != "boost-system" ]
+- then
+- _foamAddLib $BOOST_ARCH_PATH/lib
+- fi
+-
+- unset boost_version cgal_version common_path
+-
+-fi
++export CGAL_ARCH_PATH=$CGAL_ROOT
++export BOOST_ARCH_PATH=$BOOST_ROOT
+
+ #------------------------------------------------------------------------------
+diff -ur OpenFOAM-4.x-version-4.1.org/etc/config.sh/gperftools OpenFOAM-4.x-version-4.1/etc/config.sh/gperftools
+--- OpenFOAM-4.x-version-4.1.org/etc/config.sh/gperftools
++++ OpenFOAM-4.x-version-4.1/etc/config.sh/gperftools
+@@ -29,13 +29,5 @@
+ #
+ #------------------------------------------------------------------------------
+
+-version=svn
+-gperftools_install=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER
+-
+-GPERFTOOLS_VERSION=gperftools-$version
+-GPERFTOOLS_ARCH_PATH=$gperftools_install/$GPERFTOOLS_VERSION
+-
+-export PATH=$GPERFTOOLS_ARCH_PATH/bin:$PATH
+-export LD_LIBRARY_PATH=$GPERFTOOLS_ARCH_PATH/lib:$LD_LIBRARY_PATH
+
+ #------------------------------------------------------------------------------
+diff -ur OpenFOAM-4.x-version-4.1.org/etc/config.sh/metis OpenFOAM-4.x-version-4.1/etc/config.sh/metis
+--- OpenFOAM-4.x-version-4.1.org/etc/config.sh/metis
++++ OpenFOAM-4.x-version-4.1/etc/config.sh/metis
+@@ -34,7 +34,7 @@
+ #
+ #------------------------------------------------------------------------------
+
+-export METIS_VERSION=metis-5.1.0
+-export METIS_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION/$METIS_VERSION
++export METIS_VERSION=metis-$METISVERSION
++export METIS_ARCH_PATH=$METIS_ROOT
+
+ #------------------------------------------------------------------------------
+diff -ur OpenFOAM-4.x-version-4.1.org/etc/config.sh/scotch OpenFOAM-4.x-version-4.1/etc/config.sh/scotch
+--- OpenFOAM-4.x-version-4.1.org/etc/config.sh/scotch
++++ OpenFOAM-4.x-version-4.1/etc/config.sh/scotch
+@@ -37,7 +37,7 @@
+ #
+ #------------------------------------------------------------------------------
+
+-export SCOTCH_VERSION=scotch_6.0.3
+-export SCOTCH_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION/$SCOTCH_VERSION
++export SCOTCH_VERSION=scotch_$SCOTCHVERSION
++export SCOTCH_ARCH_PATH=$SCOTCH_ROOT
+
+ #------------------------------------------------------------------------------
+diff -ur OpenFOAM-4.x-version-4.1.org/etc/config.sh/settings OpenFOAM-4.x-version-4.1/etc/config.sh/settings
+--- OpenFOAM-4.x-version-4.1.org/etc/config.sh/settings
++++ OpenFOAM-4.x-version-4.1/etc/config.sh/settings
+@@ -279,6 +279,9 @@
+ ;;
+ system)
+ # Use system compiler
++ # Use system GMP and MPFR packages
++ export GMP_ARCH_PATH=$GMP_ROOT
++ export MPFR_ARCH_PATH=$MPFR_ROOT
+ ;;
+ *)
+ echo "Warn: WM_COMPILER_TYPE='$WM_COMPILER_TYPE' is unsupported" 1>&2
+diff -ur OpenFOAM-4.x-version-4.1.org/src/parallel/decompose/ptscotchDecomp/Make/options OpenFOAM-4.x-version-4.1/src/parallel/decompose/ptscotchDecomp/Make/options
+--- OpenFOAM-4.x-version-4.1.org/src/parallel/decompose/ptscotchDecomp/Make/options
++++ OpenFOAM-4.x-version-4.1/src/parallel/decompose/ptscotchDecomp/Make/options
+@@ -5,8 +5,7 @@
+ $(PFLAGS) $(PINC) \
+ -I$(SCOTCH_ROOT)/include \
+ -I$(SCOTCH_ARCH_PATH)/include/$(FOAM_MPI) \
+- -I/usr/include/scotch \
+ -I../decompositionMethods/lnInclude
+
+ LIB_LIBS = \
+- -L$(SCOTCH_ROOT)/lib -L$(FOAM_EXT_LIBBIN)/$(FOAM_MPI) -lptscotch -lptscotcherrexit -lscotch ${LINK_FLAGS} -lrt
++ -L$(SCOTCH_ROOT)/lib -L$(MPI_ARCH_PATH)/lib -lptscotch -lptscotcherrexit -lscotch ${LINK_FLAGS} -lrt
+diff -ur OpenFOAM-4.x-version-4.1.org/src/parallel/decompose/scotchDecomp/Make/options OpenFOAM-4.x-version-4.1/src/parallel/decompose/scotchDecomp/Make/options
+--- OpenFOAM-4.x-version-4.1.org/src/parallel/decompose/scotchDecomp/Make/options
++++ OpenFOAM-4.x-version-4.1/src/parallel/decompose/scotchDecomp/Make/options
+@@ -9,8 +9,7 @@
+ $(PFLAGS) $(PINC) \
+ -I$(SCOTCH_ROOT)/include \
+ -I$(SCOTCH_ARCH_PATH)/include \
+- -I/usr/include/scotch \
+ -I../decompositionMethods/lnInclude
+
+ LIB_LIBS = \
+- -L$(SCOTCH_ROOT)/lib -L$(FOAM_EXT_LIBBIN) -lscotch -lscotcherrexit -lrt
++ -L$(SCOTCH_ROOT)/lib -lscotch -lscotcherrexit -lrt
+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,6 @@
+ # The Makefile uses a POSIX shell
+ #------------------------------------------------------------------------------
+
+-SHELL = /bin/sh
+
+
+ #------------------------------------------------------------------------------
+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=$HOME/.$WM_PROJECT/.wmake
++ lockDir=$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P)/.$WM_PROJECT/.wmake
+
+ 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:=$HOSTNAME}
+
+-lockDir=$HOME/.$WM_PROJECT/.wmake
++lockDir=$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P)/.$WM_PROJECT/.wmake
+
+ # Fallback - 1 core on current host
+ : ${WM_HOSTS:=$HOST:1}
+diff -ur OpenFOAM-4.x-version-4.1.org/wmake/wmakeSchedulerUptime OpenFOAM-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:=$HOSTNAME}
+
+-lockDir=$HOME/.$WM_PROJECT/.wmake
++lockDir=$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P)/.$WM_PROJECT/.wmake
+ # Fallback - 1 core on current host
+ : ${WM_HOSTS:=$HOST:1}
+
+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/metisDecomp.C
++++ OpenFOAM-4.x-version-4.1/src/parallel/decompose/metisDecomp/metisDecomp.C
+@@ -67,7 +67,7 @@
+
+ // Processor weights initialised with no size, only used if specified in
+ // a file
+- Field<scalar> processorWeights;
++ Field<floatScalar> processorWeights;
+
+ // Cell weights (so on the vertices of the dual)
+ List<label> cellWeights;
+diff -ur OpenFOAM-4.x-version-4.1.org/wmake/rules/General/CGAL OpenFOAM-4.x-version-4.1/wmake/rules/General/CGAL
+--- OpenFOAM-4.x-version-4.1.org/wmake/rules/General/CGAL
++++ OpenFOAM-4.x-version-4.1/wmake/rules/General/CGAL
+@@ -6,9 +6,10 @@
+ -I/usr/include
+
+ CGAL_LIBS = \
+- -L$(MPFR_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \
+- -L$(GMP_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \
++ -L$(MPFR_ARCH_PATH)/lib \
++ -L$(GMP_ARCH_PATH)/lib \
+ -L$(BOOST_ARCH_PATH)/lib \
+ -L$(CGAL_ARCH_PATH)/lib \
+ -lCGAL \
++ -lgmp \
+ -lmpfr
+diff -ur OpenFOAM-4.x-version-4.1.org/wmake/rules/linux64Gcc/c++ OpenFOAM-4.x-version-4.1/wmake/rules/linux64Gcc/c++
+--- OpenFOAM-4.x-version-4.1.org/wmake/rules/linux64Gcc/c++
++++ OpenFOAM-4.x-version-4.1/wmake/rules/linux64Gcc/c++
+@@ -20,5 +20,5 @@
+
+ LINK_LIBS = $(c++DBUG)
+
+-LINKLIBSO = $(CC) $(c++FLAGS) -shared -Xlinker --add-needed -Xlinker --no-as-needed
+-LINKEXE = $(CC) $(c++FLAGS) -Xlinker --add-needed -Xlinker --no-as-needed
++LINKLIBSO = $(CC) $(c++FLAGS) $(LDFLAGS) -shared -Xlinker --add-needed -Xlinker --no-as-needed
++LINKEXE = $(CC) $(c++FLAGS) $(LDFLAGS) -Xlinker --add-needed -Xlinker --no-as-needed
diff --git a/gnu/packages/simulation.scm b/gnu/packages/simulation.scm
new file mode 100644
index 000000000..cc80dbb41
--- /dev/null
+++ b/gnu/packages/simulation.scm
@@ -0,0 +1,206 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Paul Garlick <pgarlick@tourbillion-technology.com>
+;;;
+;;; 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 <http://www.gnu.org/licenses/>.
+
+(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-map (lambda (x) (if (eq? x #\.) #\- x)) version)))
+ (file-name (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32 "0cgxh4h2hf50qbvvdg5miwc2nympb0nrv3md96vb3gbs9vk8vq9d"))
+ (patches (search-patches "openfoam-4.1-cleanup.patch"))))
+ (build-system gnu-build-system)
+ (inputs
+ `(("boost" ,boost)
+ ("cgal" ,cgal)
+ ("flex" ,flex)
+ ("git" ,git)
+ ("gmp" ,gmp)
+ ("libxt" ,libxt)
+ ("metis" ,metis)
+ ("mpfr" ,mpfr)
+ ("ncurses" ,ncurses)
+ ("readline" ,readline)
+ ("scotch" ,pt-scotch32)
+ ("zlib" ,zlib)))
+ (native-inputs
+ `(("bison" ,bison)))
+ (propagated-inputs
+ `(("gzip" ,gzip)
+ ("gnuplot" ,gnuplot)
+ ("openmpi" ,openmpi)))
+ (arguments
+ `(;; Executable files and shared libraries are located in the 'platforms'
+ ;; subdirectory.
+ #:strip-directories (list (string-append
+ "lib/OpenFOAM-" ,version
+ "/platforms/linux64GccDPInt32Opt/bin")
+ (string-append
+ "lib/OpenFOAM-" ,version
+ "/platforms/linux64GccDPInt32Opt/lib"))
+ #:tests? #f ; no tests to run
+ #: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 pathname 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)))
+ (rename-file unpack-dir build-dir) ; re-name build directory
+ (chdir (basename build-dir))) ; move to build directory
+ #t))
+ (delete 'configure) ; no configure phase
+ (replace 'build
+ (lambda _
+ (let ((libraries '("boost" "cgal" "gmp" "metis" "mpfr" "scotch")))
+ ;; set variables to define store paths
+ (for-each (lambda (library)
+ (setenv (string-append
+ (string-upcase library) "_ROOT")
+ (assoc-ref %build-inputs library))) libraries))
+ ;; set variables to define package versions
+ (setenv "SCOTCHVERSION" ,(package-version scotch))
+ (setenv "METISVERSION" ,(package-version metis))
+ ;; set variable to pass extra 'rpath' arguments to linker
+ (setenv "LDFLAGS"
+ (string-append
+ "-Wl,"
+ "-rpath=" %output "/lib/OpenFOAM-" ,version
+ "/platforms/linux64GccDPInt32Opt/lib,"
+ "-rpath=" %output "/lib/OpenFOAM-" ,version
+ "/platforms/linux64GccDPInt32Opt/lib/dummy"))
+ ;; 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 _
+ ;; record store paths and package versions in configuration files
+ (substitute* "etc/config.sh/CGAL"
+ (("$BOOST_ROOT") (getenv "BOOST_ROOT")))
+ (substitute* "etc/config.sh/CGAL"
+ (("$CGAL_ROOT") (getenv "CGAL_ROOT")))
+ (substitute* "etc/config.sh/metis"
+ (("$METIS_ROOT") (getenv "METIS_ROOT")))
+ (substitute* "etc/config.sh/metis"
+ (("$METISVERSION") (getenv "METISVERSION")))
+ (substitute* "etc/config.sh/scotch"
+ (("$SCOTCH_ROOT") (getenv "SCOTCH_ROOT")))
+ (substitute* "etc/config.sh/scotch"
+ (("$SCOTCHVERSION") (getenv "SCOTCHVERSION")))
+ (substi
This message was truncated. Download the full message here.
L
L
Ludovic Courtès wrote on 15 Sep 2017 18:35
(name . Paul Garlick)(address . pgarlick@tourbillion-technology.com)(address . 28045-done@debbugs.gnu.org)
8760cjudgu.fsf@gnu.org
Hi Paul,

Paul Garlick <pgarlick@tourbillion-technology.com> skribis:

Toggle quote (5 lines)
> *gnu/packages/patches/openfoam-4.1-cleanup.patch: New file
> *gnu/packages/simulation.scm: New file
> *gnu/local.mk (GNU_SYSTEM_MODULES): Add module
> (dist_patch_DATA): Add patch

I went ahead and pushed this (with indentation changes and use of
#:modules as discussed earlier; please consider using
‘etc/indent-code.el’ in the future):


Users who don’t set FOAM_INST_DIR will be tripped up like this:

Toggle snippet (10 lines)
$ /gnu/store/4zqn4w0wlq0irdwh3dhrdbsr7i3f1dag-openfoam-4.1/bin/checkMesh
--> FOAM FATAL ERROR in Foam::findEtcFiles() : could not find mandatory file
'controlDict'


$ /gnu/store/4zqn4w0wlq0irdwh3dhrdbsr7i3f1dag-openfoam-4.1/bin/interFoam
--> FOAM FATAL ERROR in Foam::findEtcFiles() : could not find mandatory file
'controlDict'

But that’s part of the game for now. :-)

Thanks a lot for your work and patience!

Ludo’.
Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 28045@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 28045
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch