openfoam: improve handling of wmake rules, version update

- add future-proofing for wmake rules locations:
  Accept wmake/rules/{ARCH}{COMP} or wmake/rules/{ARCH}/{COMP}

- compiler option is now '-spack' instead of 'RpathOpt'
  which now seems to be a bit harsh on the eyes.
  Now have compilations such as 'linux64GccDPInt32-spack',
  which is moderately easier to read.

- add OpenFOAM 1912, patch 200506

STYLE: adjust for new flakey8 indentation rules
This commit is contained in:
Mark Olesen 2020-05-20 10:48:30 +02:00 committed by Peter Scheibel
parent 2c6406c003
commit 0b96082e74
4 changed files with 68 additions and 40 deletions

View File

@ -7,8 +7,8 @@ export FOAM_INST_DIR=$(cd .. && pwd -L)
# Prevent influence of user/site config when building # Prevent influence of user/site config when building
export FOAM_CONFIG_MODE="o" export FOAM_CONFIG_MODE="o"
. "$PWD/etc/bashrc" '' # No arguments . "$PWD"/etc/bashrc '' # No arguments
mkdir -p "$FOAM_APPBIN" "$FOAM_LIBBIN" 2>/dev/null # Allow build interrupt mkdir -p "$FOAM_APPBIN" "$FOAM_LIBBIN" # Allow build interrupt
echo "Build openfoam with SPACK ($@)" echo "Build openfoam with SPACK ($@)"
echo "WM_PROJECT_DIR = $WM_PROJECT_DIR" echo "WM_PROJECT_DIR = $WM_PROJECT_DIR"

View File

@ -10,7 +10,7 @@
} }
export FOAM_INST_DIR=$(cd $FOAM_PROJECT_DIR/.. && pwd -L) # Needed by foam-extend export FOAM_INST_DIR=$(cd $FOAM_PROJECT_DIR/.. && pwd -L) # Needed by foam-extend
. $FOAM_PROJECT_DIR/etc/bashrc '' # No arguments . "$FOAM_PROJECT_DIR"/etc/bashrc '' # No arguments
# Package-specific adjustments # Package-specific adjustments
[ -f spack-config.sh ] && . ./spack-config.sh '' # No arguments [ -f spack-config.sh ] && . ./spack-config.sh '' # No arguments

View File

@ -0,0 +1,18 @@
#!/bin/bash
# Build wrapper script for dummy build
# Prevent influence of user/site config when building
export FOAM_CONFIG_MODE="o"
. "$PWD"/etc/bashrc '' # No arguments
echo "Dummy build openfoam with SPACK ($@)"
echo "WM_PROJECT_DIR = $WM_PROJECT_DIR"
if [ -f applications/test/00-dummy/Allwmake ]
then
applications/test/00-dummy/Allwmake $@
else
echo "Nothing to make"
fi
# -----------------------------------------------------------------------------

View File

