diff --git a/etc/bashrc b/etc/bashrc index 50df795c080f80fad94e8a04c0e10005c60aebb7..658883d95cb57303e6371afd9a0f6bb63df8e0ba 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -158,6 +158,7 @@ _foamEtc -config vtk _foamEtc -config ensight _foamEtc -config gperftools ## _foamEtc -config ADIOS +## _foamEtc -config ADIOS2 _foamEtc -config CGAL _foamEtc -config scotch _foamEtc -config FFTW diff --git a/etc/config.csh/ADIOS2 b/etc/config.csh/ADIOS2 index b375cd8ea41465d11ff0494f5a0612d790902f94..917999f51d53f66fbb3bd6c966bc297a6fab27d6 100644 --- a/etc/config.csh/ADIOS2 +++ b/etc/config.csh/ADIOS2 @@ -2,7 +2,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------ # License @@ -28,16 +28,12 @@ if ($?FOAM_VERBOSE && $?prompt) then echo "Using adios ($adios2_version) -> $ADIOS2_ARCH_PATH" endif -# If *_ARCH_PATH does not end with '-system' or '-none', -# it is located within ThirdParty, or a central installation -# outside of ThirdParty and should be added to the path. - -set ending="${ADIOS2_ARCH_PATH:t}" -if ( "$ending" != "adios-none" && "$ending" != "adios-system" ) then - # PATH was already cleaned by etc/cshrc caller +# - only add if the directory really exists +_foamAddLibAuto $ADIOS2_ARCH_PATH +if ($status == 0) then _foamAddPath $ADIOS2_ARCH_PATH/bin endif -unset adios_version ending +unset adios2_version #------------------------------------------------------------------------------ diff --git a/etc/config.sh/ADIOS2 b/etc/config.sh/ADIOS2 index 8fe60b0a1175d1f82dbd69e25cc977ede63ea8a0..b77593e9a59f4a2c3d3556c76fd152c31645f71b 100644 --- a/etc/config.sh/ADIOS2 +++ b/etc/config.sh/ADIOS2 @@ -2,7 +2,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------ # License @@ -16,6 +16,7 @@ # Description # Setup for ADIOS2 include/libraries (usually ThirdParty installation). # +# Use with -force when sourcing directly from the command-line #------------------------------------------------------------------------------ # USER EDITABLE PART: Changes made here may be lost with the next upgrade @@ -29,21 +30,30 @@ then echo "Using adios ($adios2_version) -> $ADIOS2_ARCH_PATH" 1>&2 fi -if command -v _foamAddPath >/dev/null 2>&1 # Normal sourcing +if command -v _foamAddLibAuto > /dev/null 2>&1 then - # If *_ARCH_PATH does not end with '-system' or '-none', - # it is located within ThirdParty, or a central installation - # outside of ThirdParty and should be added to the path. + # Normal sourcing (not makeADIOS) + # - but only add if the directory really exists - ending="${ADIOS2_ARCH_PATH##*-}" - if [ "$ending" != none -a "$ending" != system ] + if _foamAddLibAuto $ADIOS2_ARCH_PATH then - # PATH was already cleaned by etc/bashrc caller _foamAddPath $ADIOS2_ARCH_PATH/bin fi - unset adios2_version ending + unset adios2_version +elif [ "$1" = "-force" ] +then + # Forced command-line sourcing + + if output="$($WM_PROJECT_DIR/bin/tools/lib-dir -sh $ADIOS2_ARCH_PATH 2>/dev/null)" + then + eval "$output" + PATH="$ADIOS2_ARCH_PATH/bin:$PATH" + fi + + unset adios2_version output fi + #------------------------------------------------------------------------------ diff --git a/etc/cshrc b/etc/cshrc index 1792541cdbde81c172d6bf2d025d941ffdfba274..8a95894abf960d2bbbd1844de246bbd753e26e39 100644 --- a/etc/cshrc +++ b/etc/cshrc @@ -200,6 +200,7 @@ _foamEtc -config paraview -- "$FOAM_SETTINGS" # Pass through for evaluation _foamEtc -config vtk _foamEtc -config ensight ## _foamEtc -config ADIOS +## _foamEtc -config ADIOS2 _foamEtc -config CGAL _foamEtc -config FFTW diff --git a/wmake/scripts/have_adios2 b/wmake/scripts/have_adios2 new file mode 100644 index 0000000000000000000000000000000000000000..81055812a027d4203d776debe27f273503e4e2ca --- /dev/null +++ b/wmake/scripts/have_adios2 @@ -0,0 +1,143 @@ +#----------------------------------*-sh-*-------------------------------------- +# ========= | +# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox +# \\ / O peration | +# \\ / A nd | Copyright (C) 2018 OpenCFD Ltd. +# \\/ M anipulation | +#------------------------------------------------------------------------------ +# License +# This file is part of OpenFOAM, licensed under GNU General Public License +# <http://www.gnu.org/licenses/>. +# +# Script +# have_adios2 +# +# Description +# Detection/setup of ADIOS2 +# +# Requires +# ADIOS2_ARCH_PATH +# +# Functions provided +# have_adios2, no_adios2, echo_adios2 +# +# Variables set on success +# HAVE_ADIOS2 +# ADIOS2_ARCH_PATH +# ADIOS2_INC_DIR +# ADIOS2_LIB_DIR +# +#------------------------------------------------------------------------------ +. $WM_PROJECT_DIR/wmake/scripts/sysFunctions # General system functions + +#------------------------------------------------------------------------------ + +# Reset variables +no_adios2() +{ + unset HAVE_ADIOS2 ADIOS2_INC_DIR ADIOS2_LIB_DIR + return 0 +} + + +# Report +echo_adios2() +{ + echo "adios2=${HAVE_ADIOS2:-false}" + echo "root=$ADIOS2_ARCH_PATH" + echo "include=$ADIOS2_INC_DIR" + echo "library=$ADIOS2_LIB_DIR" +} + + +# On success, return 0 and export variables +# -> HAVE_ADIOS2, ADIOS2_INC_DIR, ADIOS2_LIB_DIR +have_adios2() +{ + local header library static label settings warn + # warn="==> skip adios2" + + # Basic setup/checks + settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ADIOS2) || { + [ -n "$warn" ] && echo "$warn (no config.sh/ADIOS2 settings)" + return 1 + } + . $settings + if isNone "$ADIOS2_ARCH_PATH" + then + [ -n "$warn" ] && echo "$warn (not available)" + return 1 + fi + + + # Header/library names + header="adios2.h" + library="libadios2$extLibso" + + + if hasAbsdir "$ADIOS2_ARCH_PATH" + then + header=$(findFirstFile $ADIOS2_ARCH_PATH/include/$header) + + # FOAM_EXT_LIBBIN is allowed to be unset + library=$(findFirstFile \ + $FOAM_EXT_LIBBIN/$library \ + $ADIOS2_ARCH_PATH/lib/$library \ + $ADIOS2_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/$library \ + ) + elif isSystem "$ADIOS2_ARCH_PATH" + then + header=$(findFirstFile /usr/local/include/$header /usr/include/$header) + + case "$header" in + /usr/local/*) + library=$(findFirstFile \ + /usr/local/lib/$library \ + /usr/local/lib$WM_COMPILER_LIB_ARCH/$library \ + ) + ;; + + *) + library=$(findFirstFile \ + /usr/lib/$library \ + /usr/lib$WM_COMPILER_LIB_ARCH/$library \ + ) + ;; + esac + else + unset header library + fi + + + # Header found? + [ -n "$header" ] || { + [ -n "$warn" ] && echo "$warn (no header)" + return 2 + } + + # Library found? + [ -n "$library" ] || { + [ -n "$warn" ] && echo "$warn (missing library)" + return 2 + } + + header="${header%/*}" # Strip one-level (include/adios2/...) + + export HAVE_ADIOS2=true + export ADIOS2_ARCH_PATH + export ADIOS2_INC_DIR="${header%/*}" # Basename + export ADIOS2_LIB_DIR="${library%/*}" # Basename +} + + +# Force reset of old variables +no_adios2 + +# Testing +if [ "$1" = "-test" ] +then + have_adios2 + echo_adios2 +fi + +#------------------------------------------------------------------------------