From 995c55b60e49b7db0815d241d1c2ce9558b2fc2a Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 19 Dec 2017 16:07:15 +0100 Subject: [PATCH 1/5] CONFIG: add clang third-party lib to LD_LIBRARY_PATH - required if there is no system openmp and libomp or libgomp are only found in the clang hierarchy STYLE: add some notes in the openmp rules. - the _OPENMP macro is now used in low-level testing files --- applications/test/openmp/Make/options | 2 +- applications/test/openmp/Test-openmp.C | 16 ++++++++++++---- etc/config.csh/settings | 1 + etc/config.sh/settings | 1 + wmake/rules/linux64Clang/openmp | 4 ++++ wmake/rules/linux64Cray/openmp | 1 + wmake/rules/linux64Gcc/openmp | 1 + wmake/rules/linux64GccKNL/openmp | 1 + wmake/rules/linux64Icc/openmp | 1 + wmake/rules/linux64IccKNL/openmp | 1 + wmake/rules/linuxARM64Clang/openmp | 4 ++++ wmake/rules/linuxARM64Gcc/openmp | 1 + wmake/rules/linuxARM7Gcc/openmp | 1 + wmake/rules/linuxClang/openmp | 4 ++++ wmake/rules/linuxGcc/openmp | 1 + wmake/rules/linuxIA64Gcc/openmp | 1 + wmake/rules/linuxIA64Icc/openmp | 1 + wmake/rules/linuxPPC64Gcc/openmp | 1 + wmake/rules/linuxPPC64leGcc/openmp | 1 + 19 files changed, 39 insertions(+), 5 deletions(-) diff --git a/applications/test/openmp/Make/options b/applications/test/openmp/Make/options index 54eed51fb9..9c1cb59980 100644 --- a/applications/test/openmp/Make/options +++ b/applications/test/openmp/Make/options @@ -1,4 +1,4 @@ -EXE_INC = ${COMP_OPENMP} +EXE_INC = ${COMP_OPENMP} /* -UUSE_OMP */ /* Mostly do not need to explicitly link openmp libraries */ /* EXE_LIBS = ${LINK_OPENMP} */ diff --git a/applications/test/openmp/Test-openmp.C b/applications/test/openmp/Test-openmp.C index acb68e9ed8..1ac9762c76 100644 --- a/applications/test/openmp/Test-openmp.C +++ b/applications/test/openmp/Test-openmp.C @@ -30,7 +30,7 @@ Description #include #include -#ifdef USE_OMP +#if _OPENMP #include #endif @@ -39,11 +39,19 @@ Description int main(int argc, char *argv[]) { +#if USE_OMP + std::cout << "USE_OMP defined (" << USE_OMP << ")\n"; +#else + std::cout << "USE_OMP undefined\n"; +#endif + +#if _OPENMP + std::cout << "_OPENMP = " << _OPENMP << "\n\n"; + + // Fork threads with their own copies of variables int nThreads, threadId; -// Fork threads with their own copies of variables -#ifdef USE_OMP -#pragma omp parallel private(nThreads, threadId) + #pragma omp parallel private(nThreads, threadId) { threadId = omp_get_thread_num(); nThreads = omp_get_num_threads(); diff --git a/etc/config.csh/settings b/etc/config.csh/settings index 4c88b294b8..37c49f4e91 100644 --- a/etc/config.csh/settings +++ b/etc/config.csh/settings @@ -302,6 +302,7 @@ CLANG_NOT_FOUND _foamAddMan $clangDir/man _foamAddPath $clangDir/bin + _foamAddLib $clangDir/lib # For things like libomp (openmp) etc if ($?FOAM_VERBOSE && $?prompt) then echo "Using ThirdParty compiler" diff --git a/etc/config.sh/settings b/etc/config.sh/settings index 286339aa53..33aa7fa893 100644 --- a/etc/config.sh/settings +++ b/etc/config.sh/settings @@ -287,6 +287,7 @@ CLANG_NOT_FOUND _foamAddMan $clangDir/share/man _foamAddPath $clangDir/bin + _foamAddLib $clangDir/lib # For things like libomp (openmp) etc if [ "$FOAM_VERBOSE" -a "$PS1" ] then diff --git a/wmake/rules/linux64Clang/openmp b/wmake/rules/linux64Clang/openmp index bcb805f57c..070a2c5d3a 100644 --- a/wmake/rules/linux64Clang/openmp +++ b/wmake/rules/linux64Clang/openmp @@ -1,4 +1,8 @@ # Flags for compiling/linking openmp +# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP) +# - +# Clang provides 'omp' and a link for 'gomp'. +# With 'gomp' we can use system libs. COMP_OPENMP = -DUSE_OMP -fopenmp LINK_OPENMP = -lgomp diff --git a/wmake/rules/linux64Cray/openmp b/wmake/rules/linux64Cray/openmp index bcb805f57c..cd007d1529 100644 --- a/wmake/rules/linux64Cray/openmp +++ b/wmake/rules/linux64Cray/openmp @@ -1,4 +1,5 @@ # Flags for compiling/linking openmp +# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP) COMP_OPENMP = -DUSE_OMP -fopenmp LINK_OPENMP = -lgomp diff --git a/wmake/rules/linux64Gcc/openmp b/wmake/rules/linux64Gcc/openmp index bcb805f57c..cd007d1529 100644 --- a/wmake/rules/linux64Gcc/openmp +++ b/wmake/rules/linux64Gcc/openmp @@ -1,4 +1,5 @@ # Flags for compiling/linking openmp +# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP) COMP_OPENMP = -DUSE_OMP -fopenmp LINK_OPENMP = -lgomp diff --git a/wmake/rules/linux64GccKNL/openmp b/wmake/rules/linux64GccKNL/openmp index bcb805f57c..cd007d1529 100644 --- a/wmake/rules/linux64GccKNL/openmp +++ b/wmake/rules/linux64GccKNL/openmp @@ -1,4 +1,5 @@ # Flags for compiling/linking openmp +# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP) COMP_OPENMP = -DUSE_OMP -fopenmp LINK_OPENMP = -lgomp diff --git a/wmake/rules/linux64Icc/openmp b/wmake/rules/linux64Icc/openmp index 154c9e5743..738673ca91 100644 --- a/wmake/rules/linux64Icc/openmp +++ b/wmake/rules/linux64Icc/openmp @@ -1,4 +1,5 @@ # Flags for compiling/linking openmp +# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP) COMP_OPENMP = -DUSE_OMP -qopenmp LINK_OPENMP = -liomp5 diff --git a/wmake/rules/linux64IccKNL/openmp b/wmake/rules/linux64IccKNL/openmp index 154c9e5743..738673ca91 100644 --- a/wmake/rules/linux64IccKNL/openmp +++ b/wmake/rules/linux64IccKNL/openmp @@ -1,4 +1,5 @@ # Flags for compiling/linking openmp +# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP) COMP_OPENMP = -DUSE_OMP -qopenmp LINK_OPENMP = -liomp5 diff --git a/wmake/rules/linuxARM64Clang/openmp b/wmake/rules/linuxARM64Clang/openmp index bcb805f57c..070a2c5d3a 100644 --- a/wmake/rules/linuxARM64Clang/openmp +++ b/wmake/rules/linuxARM64Clang/openmp @@ -1,4 +1,8 @@ # Flags for compiling/linking openmp +# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP) +# - +# Clang provides 'omp' and a link for 'gomp'. +# With 'gomp' we can use system libs. COMP_OPENMP = -DUSE_OMP -fopenmp LINK_OPENMP = -lgomp diff --git a/wmake/rules/linuxARM64Gcc/openmp b/wmake/rules/linuxARM64Gcc/openmp index bcb805f57c..cd007d1529 100644 --- a/wmake/rules/linuxARM64Gcc/openmp +++ b/wmake/rules/linuxARM64Gcc/openmp @@ -1,4 +1,5 @@ # Flags for compiling/linking openmp +# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP) COMP_OPENMP = -DUSE_OMP -fopenmp LINK_OPENMP = -lgomp diff --git a/wmake/rules/linuxARM7Gcc/openmp b/wmake/rules/linuxARM7Gcc/openmp index bcb805f57c..cd007d1529 100644 --- a/wmake/rules/linuxARM7Gcc/openmp +++ b/wmake/rules/linuxARM7Gcc/openmp @@ -1,4 +1,5 @@ # Flags for compiling/linking openmp +# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP) COMP_OPENMP = -DUSE_OMP -fopenmp LINK_OPENMP = -lgomp diff --git a/wmake/rules/linuxClang/openmp b/wmake/rules/linuxClang/openmp index bcb805f57c..070a2c5d3a 100644 --- a/wmake/rules/linuxClang/openmp +++ b/wmake/rules/linuxClang/openmp @@ -1,4 +1,8 @@ # Flags for compiling/linking openmp +# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP) +# - +# Clang provides 'omp' and a link for 'gomp'. +# With 'gomp' we can use system libs. COMP_OPENMP = -DUSE_OMP -fopenmp LINK_OPENMP = -lgomp diff --git a/wmake/rules/linuxGcc/openmp b/wmake/rules/linuxGcc/openmp index bcb805f57c..cd007d1529 100644 --- a/wmake/rules/linuxGcc/openmp +++ b/wmake/rules/linuxGcc/openmp @@ -1,4 +1,5 @@ # Flags for compiling/linking openmp +# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP) COMP_OPENMP = -DUSE_OMP -fopenmp LINK_OPENMP = -lgomp diff --git a/wmake/rules/linuxIA64Gcc/openmp b/wmake/rules/linuxIA64Gcc/openmp index bcb805f57c..cd007d1529 100644 --- a/wmake/rules/linuxIA64Gcc/openmp +++ b/wmake/rules/linuxIA64Gcc/openmp @@ -1,4 +1,5 @@ # Flags for compiling/linking openmp +# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP) COMP_OPENMP = -DUSE_OMP -fopenmp LINK_OPENMP = -lgomp diff --git a/wmake/rules/linuxIA64Icc/openmp b/wmake/rules/linuxIA64Icc/openmp index 154c9e5743..738673ca91 100644 --- a/wmake/rules/linuxIA64Icc/openmp +++ b/wmake/rules/linuxIA64Icc/openmp @@ -1,4 +1,5 @@ # Flags for compiling/linking openmp +# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP) COMP_OPENMP = -DUSE_OMP -qopenmp LINK_OPENMP = -liomp5 diff --git a/wmake/rules/linuxPPC64Gcc/openmp b/wmake/rules/linuxPPC64Gcc/openmp index bcb805f57c..cd007d1529 100644 --- a/wmake/rules/linuxPPC64Gcc/openmp +++ b/wmake/rules/linuxPPC64Gcc/openmp @@ -1,4 +1,5 @@ # Flags for compiling/linking openmp +# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP) COMP_OPENMP = -DUSE_OMP -fopenmp LINK_OPENMP = -lgomp diff --git a/wmake/rules/linuxPPC64leGcc/openmp b/wmake/rules/linuxPPC64leGcc/openmp index bcb805f57c..cd007d1529 100644 --- a/wmake/rules/linuxPPC64leGcc/openmp +++ b/wmake/rules/linuxPPC64leGcc/openmp @@ -1,4 +1,5 @@ # Flags for compiling/linking openmp +# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP) COMP_OPENMP = -DUSE_OMP -fopenmp LINK_OPENMP = -lgomp From 2fe7d0c00bf7689ba8092c51799a75c2c718a73d Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 21 Dec 2017 10:38:57 +0100 Subject: [PATCH 2/5] STYLE: update BuildIssues with CGAL mpfr-none problem (issue #674) - add some notes about 'git submodule' in modules/README.md --- BuildIssues.txt | 29 +++++++++++++++++++- etc/bashrc | 57 +++++++++++++++------------------------ etc/config.csh/settings | 9 +++---- etc/config.sh/settings | 9 +++---- etc/cshrc | 54 +++++++++++++++++-------------------- modules/README.md | 59 +++++++++++++++++++++++++++++++++++++---- 6 files changed, 137 insertions(+), 80 deletions(-) diff --git a/BuildIssues.txt b/BuildIssues.txt index fbb6b6dcb5..a05b5301c3 100644 --- a/BuildIssues.txt +++ b/BuildIssues.txt @@ -1,4 +1,4 @@ -OpenFOAM-1706 +OpenFOAM-1712 ================== Known Build Issues ================== @@ -75,6 +75,33 @@ If your system compiler is too old to build the minimum required gcc or clang/llvm, it is just simply too old. +--------------------------------- +ThirdParty clang without gmp/mpfr +--------------------------------- + +If using ThirdParty clang without gmp/mpfr, the ThirdParty makeCGAL +script will need to be run manually and specify that there is no +gmp/mpfr. Eg, + + cd $WM_THIRD_PARTY_DIR + ./makeCGAL gmp-none mpfr-none + +Subequent compilation with Allwmake will now run largely without any +problems, except that the components linking against CGAL +(foamyMesh and surfaceBooleanFeatures) will also try to link against +a nonexistent mpfr library. As a workaround, the link-dependency can +be removed in wmake/rules/General/CGAL : + + CGAL_LIBS = \ + -L$(BOOST_ARCH_PATH)/lib \ + -L$(BOOST_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \ + -L$(CGAL_ARCH_PATH)/lib \ + -L$(CGAL_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \ + -lCGAL + +This is a temporary inconvenience until a more robust solution is found. + + ------------------------- Building with spack ------------------------- diff --git a/etc/bashrc b/etc/bashrc index 2ad6b3512d..b1a39aaed3 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -36,7 +36,7 @@ export WM_PROJECT=OpenFOAM export WM_PROJECT_VERSION=plus # [FOAM_INST_DIR] - parent directory containing the OpenFOAM installation. -# * When this file is located as $WM_PROJECT_DIR/etc/bashrc, the next lines +# \- When this file is located as $WM_PROJECT_DIR/etc/bashrc, the next lines # should work when sourced by BASH or ZSH shells. If this however fails, # set one of the fallback values to an appropriate path. # -- @@ -104,23 +104,18 @@ export WM_MPLIB=SYSTEMOPENMPI ################################################################################ -# The old dirs to be cleaned from the environment variables +# Old directories to be cleaned from PATH, LD_LIBRARY_PATH foamOldDirs="$WM_PROJECT_DIR $WM_THIRD_PARTY_DIR \ $HOME/$WM_PROJECT/$USER $FOAM_USER_APPBIN $FOAM_USER_LIBBIN \ $WM_PROJECT_SITE $FOAM_SITE_APPBIN $FOAM_SITE_LIBBIN" -# Location of installation -# ~~~~~~~~~~~~~~~~~~~~~~~~ +# Location of installation and third-party software export WM_PROJECT_INST_DIR=$FOAM_INST_DIR export WM_PROJECT_DIR=$WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION - -# Location of third-party software -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ export WM_THIRD_PARTY_DIR=$WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION -# Location of site-specific templates etc -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# unset is equivalent to $WM_PROJECT_INST_DIR/site +# [WM_PROJECT_SITE] - Location of site-specific (group) files +# default (unset) implies WM_PROJECT_INST_DIR/site if [ -d "$WM_PROJECT_SITE" ] then export WM_PROJECT_SITE @@ -128,12 +123,10 @@ else unset WM_PROJECT_SITE fi -# Location of user files -# ~~~~~~~~~~~~~~~~~~~~~~ +# [WM_PROJECT_USER_DIR] - Location of user files export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION # Load shell functions -# ~~~~~~~~~~~~~~~~~~~~ . $WM_PROJECT_DIR/etc/config.sh/functions # Override definitions via prefs, with 'other' first so the sys-admin @@ -163,35 +156,29 @@ cleaned=$($foamClean "$MANPATH" "$foamOldDirs") && MANPATH="$cleaned" export PATH LD_LIBRARY_PATH MANPATH -# Source project setup files -# ~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Setup for OpenFOAM compilation etc +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _foamEtc config.sh/settings -if /usr/bin/tty -s 2>/dev/null # Interactive shell -then - _foamEtc config.sh/aliases - - # Bash completions - if [ "${BASH_VERSINFO:-0}" -ge 4 ] - then - _foamEtc config.sh/bash_completion - fi -fi - - -# Source user setup files for optional packages -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Setup for third-party packages +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _foamEtc config.sh/mpi _foamEtc config.sh/paraview _foamEtc config.sh/vtk _foamEtc config.sh/ensight _foamEtc config.sh/gperftools - -#_foamEtc config.sh/ADIOS +## _foamEtc config.csh/ADIOS _foamEtc config.sh/CGAL _foamEtc config.sh/scotch _foamEtc config.sh/FFTW +# Interactive shell +if /usr/bin/tty -s 2>/dev/null +then + _foamEtc config.sh/aliases + [ "${BASH_VERSINFO:-0}" -ge 4 ] && _foamEtc config.sh/bash_completion +fi + # Clean environment paths again. Only remove duplicates # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -214,13 +201,13 @@ then fi -# Cleanup environment -# ~~~~~~~~~~~~~~~~~~~ +# Cleanup temporary information +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# Functions +# Unload shell functions . $WM_PROJECT_DIR/etc/config.sh/functions -# Variables (do as last for a clean exit code) +# Variables (done as the last statement for a clean exit code) unset cleaned foamClean foamOldDirs #------------------------------------------------------------------------------ diff --git a/etc/config.csh/settings b/etc/config.csh/settings index 37c49f4e91..8b7d27e2a3 100644 --- a/etc/config.csh/settings +++ b/etc/config.csh/settings @@ -149,15 +149,14 @@ setenv FOAM_LIBBIN $WM_PROJECT_DIR/platforms/$WM_OPTIONS/lib # External (ThirdParty) libraries setenv FOAM_EXT_LIBBIN $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION/lib -# Site-specific directory +# Site-specific (group) files if ( $?WM_PROJECT_SITE ) then set siteDir=$WM_PROJECT_SITE else set siteDir=$WM_PROJECT_INST_DIR/site endif -# Shared site executables/libraries -# Similar naming convention as ~OpenFOAM expansion +# Shared site (group) executables/libraries setenv FOAM_SITE_APPBIN $siteDir/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/bin setenv FOAM_SITE_LIBBIN $siteDir/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/lib @@ -165,8 +164,8 @@ setenv FOAM_SITE_LIBBIN $siteDir/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/lib setenv FOAM_USER_APPBIN $WM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/bin setenv FOAM_USER_LIBBIN $WM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/lib -# DynamicCode templates -# - default location is the "~OpenFOAM/codeTemplates/dynamicCode" expansion +# [FOAM_CODE_TEMPLATES] - dynamicCode templates +# * fallback == "foamEtcFile -list codeTemplates/dynamicCode" # setenv FOAM_CODE_TEMPLATES $WM_PROJECT_DIR/etc/codeTemplates/dynamicCode # Convenience diff --git a/etc/config.sh/settings b/etc/config.sh/settings index 33aa7fa893..330f197af1 100644 --- a/etc/config.sh/settings +++ b/etc/config.sh/settings @@ -133,7 +133,7 @@ export FOAM_LIBBIN=$WM_PROJECT_DIR/platforms/$WM_OPTIONS/lib # External (ThirdParty) libraries export FOAM_EXT_LIBBIN=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION/lib -# Site-specific directory +# Site-specific (group) files if [ -n "$WM_PROJECT_SITE" ] then siteDir=$WM_PROJECT_SITE @@ -141,8 +141,7 @@ else siteDir=$WM_PROJECT_INST_DIR/site fi -# Shared site executables/libraries -# Similar naming convention as ~OpenFOAM expansion +# Shared site (group) executables/libraries export FOAM_SITE_APPBIN=$siteDir/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/bin export FOAM_SITE_LIBBIN=$siteDir/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/lib @@ -150,8 +149,8 @@ export FOAM_SITE_LIBBIN=$siteDir/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/lib export FOAM_USER_APPBIN=$WM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/bin export FOAM_USER_LIBBIN=$WM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/lib -# DynamicCode templates -# - default location is the "~OpenFOAM/codeTemplates/dynamicCode" expansion +# [FOAM_CODE_TEMPLATES] - dynamicCode templates +# * fallback == "foamEtcFile -list codeTemplates/dynamicCode" # export FOAM_CODE_TEMPLATES=$WM_PROJECT_DIR/etc/codeTemplates/dynamicCode # Convenience diff --git a/etc/cshrc b/etc/cshrc index 9a1e81d3ee..4dc34be99e 100644 --- a/etc/cshrc +++ b/etc/cshrc @@ -36,7 +36,7 @@ setenv WM_PROJECT OpenFOAM setenv WM_PROJECT_VERSION plus # [FOAM_INST_DIR] - parent directory containing the OpenFOAM installation. -# * When this file is located as $WM_PROJECT_DIR/etc/cshrc, the next lines +# \- When this file is located as $WM_PROJECT_DIR/etc/cshrc, the next lines # should work when sourced by CSH or TCSH shells. If this however fails, # set one of the fallback values to an appropriate path. # -- @@ -101,7 +101,7 @@ setenv WM_MPLIB SYSTEMOPENMPI ################################################################################ -# The old dirs to be cleaned from the environment variables +# Old directories to be cleaned from PATH, LD_LIBRARY_PATH set foamOldDirs= if ( $?WM_PROJECT_DIR ) then set foamOldDirs="$foamOldDirs $WM_PROJECT_DIR" @@ -119,18 +119,13 @@ if ( $?FOAM_SITE_LIBBIN ) then set foamOldDirs="$foamOldDirs $FOAM_SITE_LIBBIN" endif -# Location of installation -# ~~~~~~~~~~~~~~~~~~~~~~~~ +# Location of installation and third-party software setenv WM_PROJECT_INST_DIR $FOAM_INST_DIR -setenv WM_PROJECT_DIR $WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION +setenv WM_PROJECT_DIR $WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION +setenv WM_THIRD_PARTY_DIR $WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION -# Location of third-party software -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -setenv WM_THIRD_PARTY_DIR $WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION - -# Location of site-specific templates etc -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# unset is equivalent to $WM_PROJECT_INST_DIR/site +# [WM_PROJECT_SITE] - Location of site-specific (group) files +# default (unset) implies WM_PROJECT_INST_DIR/site if ( $?WM_PROJECT_SITE ) then set foamOldDirs="$WM_PROJECT_SITE $foamOldDirs" if ( ! -d "$WM_PROJECT_SITE" ) unsetenv WM_PROJECT_SITE @@ -138,8 +133,7 @@ else unsetenv WM_PROJECT_SITE endif -# Location of user files -# ~~~~~~~~~~~~~~~~~~~~~~ +# [WM_PROJECT_USER_DIR] - Location of user files setenv WM_PROJECT_USER_DIR $HOME/$WM_PROJECT/$LOGNAME-$WM_PROJECT_VERSION # Source an etc file, possibly with some verbosity @@ -210,27 +204,26 @@ set cleaned=`$foamClean "$MANPATH" "$foamOldDirs"` if ( $status == 0 ) setenv MANPATH $cleaned -# Source project setup files -# ~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Setup for OpenFOAM compilation etc +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _foamEtc config.csh/settings -if ($?prompt) then # Interactive shell - _foamEtc config.csh/aliases - _foamEtc config.csh/tcsh_completion -endif - - -# Source user setup files for optional packages -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Setup for third-party packages +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _foamEtc config.csh/mpi _foamEtc config.csh/paraview _foamEtc config.csh/vtk _foamEtc config.csh/ensight - -#_foamEtc config.csh/ADIOS +## _foamEtc config.csh/ADIOS _foamEtc config.csh/CGAL _foamEtc config.csh/FFTW +# Interactive shell +if ($?prompt) then + _foamEtc config.csh/aliases + _foamEtc config.csh/tcsh_completion +endif + # Clean environment paths again. Only remove duplicates # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -253,12 +246,15 @@ if ( $?LD_PRELOAD ) then endif -# Cleanup environment -# ~~~~~~~~~~~~~~~~~~~ -unset cleaned foamClean foamOldDirs +# Cleanup temporary information +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Unload shell "functions" unalias _foamEtc unalias _foamAddPath unalias _foamAddLib unalias _foamAddMan +unset cleaned foamClean foamOldDirs + #------------------------------------------------------------------------------ diff --git a/modules/README.md b/modules/README.md index 246fac8696..8bc84322da 100644 --- a/modules/README.md +++ b/modules/README.md @@ -1,15 +1,64 @@ OpenFOAM Modules ================ -This directory is a location to place additional OpenFOAM components -or tools and have them built as part of the normal OpenFOAM build +This directory is a location for additional OpenFOAM components or tools +to placed and have them built as part of the normal OpenFOAM build process. It is assumed that each subdirectory contain an appropriate -Allwmake file, and that they should in all likelihood also build into +Allwmake file, and that they in all likelihood also build into `$FOAM_APPBIN` and `$FOAM_LIBBIN` instead of `$FOAM_USER_APPBIN` and `$FOAM_USER_LIBBIN`. -These additional components may be added as git submodules, by script -or by hand. +These additional components may be added as [git submodules][man git-submodule], +by script or by hand. + + +### git + +On the first use, it will be necessary to register the submodules: + + git submodule init + + +This will clone the relevant submodules from their respective +repositories. + + +The following will indicate the current state: + + git submodule status + + +On the first use, or after merging upstream changes in the OpenFOAM +repository, it will be necessary to update the submodules: + + git submodule update + + +A quick overview of `git submodule` can be in this +[*blog*][blog git-submodule] with full details in the +[*manpage*][man git-submodule]. + + +An easy way to see which submodules are actually in use: + + `cat .gitmodules` + +Which will reveal content resembling the following: + + [submodule "cfmesh"] + path = modules/cfmesh + url = https://develop.openfoam.com/Community/integration-cfmesh.git + + +### doxygen To build the doxygen information for the components, it is also necessary to link the directories to the doc/ subdirectory. +This is a purely manual operation. + + + +[man git-submodule]: https://git-scm.com/docs/git-submodule +[blog git-submodule]: http://blog.joncairns.com/2011/10/how-to-use-git-submodules/ + +--- From 9c38ad6ae49a69e1d3cdb65a9e8a35cfb06652c3 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 21 Dec 2017 14:17:20 +0100 Subject: [PATCH 3/5] TUT: relocate tutorial log analysis as functions for reuse in modules - removed some unneeded tutorial files --- bin/tools/CleanFunctions | 17 +- bin/tools/LogFunctions | 120 ++ bin/tools/RunFunctions | 17 +- tutorials/Allclean | 15 +- tutorials/Allrun | 113 +- .../planeTransport/constant/faMesh/faBoundary | 212 --- .../planeTransport/constant/faMesh/faceLabels | 1224 ----------------- 7 files changed, 143 insertions(+), 1575 deletions(-) create mode 100644 bin/tools/LogFunctions delete mode 100644 tutorials/finiteArea/surfactantFoam/planeTransport/constant/faMesh/faBoundary delete mode 100644 tutorials/finiteArea/surfactantFoam/planeTransport/constant/faMesh/faceLabels diff --git a/bin/tools/CleanFunctions b/bin/tools/CleanFunctions index 431c52f383..2f546b4f84 100644 --- a/bin/tools/CleanFunctions +++ b/bin/tools/CleanFunctions @@ -6,20 +6,8 @@ # \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM. -# -# OpenFOAM 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. -# -# OpenFOAM 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 OpenFOAM. If not, see . +# This file is part of OpenFOAM, licensed under GNU General Public License +# . # # Script # CleanFunctions @@ -158,6 +146,7 @@ cleanFaMesh () ) } + cleanApplication() { echo "Cleaning application $PWD" diff --git a/bin/tools/LogFunctions b/bin/tools/LogFunctions new file mode 100644 index 0000000000..820ab4a27f --- /dev/null +++ b/bin/tools/LogFunctions @@ -0,0 +1,120 @@ +#!/bin/sh +#------------------------------------------------------------------------------ +# ========= | +# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox +# \\ / O peration | +# \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. +# \\/ M anipulation | +#------------------------------------------------------------------------------ +# License +# This file is part of OpenFOAM, licensed under GNU General Public License +# . +# +# Script +# LogFunctions +# +# Description +# Miscellaneous functions for running tutorials in a loop and for +# analyzing the output. +# +# Output is normally summarized as 'testLoopReport' +# +#------------------------------------------------------------------------------ + +# logReport +# Extracts useful info from log file. +logReport() +{ + local logfile=$1 + + # logfile is path/to/case/log.application + caseName=$(dirname $logfile | sed -e 's/\(.*\)\.\///g') + app=$(echo $logfile | sed -e 's/\(.*\)log\.//g') + appAndCase="Application $app - case $caseName" + + if grep -q "FOAM FATAL" $logfile + then + echo "$appAndCase: ** FOAM FATAL ERROR **" + return 1 + fi + + # Check for solution singularity on U equation + for eqn in Ux Uy Uz + do + if grep -q -E "${eqn}[:| ]*solution singularity" $logfile + then + if [ "$eqn" = Uz ] + then + # Can only get here if Ux,Uy,Uz all failed + echo "$appAndCase: ** Solution singularity **" + return 1 + fi + else + break + fi + done + + if grep -q -E "^[\t ]*[Ee]nd" $logfile + then + # Extract time from this type of content + ## ExecutionTime = 60.2 s ClockTime = 63 s --> "60.2 s" + completionTime=$(tail -10 $logfile | \ + sed -n -e '/Execution/{s/^[^=]*=[ \t]*//; s/\( s\) .*$/\1/; p}') + + echo "$appAndCase: completed${completionTime:+ in }$completionTime" + else + echo "$appAndCase: unconfirmed completion" + fi +} + + +# Collect and analyse all log files +collectLogs() +{ + echo "Collecting log files..." 1>&2 + rm -f logs testLoopReport > /dev/null 2>&1 + touch logs testLoopReport + + local appDir log logFiles + + for appDir in * + do + [ -d $appDir ] || continue + echo -n " $appDir..." 1>&2 + + logFiles=$(find -L $appDir -name 'log.*' -type f) + if [ -n "$logFiles" ] + then + echo 1>&2 + else + echo " (no logs)" 1>&2 + continue + fi + + # Sort logs by time-stamp + for log in $(echo $logFiles | xargs ls -rt) + do + # Concatenate and summarize logs + cat "$log" >> logs 2>/dev/null + logReport $log + done + echo + done > testLoopReport +} + + +removeLogs() +{ + echo "Removing backup files" + + find . \( \ + -name '*~' -o -name '*.bak' \ + -name core -o -name 'core.[1-9]*' \ + -name '*.pvs' -o -name '*.foam' -o -name '*.OpenFOAM' \ + \) -type f -delete + + rm -f logs testLoopReport > /dev/null 2>&1 +} + + +#------------------------------------------------------------------------------ diff --git a/bin/tools/RunFunctions b/bin/tools/RunFunctions index 55ab42d175..d9712dea2c 100644 --- a/bin/tools/RunFunctions +++ b/bin/tools/RunFunctions @@ -6,26 +6,15 @@ # \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM. -# -# OpenFOAM 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. -# -# OpenFOAM 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 OpenFOAM. If not, see . +# This file is part of OpenFOAM, licensed under GNU General Public License +# . # # Script # RunFunctions # # Description # Miscellaneous functions for running tutorial cases +# #------------------------------------------------------------------------------ # The normal locations diff --git a/tutorials/Allclean b/tutorials/Allclean index 0eea9fb549..bbaca026e2 100755 --- a/tutorials/Allclean +++ b/tutorials/Allclean @@ -1,18 +1,11 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/LogFunctions # Tutorial log-file functions echo "--------" +removeLogs + echo "Cleaning tutorials ..." -echo "Removing backup files" - -find . \( \ - -name '*~' -o -name '*.bak' \ - -name core -o -name 'core.[1-9]*' \ - -name '*.pvs' -o -name '*.OpenFOAM' \ - \) -type f -delete - -rm -f logs testLoopReport > /dev/null 2>&1 - foamCleanTutorials cases echo "--------" diff --git a/tutorials/Allrun b/tutorials/Allrun index 0a731b3fc9..77d185e928 100755 --- a/tutorials/Allrun +++ b/tutorials/Allrun @@ -7,26 +7,14 @@ # \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM. -# -# OpenFOAM 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. -# -# OpenFOAM 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 OpenFOAM. If not, see . +# This file is part of OpenFOAM, licensed under GNU General Public License +# . # # Script # Allrun # # Description -# Runs tutorial cases and summarizes the outcome as 'testLoopReport' +# Run tutorial cases and summarize the outcome as 'testLoopReport' # #------------------------------------------------------------------------------ cd ${0%/*} || exit 1 # Run from this directory @@ -43,27 +31,26 @@ options: -collect Collect logs only. Can be useful for aborted runs. -help print the usage -* Runs tutorial cases and summarizes the outcome as 'testLoopReport' +Run tutorial cases and summarize the outcome as 'testLoopReport' USAGE exit 1 } #------------------------------------------------------------------------------ +unset optCollect -unset optCollectOnly - -# parse options +# Parse options while [ "$#" -gt 0 ] do case "$1" in - -h | -help) + -h | -help*) usage ;; -collect) - optCollectOnly=true + optCollect=true ;; - -test) # Known options that should be passed through + -test) # Known options to pass through break ;; -*) @@ -77,87 +64,13 @@ do done #------------------------------------------------------------------------------ +. $WM_PROJECT_DIR/bin/tools/LogFunctions # Tutorial log-file functions -# logReport -# Extracts useful info from log file. -logReport() -{ - local logfile=$1 - - # logfile is path/to/case/log.application - caseName=$(dirname $logfile | sed -e 's/\(.*\)\.\///g') - app=$(echo $logfile | sed -e 's/\(.*\)log\.//g') - appAndCase="Application $app - case $caseName" - - if grep -q "FOAM FATAL" $logfile - then - echo "$appAndCase: ** FOAM FATAL ERROR **" - return 1 - fi - - # Check for solution singularity on U equation - for eqn in Ux Uy Uz - do - if grep -q -E "${eqn}[:| ]*solution singularity" $logfile - then - if [ "$eqn" = Uz ] - then - # Can only get here if Ux,Uy,Uz all failed - echo "$appAndCase: ** Solution singularity **" - return 1 - fi - else - break - fi - done - - if grep -q -E "^[\t ]*[Ee]nd" $logfile - then - # Extract time from this type of content - ## ExecutionTime = 60.2 s ClockTime = 63 s --> "60.2 s" - completionTime=$(tail -10 $logfile | \ - sed -n -e '/Execution/{s/^[^=]*=[ \t]*//; s/\( s\) .*$/\1/; p}') - - echo "$appAndCase: completed${completionTime:+ in }$completionTime" - else - echo "$appAndCase: unconfirmed completion" - fi -} - -if [ -z "$optCollectOnly" ] +if [ -z "$optCollect" ] then - # Recursively run all tutorials - foamRunTutorials -skipFirst $* + foamRunTutorials -skipFirst $* # Run tutorials recursively fi - -# Analyse all log files -echo "Collecting log files..." 1>&2 -rm -f logs testLoopReport > /dev/null 2>&1 -touch logs testLoopReport - -for appDir in * -do - [ -d $appDir ] || continue - echo -n " $appDir..." 1>&2 - - logs=$(find -L $appDir -name 'log.*' -type f) - if [ -n "$logs" ] - then - echo 1>&2 - else - echo " (no logs)" 1>&2 - continue - fi - - # Sort logs by time-stamp - for log in $(echo $logs | xargs ls -rt) - do - # Concatenate and summarize logs - cat "$log" >> logs 2>/dev/null - logReport $log - done - echo -done > testLoopReport +collectLogs #------------------------------------------------------------------------------ diff --git a/tutorials/finiteArea/surfactantFoam/planeTransport/constant/faMesh/faBoundary b/tutorials/finiteArea/surfactantFoam/planeTransport/constant/faMesh/faBoundary deleted file mode 100644 index ed1236d475..0000000000 --- a/tutorials/finiteArea/surfactantFoam/planeTransport/constant/faMesh/faBoundary +++ /dev/null @@ -1,212 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ -| ========= | | -| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus | -| \\ / A nd | Web: www.OpenFOAM.com | -| \\/ M anipulation | | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - version 2.0; - format ascii; - class faBoundaryMesh; - location "constant/faMesh"; - object faBoundary; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -3 -( - inlet - { - type patch; - edgeLabels List