@ -265,6 +265,7 @@ class Openfoam(Package):
version('develop', branch='develop', submodules='True') version('develop', branch='develop', submodules='True')
version('master', branch='master', submodules='True') version('master', branch='master', submodules='True')
version('1912_200506', sha256='831a39ff56e268e88374d0a3922479fd80260683e141e51980242cc281484121')
version('1912_200403', sha256='1de8f4ddd39722b75f6b01ace9f1ba727b53dd999d1cd2b344a8c677ac2db4c0') version('1912_200403', sha256='1de8f4ddd39722b75f6b01ace9f1ba727b53dd999d1cd2b344a8c677ac2db4c0')
version('1912', sha256='437feadf075419290aa8bf461673b723a60dc39525b23322850fb58cb48548f2') version('1912', sha256='437feadf075419290aa8bf461673b723a60dc39525b23322850fb58cb48548f2')
version('1906_200312', sha256='f75645151ed5d8c5da592d307480979fe580a25627cc0c9718ef370211577594') version('1906_200312', sha256='f75645151ed5d8c5da592d307480979fe580a25627cc0c9718ef370211577594')
@ -348,10 +349,10 @@ class Openfoam(Package):
patch('https://develop.openfoam.com/Development/openfoam/commit/8831dfc58b0295d0d301a78341dd6f4599073d45.patch', patch('https://develop.openfoam.com/Development/openfoam/commit/8831dfc58b0295d0d301a78341dd6f4599073d45.patch',
when='@1806', when='@1806',
sha256='21f1ab68c82dfa41ed1a4439427c94c43ddda02c84175c30da623d905d3e5d61' sha256='21f1ab68c82dfa41ed1a4439427c94c43ddda02c84175c30da623d905d3e5d61'
) )
# Some user config settings # Some user config settings
# default: 'compile-option': 'RpathOpt', # default: 'compile-option': '-spack',
# default: 'mplib': 'USERMPI', # Use user mpi for spack # default: 'mplib': 'USERMPI', # Use user mpi for spack
config = { config = {
# Add links into bin/, lib/ (eg, for other applications) # Add links into bin/, lib/ (eg, for other applications)
@ -421,15 +422,15 @@ def setup_run_environment(self, env):
blacklist=[ # Blacklist these blacklist=[ # Blacklist these
# Inadvertent changes # Inadvertent changes
# ------------------- # -------------------
'PS1', # Leave unaffected 'PS1', # Leave untouched
'MANPATH', # Leave unaffected 'MANPATH', # Leave untouched
# Unneeded bits # Unneeded bits
# ------------- # -------------
# 'FOAM_SETTINGS', # Do not use with modules # 'FOAM_SETTINGS', # Do not use with modules
# 'FOAM_INST_DIR', # Old # 'FOAM_INST_DIR', # Old
# 'FOAM_(APP|ETC|SRC|SOLVERS|UTILITIES)', # 'FOAM_(APP|ETC|SRC|SOLVERS|UTILITIES)',
# 'FOAM_TUTORIALS', # can be useful # 'FOAM_TUTORIALS', # May be useful
# 'WM_OSTYPE', # Purely optional value # 'WM_OSTYPE', # Purely optional value
# Third-party cruft - only used for orig compilation # Third-party cruft - only used for orig compilation
@ -443,7 +444,7 @@ def setup_run_environment(self, env):
'(FOAM|WM)_.*USER_.*', '(FOAM|WM)_.*USER_.*',
], ],
whitelist=[ # Whitelist these whitelist=[ # Whitelist these
'MPI_ARCH_PATH', # Can be needed for compilation 'MPI_ARCH_PATH', # Can be required for compilation
]) ])
env.extend(mods) env.extend(mods)
@ -544,16 +545,24 @@ def patch(self):
@run_before('configure') @run_before('configure')
def make_fujitsu_rules(self): def make_fujitsu_rules(self):
"""Create Fujitsu rules (clang variant) unless supplied upstream. """Create Fujitsu rules (clang variant) unless supplied upstream.
Implemented for 1906 and newer - older rules are messier to edit Implemented for 1906 and later (older rules are too messy to edit).
Already included after 1912.
""" """
general_rules = 'wmake/rules/General' general_rules = 'wmake/rules/General'
arch_rules = join_path('wmake/rules/linuxARM64') # self.arch arch_rules = 'wmake/rules/linuxARM64' # self.arch
src = arch_rules + 'Clang' src = arch_rules + 'Clang'
dst = arch_rules + 'Fujitsu' # self.compiler dst = arch_rules + 'Fujitsu' # self.compiler
if os.path.exists(dst): if os.path.exists(dst):
return return
# Handle rules/<ARCH><COMP> or rules/<ARCH>/<COMP>
if not os.path.exists(src):
src = join_path(arch_rules, 'Clang')
dst = join_path(arch_rules, 'Fujitsu') # self.compiler
if os.path.exists(dst):
return
tty.info('Add Fujitsu wmake rules') tty.info('Add Fujitsu wmake rules')
copy_tree(src, dst) copy_tree(src, dst)
@ -622,11 +631,11 @@ def configure(self, spec, prefix):
'metis': {}, 'metis': {},
'ensight': {}, # Disable settings 'ensight': {}, # Disable settings
'paraview': [], 'paraview': [],
'gperftools': [], # Currently unused 'gperftools': [], # Disable settings
'vtk': [], 'vtk': [],
} }
# With adios2 after 1912 or develop (after 2019-10-01) # With adios2 after 1912
if spec.satisfies('@1912:'): if spec.satisfies('@1912:'):
self.etc_config['adios2'] = [ self.etc_config['adios2'] = [
('ADIOS2_ARCH_PATH', spec['adios2'].prefix), ('ADIOS2_ARCH_PATH', spec['adios2'].prefix),
@ -823,7 +832,7 @@ class OpenfoamArch(object):
Keywords Keywords
label-size=[True] supports int32/int64 label-size=[True] supports int32/int64
compile-option[=RpathOpt] compile-option[=-spack]
mplib[=USERMPI] mplib[=USERMPI]
""" """
@ -837,10 +846,9 @@ def __init__(self, spec, **kwargs):
self.arch_option = '' # Eg, -march=knl self.arch_option = '' # Eg, -march=knl
self.label_size = None # <- +int64 self.label_size = None # <- +int64
self.precision_option = 'DP' # <- +float32 self.precision_option = 'DP' # <- +float32
self.compile_option = kwargs.get('compile-option', 'RpathOpt') self.compile_option = kwargs.get('compile-option', '-spack')
self.arch = None self.arch = None
self.options = None self.options = None
self.rule = None
self.mplib = kwargs.get('mplib', 'USERMPI') self.mplib = kwargs.get('mplib', 'USERMPI')
# Normally support WM_LABEL_OPTION, but not yet for foam-extend # Normally support WM_LABEL_OPTION, but not yet for foam-extend
@ -852,6 +860,9 @@ def __init__(self, spec, **kwargs):
if '+float32' in spec: if '+float32' in spec:
self.precision_option = 'SP' self.precision_option = 'SP'
# TDB: mixed precision?
# self.precision_option = 'SPDP'
# Processor/architecture-specific optimizations # Processor/architecture-specific optimizations
if '+knl' in spec: if '+knl' in spec:
self.arch_option = '-march=knl' self.arch_option = '-march=knl'
@ -884,9 +895,9 @@ def __init__(self, spec, **kwargs):
self.arch = platform self.arch = platform
# Capitalized version of the compiler name, which corresponds # Capitalize first letter of compiler name, which corresponds
# to how OpenFOAM handles things (eg, gcc -> Gcc). # to how OpenFOAM handles things (eg, gcc -> Gcc).
# Use compiler_mapping to handing special cases. # Use compiler_mapping for special cases.
comp = spec.compiler.name comp = spec.compiler.name
if comp in self.compiler_mapping: if comp in self.compiler_mapping:
@ -894,7 +905,6 @@ def __init__(self, spec, **kwargs):
comp = comp.capitalize() comp = comp.capitalize()
self.compiler = comp self.compiler = comp
self.rule = self.arch + self.compiler
# Build WM_OPTIONS # Build WM_OPTIONS
# ---- # ----
@ -904,7 +914,8 @@ def __init__(self, spec, **kwargs):
# WM_OPTIONS=$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_COMPILE_OPTION # WM_OPTIONS=$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_COMPILE_OPTION
# ---- # ----
self.options = ''.join([ self.options = ''.join([
self.rule, self.arch,
self.compiler,
self.precision_option, self.precision_option,
('Int' + self.label_size if self.label_size else ''), ('Int' + self.label_size if self.label_size else ''),
self.compile_option]) self.compile_option])
@ -925,46 +936,45 @@ def foam_dict(self):
('WM_MPLIB', self.mplib), ('WM_MPLIB', self.mplib),
]) ])
def _rule_directory(self, projdir=None, general=False): def _rule_directory(self, projdir, general=False):
"""The wmake/rules/ compiler directory""" """Return the wmake/rules/ General or compiler rules directory.
Supports wmake/rules/<ARCH><COMP> and wmake/rules/<ARCH>/<COMP>.
"""
rules_dir = os.path.join(projdir, 'wmake', 'rules')
if general: if general:
relative = os.path.join('wmake', 'rules', 'General') return os.path.join(rules_dir, 'General')
arch_dir = os.path.join(rules_dir, self.arch)
comp_rules = arch_dir + self.compiler
if os.path.isdir(comp_rules):
return comp_rules
else: else:
relative = os.path.join('wmake', 'rules', self.rule) return os.path.join(arch_dir, self.compiler)
if projdir:
return os.path.join(projdir, relative)
else:
return relative
def has_rule(self, projdir): def has_rule(self, projdir):
"""Verify that a wmake/rules/ compiler rule exists in the project """Verify that a wmake/rules/ compiler rule exists in the project.
directory.
""" """
# Insist on a wmake rule for this architecture/compiler combination # Insist on a wmake rule for this architecture/compiler combination
rule_dir = self._rule_directory(projdir) rule_dir = self._rule_directory(projdir)
if not os.path.isdir(rule_dir): if not os.path.isdir(rule_dir):
raise InstallError( raise InstallError(
'No wmake rule for {0}'.format(self.rule)) 'No wmake rule for {0} {1}'.format(self.arch, self.compiler))
if not re.match(r'.+Opt$', self.compile_option):
raise InstallError(
"WM_COMPILE_OPTION={0} is not type '*Opt'"
.format(self.compile_option))
return True return True
def create_rules(self, projdir, foam_pkg): def create_rules(self, projdir, foam_pkg):
""" Create cRpathOpt,c++RpathOpt and mplibUSER,mplibUSERMPI """ Create {c,c++}-spack and mplib{USER,USERMPI}
rules in the specified project directory. rules in the specified project directory.
The compiler rules are based on the respective cOpt,c++Opt rules The compiler rules are based on the respective {c,c++}Opt rules
but with additional rpath information for the OpenFOAM libraries. but with additional rpath information for the OpenFOAM libraries.
The rpath rules allow wmake to use spack information with minimal The '-spack' rules channel spack information into OpenFOAM wmake
modification to OpenFOAM. rules with minimal modification to OpenFOAM.
The rpath is used for the installed libpath (continue to use The rpath is used for the installed libpath (continue to use
LD_LIBRARY_PATH for values during the build). LD_LIBRARY_PATH for values during the build).
""" """
# Note: the 'c' rules normally don't need rpath, since they are just # Note: the 'c' rules normally don't need rpath, since they are just
# used for statically linked wmake utilities, but left in anyhow. # used for some statically linked wmake tools, but left in anyhow.
# rpath for installed OpenFOAM libraries # rpath for installed OpenFOAM libraries
rpath = '{0}{1}'.format( rpath = '{0}{1}'.format(