View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0003303 | OpenFOAM | Bug | public | 2019-07-08 23:42 | 2019-07-24 14:32 |
Reporter | jherb | Assigned To | henry | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Platform | SUSE Linux Enterprise 11 SP4 | OS | Other | OS Version | (please specify) |
Fixed in Version | dev | ||||
Summary | 0003303: Compilation of (Intel) MPI fails | ||||
Description | Building OpenFOAM using the Allwmake script in $WM_PROJECT_DIR results in the following error: Compiling enabled on 20 cores Allwmake /home/hej/OpenFOAM/OpenFOAM-7 make: Nothing to be done for `all'. ======================================== Start ThirdParty Allwmake ======================================== ======================================== Build MPI libraries if required ======================================== Build Scotch decomposition library scotch_6.0.6 /home/hej/OpenFOAM/ThirdParty-7/platforms/linux64IccDPInt32/scotch_6.0.6 scotch header in /home/hej/OpenFOAM/ThirdParty-7/platforms/linux64IccDPInt32/scotch_6.0.6/include scotch libs in /home/hej/OpenFOAM/ThirdParty-7/platforms/linux64IccDPInt32/lib ======================================== Build PTScotch decomposition library scotch_6.0.6 (uses MPI) /home/hej/OpenFOAM/ThirdParty-7/platforms/linux64IccDPInt32/scotch_6.0.6 ptscotch header in /home/hej/OpenFOAM/ThirdParty-7/platforms/linux64IccDPInt32/scotch_6.0.6/include/intel64 ptscotch libs in /home/hej/OpenFOAM/ThirdParty-7/platforms/linux64IccDPInt32/lib/intel64 ======================================== Build Metis decomposition optional component Metis was not found ======================================== Build CGAL skipped because foamyHexMesh is not selected ======================================== Done ThirdParty Allwmake ======================================== Allwmake src version changed from previous build removing .o files corresponding to OpenFOAM/global/global.o ... Allwmake src/Pstream wmake dummy wclean mpi wmake mpi wmakeLnInclude: linking include files to ./lnInclude find: WARNING: Hard link count is wrong for `..' (saw only st_nlink=3 but we already saw 1 subdirectories): this may be a bug in your file system driver. Automatically turning on find's -noleaf option. Earlier results may have failed to include directories that should have been searched. touch: cannot touch `/home/hej/OpenFOAM/OpenFOAM-7/platforms/linux64IccDPInt32OptINTELMPI/src/Pstream/mpi/using:intel64': No such file or directory The offending line with the touch command is located in src/Pstream/Allrun This are the changes of the source tree compared with the git repository of OpenFOAM-7: diff --git a/etc/bashrc b/etc/bashrc index 19061dc..a37af07 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -62,7 +62,7 @@ export WM_COMPILER_TYPE=system #- Compiler: # WM_COMPILER = Gcc | Gcc48 ... Gcc62 | Clang | Icc -export WM_COMPILER=Gcc +export WM_COMPILER=Icc unset WM_COMPILER_ARCH WM_COMPILER_LIB_ARCH #- Memory addressing: @@ -86,7 +86,7 @@ export WM_COMPILE_OPTION=Opt #- MPI implementation: # WM_MPLIB = SYSTEMOPENMPI | OPENMPI | SYSTEMMPI | MPICH | MPICH-GM | HPMPI # | MPI | FJMPI | QSMPI | SGIMPI | INTELMPI -export WM_MPLIB=SYSTEMOPENMPI +export WM_MPLIB=INTELMPI #- Operating System: # WM_OSTYPE = POSIX | ??? diff --git a/src/Pstream/Allwmake b/src/Pstream/Allwmake index 9fdd37b..11a7f90 100755 --- a/src/Pstream/Allwmake +++ b/src/Pstream/Allwmake @@ -17,7 +17,7 @@ wmakeMpiLib() whichmpi="$WM_PROJECT_DIR/platforms/$WM_OPTIONS/src/Pstream/$libName/using:$FOAM_MPI" [ -e "$whichmpi" ] || wclean $libName wmake $targetType $libName - touch "$whichmpi" + #touch "$whichmpi" ) done } diff --git a/wmake/rules/General/mplibINTELMPI64 b/wmake/rules/General/mplibINTELMPI64 index 278e0b0..dbcc758 100644 --- a/wmake/rules/General/mplibINTELMPI64 +++ b/wmake/rules/General/mplibINTELMPI64 @@ -1,3 +1,3 @@ PFLAGS = -DMPICH_SKIP_MPICXX -PINC = -isystem $(MPI_ARCH_PATH)/include64 -PLIBS = -L$(MPI_ARCH_PATH)/lib64 -lmpi +PINC = -isystem /home/software/intel/Intel-2018/compilers_and_libraries_2018.0.128/linux/mpi/intel64/include +PLIBS = -L/home/software/intel/Intel-2018/compilers_and_libraries_2018.0.128/linux/mpi/intel64/lib -lmpi (removing the touch command allows to compile the source) | ||||
Tags | No tags attached. | ||||
|
The patches you have provided hard-code paths which means that with them OpenFOAM would only compile on your machine with Intel MPI. |
|
Yes, I am aware, that in my "patch" I hard-coded paths. The main problem is, that the Allwmake script/wmake want to touch this file: touch: cannot touch `/home/hej/OpenFOAM/OpenFOAM-7/platforms/linux64IccDPInt32OptINTELMPI/src/Pstream/mpi/using:intel64': No such file or directory And I cannot understand, how this file name is build. Perhaps, the problem is, that my OpenFOAM installation is using (symbolic) links. Building OpenFOAM-6 works. A more generic patch would be to add the paths to include and include64 and lib and lib64: diff --git a/wmake/rules/General/mplibINTELMPI64 b/wmake/rules/General/mplibINTELMPI64 index 278e0b0..dbcc758 100644 --- a/wmake/rules/General/mplibINTELMPI64 +++ b/wmake/rules/General/mplibINTELMPI64 @@ -1,3 +1,3 @@ PFLAGS = -DMPICH_SKIP_MPICXX -PINC = -isystem $(MPI_ARCH_PATH)/include64 -PLIBS = -L$(MPI_ARCH_PATH)/lib64 -lmpi +PINC = -isystem $(MPI_ARCH_PATH)/include64 -isystem $(MPI_ARCH_PATH)/include +PLIBS = -L$(MPI_ARCH_PATH)/lib64 -L$(MPI_ARCH_PATH)/lib -lmpi But this still does not solve my problem with the broken build. |
|
I am not able to reproduce the problem, for me the "touch" creates the empty file as intended. |
|
I compared OpenFOAM-6/src/Pstream/Allwmake with OpenFOAM-7/src/Pstream/Allwmake, they are identical so the file touch occurs for both version 6 and version 7. |
|
Reverting this commit fixes the problem: 9980357df166e81b5d67fe6de33f9fff7869e373 |
|
I can revert that commit but it was needed to resolve https://bugs.openfoam.org/view.php?id=3301 |
|
What is the filesystem being used here? And, what is the output from `pwd` and `pwd -P` in the top level OpenFOAM directory? This seems to be the issue: find: WARNING: Hard link count is wrong for `..' (saw only st_nlink=3 but we already saw 1 subdirectories): this may be a bug in your file system driver. Automatically turning on find's -noleaf option. Earlier results may have failed to include directories that should have been searched. (which I am guessing is coming from the `pwd -P`) |
|
My setup is: OpenFOAM is located in /manni/data/hej/OpenFOAM/OpenFOAM-7 HOME is /home/hej there are two symbolic links: /home/hej/data -> /manni/data/hej /home/hej/OpenFOAM/OpenFOAM-7 -> /home/hej/data/OpenFOAM/OpenFOAM-7 In the old version the IF clause in https://github.com/OpenFOAM/OpenFOAM-dev/commit/9980357df166e81b5d67fe6de33f9fff7869e373#diff-2a9ede44ae79c09f1b202e1e5db7e69eL398 evaluates to true, in the new version it is false, because: exPath: /manni/data/hej/OpenFOAM/OpenFOAM-7/src/Pstream/mpi and WM_PROJECT_DIR: /home/hej/OpenFOAM/OpenFOAM-7 |
|
This is the output of pwd -P in the OpenFOAM-7 folder: hej@manni:~/OpenFOAM/OpenFOAM-7> pwd -P /manni/data/hej/OpenFOAM/OpenFOAM-7 |
|
Do you edit the FOAM_INST_DIR inside `OpenFOAM-7/etc/bashrc`? If you haven't changed this, I am confused why you would have the shortened version of `$HOME/$WM_PROJECT`. @Henry - When would this export ever return a false value to execute the second part - https://github.com/OpenFOAM/OpenFOAM-dev/blob/master/etc/bashrc#L46) - A potential fix would be to set WM_PROJECT_INST_DIR to be the expanded path of $FOAM_INST_DIR here - https://github.com/OpenFOAM/OpenFOAM-dev/blob/master/etc/bashrc#L113 |
|
I was not involved in the changes to https://github.com/OpenFOAM/OpenFOAM-dev/blob/master/etc/bashrc#L46 to handle links, I never use links in the installation of OpenFOAM. This line has been changed several times over the last few years by people wanting to handle links in different and more complex ways, the last time it was commit 047460b0532160794a5cdfa54ba75766485b3a4f in response to patch request https://bugs.openfoam.org/view.php?id=2490 prior to that it was changed by Bruno Santos: commit 423ac54eabed1a9df7cd906686a8499f4cf69719 etc/bashrc: Added support for sourcing etc/bashrc with relative path Patch contributed by Bruno Santos Resolves bug-report http://bugs.openfoam.org/view.php?id=2310 and prior to that commit a874d8fae19a04b2f562655d4e9ead127c5c2540 OpenFOAM-dev/etc/bashrc: Use 'pwd -P' to handle relative paths and links Resolves bug-report http://bugs.openfoam.org/view.php?id=2223 the changes go on before this but it gets harder to trace. Most of the changes are patches provided by Bruno Santos. |
|
The logic was that 'pwd -P' will point to the correct/real path where OpenFOAM is really installed. So far, I haven't managed to trip over a situation where this was not wanted/expected, given that it's not strictly necessary to install OpenFOAM at '~/OpenFOAM/OpenFOAM-*'. Having the symbolic link might be useful to get around in the filesystem and this issue with the symbolic paths breaking when building MPI dependent libraries has also been reported here: https://bugs.openfoam.org/view.php?id=2204 So in order to keep things consistent, there are two things that are needed: 1. We need a clear answer (and a clear test scenario) as to why the symbolic path should be respected and why not always respect the real path? 2. The 'wmakeMpiLib' function is a hack in the 'Allwmake' scripts that shouldn't be necessary and should instead be managed by 'wmake' automatically, given that there 2 or 3 places where the hack is needed. |
|
@jherb: What is the specific filesystem used in '/manni/data'? Is it FAT32, NTFS, BTRFS, XFS, EXT4 or some other type? |
|
The filesystem of /manni is beegfs (https://www.beegfs.io/content/) But I think pwd -P is giving the correct answer. So I think the file system type is not the problem here, is it? |
|
@jherb: Wow, I didn't expect that... interesting file system... although it's not entirely clear if the long paths did fully resolve or not. Please test the following commands: cd /home/hej/OpenFOAM/OpenFOAM-7/platforms/linux64IccDPInt32OptINTELMPI/src/Pstream/mpi/ pwd -P What does the last command give you? Does it point to the '/manni/data/hej' path? The other test is to run these commands: touch dummy:test1 cd /manni/data/hej/OpenFOAM/OpenFOAM-7/platforms/linux64IccDPInt32OptINTELMPI/src/Pstream/mpi/ touch dummy:test2 Does it create the two files "dummy:test1" and "dummy:test2" or just one or none of them? Because my two doubts are: 1- If the filesystem really supports the colon symbol ':' or not. 2- If the only problem is that the 'wmakeMpiLib' needs to properly handle paths the same way as does 'wmake'. |
|
@jherb Do you edit the FOAM_INST_DIR inside `OpenFOAM-7/etc/bashrc`? |
|
No, I did not change FOAM_INST_DIR in etc/bashrc. It is: /home/hej/OpenFOAM The path /home/hej/OpenFOAM/OpenFOAM-7/platforms/linux64IccDPInt32OptINTELMPI/src/Pstream/mpi/ does not exist. What exists is: /home/hej/OpenFOAM/OpenFOAM-7/platforms/linux64IccDPInt32OptINTELMPI/src/Pstream/ pwd -P inside it results in: /manni/data/hej/OpenFOAM/OpenFOAM-7/platforms/linux64IccDPInt32OptINTELMPI/src/Pstream If I create the mpi subfolder and cd into it I get: > mkdir mpi > cd /home/hej/OpenFOAM/OpenFOAM-7/platforms/linux64IccDPInt32OptINTELMPI/src/Pstream/mpi/ > pwd -P /manni/data/hej/OpenFOAM/OpenFOAM-7/platforms/linux64IccDPInt32OptINTELMPI/src/Pstream/mpi The touch commands created both files: > ls dummy:test1 dummy:test2 |
|
I don't understand why $HOME/$WM_PROJECT is used rather than $(cd $(dirname ${BASH_SOURCE:-$0})/../.. && pwd -P). Does anyone else understand this? |
|
@jherb: Many thanks, now I have a much clearer picture of what's going on. Although I'm wondering if you really need the two-step symbolic link (1st data, 2nd through local link)... why not only use one-step direct symbolic link? @paulmedwards: That's only used if the first line fails. Notice the "||" near the end of the first line that handles finding the current real installation path. So if it fails, it goes for the default that OpenFOAM assumes for the past several years, if not since its inception. |
|
@wyldckat: I understand the bash syntax but I don't see how it can be triggered as you need the export to return non-null, wouldn't you? E.g. export FOO=$(exit 1) || export FOO=bar That still means than FOO is empty. Or, am I misunderstanding here? |
|
@paulmedwards: You're right, the '||' doesn't work in this case... Let me check, the original commit when that was started was this: https://github.com/OpenFOAM/OpenFOAM-dev/commit/4114a1e2bf85ec33024f51b230bb1cd7a97f6f32 Oh, right, I didn't look at the line before that, so for the current code in OpenFOAM-dev it's: [ "$BASH" -o "$ZSH_NAME" ] && \ export FOAM_INST_DIR=$(cd $(dirname ${BASH_SOURCE:-$0})/../.. && pwd -P) || \ export FOAM_INST_DIR=$HOME/$WM_PROJECT The '||' is actually as a match for the '&&', namely that if it's not bash not zsh, then it uses the default path. If the 'pwd -P' fails for whatever reason, there is no proper fallback. OK, I'm going to work on this right now and try to figure this out once and for all. |
|
Now I understand paulmedwards' comments on the default being "$HOME/$WM_PROJECT"... the symbolic path structure defined in jherb's installation has a real path "$HOME/OpenFOAM", but the rest is symbolic, therefore making 'pwd -P' a bit misleading, since it only checks how real is the '$FOAM_INST_DIR'. Attached is a proof of concept of what technically the end result needs to be, although it's not the most elegant implementation and likely not the most popular solution. The attached proposal files: - proposal_v3.patch - shows the changes made to the file 'etc/bashrc'. - bashrc_proposal_v3 - has the complete 'etc/bashrc', indexed to the commit mentioned in the patch file. The proposal here is to always enforce the real paths, where the simplest approach was to change this directly at the initial sourcing of 'etc/bashrc', instead of hiding it within 'wmake', namely also enforcing the real paths for '$WM_PROJECT_DIR' and '$WM_THIRD_PARTY_DIR'. The reasoning for this is as follows: 1- The critical issue with symbolic links is that we can easily end up on the real path, instead of the symbolic path. For example, I reproduced jherb's path as follows, at '/home/ofuser' in a virtual machine with Ubuntu 18.04: data -> /mnt/data/ofuser/ OpenFOAM/OpenFOAM-dev -> /home/ofuser/data/OpenFOAM/OpenFOAM-dev/ 2- Then one way we can easily end up on the real path is by running: cd ~/OpenFOAM/OpenFOAM-dev/ source etc/bashrc And then open a new tab in the Gnome terminal. This will open the new tab into the folder '/mnt/data/ofuser/OpenFOAM/OpenFOAM-dev/' 3- If we then run automatically or manually: source ~/OpenFOAM/OpenFOAM-dev/etc/bashrc 4- ... the nightmare can begin as follows: 1- Run a few build commands on the symbolic path. 2- Run a few build commands on the real path. 3- What we end up is with a messy build, if one at all, because the commands were executed in the wrong places. This is vaguely how remember the 'pwd -P' requirement starting to appear. Therefore, the only consistent way to ensure the build is done properly in either symbolic paths, or the real paths the symbolic ones point to, is to always reference the real paths. AFAIK this doesn't hurt OpenFOAM's libraries and applications, because the binaries do not have a hard bind to the path into which they were linking into, given that they are dynamic. The only issues I remember seeing popup in the past in this regard was with ParaView, Qt and Open-MPI, namely their custom builds, although some circumvention measures for this have been implemented into OpenFOAM's 'ThirdParty' folder, by re-basing after the build is complete for the respective build script. @paulmedwards and @jherb: I don't know if you agree with this change to the 'etc/bashrc' file, but my main concern is whether the final build is then usable the way you want it to work, namely in a way that the installation is fully portable. I'll only be able to test this during the weekend, so if either one of you could test this sooner, it would speed up fixing this issue. If this works properly, then a more elegant and consistent fix can be implemented. bashrc_proposal_v3 (7,432 bytes)
#----------------------------------*-sh-*-------------------------------------- # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | Website: https://openfoam.org # \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation # \\/ M anipulation | #------------------------------------------------------------------------------ # 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 <http://www.gnu.org/licenses/>. # # File # etc/bashrc # # Description # Startup file for OpenFOAM # Sourced from ~/.profile or ~/.bashrc # Should be usable by any POSIX-compliant shell (eg, ksh) # #------------------------------------------------------------------------------ export WM_PROJECT=OpenFOAM export WM_PROJECT_VERSION=dev ################################################################################ # USER EDITABLE PART: Changes made here may be lost with the next upgrade # # FOAM_INST_DIR is the location of the OpenFOAM installation which defaults to # the directory containing this file if sourced by a bash shell. # # Please set to the appropriate path if the default is not correct. # [ "$BASH" -o "$ZSH_NAME" ] && \ export FOAM_INST_DIR=$(cd $(dirname ${BASH_SOURCE:-$0})/../.. && pwd -P) || \ export FOAM_INST_DIR=$HOME/$WM_PROJECT # export FOAM_INST_DIR=~$WM_PROJECT # export FOAM_INST_DIR=/opt/$WM_PROJECT # export FOAM_INST_DIR=/usr/local/$WM_PROJECT # # END OF (NORMAL) USER EDITABLE PART ################################################################################ # The default environment variables below can be overridden in a prefs.sh file # located in ~/.OpenFOAM/$WM_PROJECT_VERSION, ~/.OpenFOAM, # $FOAM_INST_DIR/site/$WM_PROJECT_VERSION or $FOAM_INST_DIR/site #- Compiler location: # WM_COMPILER_TYPE= system | ThirdParty (OpenFOAM) export WM_COMPILER_TYPE=system #- Compiler: # WM_COMPILER = Gcc | Gcc48 ... Gcc62 | Clang | Icc export WM_COMPILER=Gcc unset WM_COMPILER_ARCH WM_COMPILER_LIB_ARCH #- Memory addressing: # On a 64bit OS this can be 32bit or 64bit # On a 32bit OS addressing is 32bit and this option is not used # WM_ARCH_OPTION = 32 | 64 export WM_ARCH_OPTION=64 #- Precision: # WM_PRECISION_OPTION = SP | DP | LP export WM_PRECISION_OPTION=DP #- Label size: # WM_LABEL_SIZE = 32 | 64 export WM_LABEL_SIZE=32 #- Optimised, debug, profiling: # WM_COMPILE_OPTION = Opt | Debug | Prof export WM_COMPILE_OPTION=Opt #- MPI implementation: # WM_MPLIB = SYSTEMOPENMPI | OPENMPI | SYSTEMMPI | MPICH | MPICH-GM | HPMPI # | MPI | FJMPI | QSMPI | SGIMPI | INTELMPI export WM_MPLIB=SYSTEMOPENMPI #- Operating System: # WM_OSTYPE = POSIX | ??? export WM_OSTYPE=POSIX #- Floating-point signal handling: # set or unset export FOAM_SIGFPE= #- memory initialisation: # set or unset #export FOAM_SETNAN= ################################################################################ # The old dirs to be cleaned from the environment variables 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 # ~~~~~~~~~~~~~~~~~~~~~~~~ export WM_PROJECT_INST_DIR=$FOAM_INST_DIR export WM_PROJECT_DIR=$WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION WM_PROJECT_DIR_REAL=$(cd $WM_PROJECT_DIR && pwd -P) if [ -d "$WM_PROJECT_DIR_REAL" -a -e "$WM_PROJECT_DIR_REAL/etc/bashrc" ] then export WM_PROJECT_DIR=$WM_PROJECT_DIR_REAL fi unset WM_PROJECT_DIR_REAL # Location of third-party software # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ export WM_THIRD_PARTY_DIR=$WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION WM_THIRD_PARTY_DIR_REAL=$(cd $WM_PROJECT_DIR && pwd -P) if [ -d "$WM_THIRD_PARTY_DIR_REAL" -a -e "$WM_THIRD_PARTY_DIR_REAL/etc" ] then export WM_THIRD_PARTY_DIR=$WM_THIRD_PARTY_DIR_REAL fi unset WM_THIRD_PARTY_DIR_REAL # Location of site-specific templates etc # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # unset is equivalent to $WM_PROJECT_INST_DIR/site if [ -d "$WM_PROJECT_SITE" ] then export WM_PROJECT_SITE else unset WM_PROJECT_SITE fi # Location of user files # ~~~~~~~~~~~~~~~~~~~~~~ export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION # Source initialization functions # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ . $WM_PROJECT_DIR/etc/config.sh/functions # Add in preset user or site preferences: _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile prefs.sh` # Evaluate command-line parameters and record settings for later # these can be used to set/unset values, or specify alternative pref files export FOAM_SETTINGS="$@" _foamEval $@ # Clean standard environment variables (PATH, LD_LIBRARY_PATH, MANPATH) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ foamClean=$WM_PROJECT_DIR/bin/foamCleanPath #- Clean PATH cleaned=`$foamClean "$PATH" "$foamOldDirs"` && PATH="$cleaned" #- Clean LD_LIBRARY_PATH cleaned=`$foamClean "$LD_LIBRARY_PATH" "$foamOldDirs"` \ && LD_LIBRARY_PATH="$cleaned" #- Clean MANPATH cleaned=`$foamClean "$MANPATH" "$foamOldDirs"` && MANPATH="$cleaned" export PATH LD_LIBRARY_PATH MANPATH # Source project setup files # ~~~~~~~~~~~~~~~~~~~~~~~~~~ _foamSource $WM_PROJECT_DIR/etc/config.sh/settings _foamSource $WM_PROJECT_DIR/etc/config.sh/aliases # Source user setup files for optional packages # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/mpi` _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/paraview` _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/ensight` _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/gperftools` if [ ! -z "$FOAMY_HEX_MESH" ] then _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/CGAL` fi # Clean environment paths again. Only remove duplicates # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #- Clean PATH cleaned=`$foamClean "$PATH"` && PATH="$cleaned" #- Clean LD_LIBRARY_PATH cleaned=`$foamClean "$LD_LIBRARY_PATH"` && LD_LIBRARY_PATH="$cleaned" #- Clean MANPATH (trailing ':' to find system pages) cleaned=`$foamClean "$MANPATH"`: && MANPATH="$cleaned" export PATH LD_LIBRARY_PATH MANPATH #- Clean LD_PRELOAD if [ -n "$LD_PRELOAD" ] then cleaned=`$foamClean "$LD_PRELOAD"` && LD_PRELOAD="$cleaned" export LD_PRELOAD fi # Cleanup environment: # ~~~~~~~~~~~~~~~~~~~~ unset cleaned foamClean foamOldDirs # Unload initialization functions: # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ . $WM_PROJECT_DIR/etc/config.sh/functions # Source the bash completion file: # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [ "$BASH" ] && . $WM_PROJECT_DIR/etc/config.sh/bash_completion #------------------------------------------------------------------------------ proposal_v3.patch (1,031 bytes)
diff --git a/etc/bashrc b/etc/bashrc index ae19940..f55914a 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -113,10 +113,24 @@ foamOldDirs="$WM_PROJECT_DIR $WM_THIRD_PARTY_DIR \ export WM_PROJECT_INST_DIR=$FOAM_INST_DIR export WM_PROJECT_DIR=$WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION +WM_PROJECT_DIR_REAL=$(cd $WM_PROJECT_DIR && pwd -P) +if [ -d "$WM_PROJECT_DIR_REAL" -a -e "$WM_PROJECT_DIR_REAL/etc/bashrc" ] +then + export WM_PROJECT_DIR=$WM_PROJECT_DIR_REAL +fi +unset WM_PROJECT_DIR_REAL + # Location of third-party software # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ export WM_THIRD_PARTY_DIR=$WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION +WM_THIRD_PARTY_DIR_REAL=$(cd $WM_PROJECT_DIR && pwd -P) +if [ -d "$WM_THIRD_PARTY_DIR_REAL" -a -e "$WM_THIRD_PARTY_DIR_REAL/etc" ] +then + export WM_THIRD_PARTY_DIR=$WM_THIRD_PARTY_DIR_REAL +fi +unset WM_THIRD_PARTY_DIR_REAL + # Location of site-specific templates etc # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # unset is equivalent to $WM_PROJECT_INST_DIR/site |
|
I tried it with only one link in /home/hej/OpenFOAM: OpenFOAM-7 -> /manni/data/hej/OpenFOAM/OpenFOAM-7 (so no intermediate link) The behavior is the same (broken) as before. |
|
I tried the above bashrc (after changing the OpenFOAM version from dev to 7) It breaks the build, if started from within the OpenFOAM directory: (my_root37) hej@manni:/manni/data/hej/OpenFOAM/OpenFOAM-7> ./Allwmake 2>&1 | tee ~/build-OpenFOAM-7-190717-02 Allwmake /manni/data/hej/OpenFOAM/OpenFOAM-7 make: Nothing to be done for `all'. Allwmake /manni/data/hej/OpenFOAM/OpenFOAM-7 make: Nothing to be done for `all'. If started from a subfolder (e.g. src or src/Pstream) it works |
|
@wyldckat: ah - I missed that line before too! So, it uses $HOME/$WM_PROJECT because "$BASH" or "$ZSH_NAME" are not set? I am wondering why we have that check (and, why they aren't set) - especially since we ask to source *bashrc*. @jherb: which shell are you using? |
|
GNU bash, version 3.2.57(2)-release (x86_64-suse-linux-gnu) |
|
@paulmedwards: Dash is the default shell in Ubuntu, hence one of the reasons as to why 'etc/bashrc' is working on this as safely as possible and since it's a minimal effort to support it. Furthermore, since in Ubuntu '/bin/sh' is Dash, a job scripts might use it and have to source 'etc/bashrc'. @jherb: Many thanks and my apologies, I completely forgot to test it from the main folder. I'll try to re-check what's going on with it later today. |
|
@jherb Is $BASH set? I'm guessing not... What happens if you do the following: export BASH=$(which bash) source ~/OpenFOAM/OpenFOAM-7/etc/bashrc echo $FOAM_INST_DIR (and try building....) |
|
@wyldckat Why not just check for dash as well and have the other condition as "echo 'Please source with bash/dash/zsh shell'"? Rather than just picking $HOME/OpenFOAM/. At the moment it won't work for dash if OpenFOAM is in a different location. |
|
BASH is set: echo $BASH /bin/bash |
|
I haven't tested it yet, but also the folders which contain user code which is build/linked against the installation of OpenFOAM might contain links |
|
I still don't understand why "FOAM_INST_DIR=$HOME/$WM_PROJECT". As "$BASH" is not empty then it should not be set here: [ "$BASH" -o "$ZSH_NAME" ] && \ export FOAM_INST_DIR=$(cd $(dirname ${BASH_SOURCE:-$0})/../.. && pwd -P) || \ export FOAM_INST_DIR=$HOME/$WM_PROJECT Does anyone understand this? |
|
This is the output of test: > [ "$BASH" -o "$ZSH_NAME" ] && echo test test |
|
What is FOAM_INST_DIR set to? @wyldkcat Can this be set anywhere else? |
|
@paulmedwards: The path in jherb's installation is a real path, namely: FOAM_INST_DIR=/home/hej/OpenFOAM The problem is that it's '/home/hej/OpenFOAM/OpenFOAM-7' that is a symbolic link and 'etc/bashrc' doesn't check for that. Namely: cd $(dirname ${BASH_SOURCE:-$0})/../.. equates to: /home/hej/OpenFOAM/OpenFOAM-7/etc/../.. /home/hej/OpenFOAM Therefore FOAM_INST_DIR will be the same path in this specific installation, regardless of the symbolic path or not for the subfolders, since '/home/hej/OpenFOAM' is a real path. @jherb: You mentioned: > folders which contain user code which is build/linked against the installation of OpenFOAM might contain links Since there is a lot of information floating in this report, please provide a few more details (step-by-step if possible?), so that we can reproduce this. No hurry on my side, since I will only be able to look into this later tonight. |
|
@paulmedwards: There used to be a way for the use to pre-emptively set FOAM_INST_DIR or similar in the past... but that was replaced by the current mechanism, if I'm seeing things correctly. |
|
thanks @wyldckat - I see now. That is confusing with symlinks in the OpenFOAM directory. |
|
OK, now I've revised and tested the changes into 'etc/bashrc' and it seemed to work as intended. I had made a critical mistake with a copy-paste and not correcting the 'cd' command for the 3rd party, which resulted in it going into '$WM_PROJECT_DIR' instead. But that also revealed that if the 'ThirdParty-$WM_PROJECT_VERSION' folder doesn't exist, we should not try to 'cd' into it, since it will fail and risk landing it in the wrong place and breaking everything. Anyway, please find in attached the following proposal files, also still experimental: - proposal_v4.patch - shows the changes made to the file 'etc/bashrc'. - bashrc_proposal_v4 - has the complete 'etc/bashrc', indexed to the commit mentioned in the patch file. Even if the user runs the 'Allwmake' command from within the symbolic path, this mechanism will ensure that the real paths are always used. I'm going to leave the build running overnight and tomorrow (Thursday) at night I'll test carrying the installation elsewhere, to see if it still works as intended or not, to test if there are problems with hard-coded paths. bashrc_proposal_v4 (7,566 bytes)
#----------------------------------*-sh-*-------------------------------------- # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | Website: https://openfoam.org # \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation # \\/ M anipulation | #------------------------------------------------------------------------------ # 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 <http://www.gnu.org/licenses/>. # # File # etc/bashrc # # Description # Startup file for OpenFOAM # Sourced from ~/.profile or ~/.bashrc # Should be usable by any POSIX-compliant shell (eg, ksh) # #------------------------------------------------------------------------------ export WM_PROJECT=OpenFOAM export WM_PROJECT_VERSION=dev ################################################################################ # USER EDITABLE PART: Changes made here may be lost with the next upgrade # # FOAM_INST_DIR is the location of the OpenFOAM installation which defaults to # the directory containing this file if sourced by a bash shell. # # Please set to the appropriate path if the default is not correct. # [ "$BASH" -o "$ZSH_NAME" ] && \ export FOAM_INST_DIR=$(cd $(dirname ${BASH_SOURCE:-$0})/../.. && pwd -P) || \ export FOAM_INST_DIR=$HOME/$WM_PROJECT # export FOAM_INST_DIR=~$WM_PROJECT # export FOAM_INST_DIR=/opt/$WM_PROJECT # export FOAM_INST_DIR=/usr/local/$WM_PROJECT # # END OF (NORMAL) USER EDITABLE PART ################################################################################ # The default environment variables below can be overridden in a prefs.sh file # located in ~/.OpenFOAM/$WM_PROJECT_VERSION, ~/.OpenFOAM, # $FOAM_INST_DIR/site/$WM_PROJECT_VERSION or $FOAM_INST_DIR/site #- Compiler location: # WM_COMPILER_TYPE= system | ThirdParty (OpenFOAM) export WM_COMPILER_TYPE=system #- Compiler: # WM_COMPILER = Gcc | Gcc48 ... Gcc62 | Clang | Icc export WM_COMPILER=Gcc unset WM_COMPILER_ARCH WM_COMPILER_LIB_ARCH #- Memory addressing: # On a 64bit OS this can be 32bit or 64bit # On a 32bit OS addressing is 32bit and this option is not used # WM_ARCH_OPTION = 32 | 64 export WM_ARCH_OPTION=64 #- Precision: # WM_PRECISION_OPTION = SP | DP | LP export WM_PRECISION_OPTION=DP #- Label size: # WM_LABEL_SIZE = 32 | 64 export WM_LABEL_SIZE=32 #- Optimised, debug, profiling: # WM_COMPILE_OPTION = Opt | Debug | Prof export WM_COMPILE_OPTION=Opt #- MPI implementation: # WM_MPLIB = SYSTEMOPENMPI | OPENMPI | SYSTEMMPI | MPICH | MPICH-GM | HPMPI # | MPI | FJMPI | QSMPI | SGIMPI | INTELMPI export WM_MPLIB=SYSTEMOPENMPI #- Operating System: # WM_OSTYPE = POSIX | ??? export WM_OSTYPE=POSIX #- Floating-point signal handling: # set or unset export FOAM_SIGFPE= #- memory initialisation: # set or unset #export FOAM_SETNAN= ################################################################################ # The old dirs to be cleaned from the environment variables 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 # ~~~~~~~~~~~~~~~~~~~~~~~~ export WM_PROJECT_INST_DIR=$FOAM_INST_DIR export WM_PROJECT_DIR=$WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION if [ -d "$WM_PROJECT_DIR" ] then WM_PROJECT_DIR_REAL=$(cd $WM_PROJECT_DIR && pwd -P) if [ -d "$WM_PROJECT_DIR_REAL" -a -e "$WM_PROJECT_DIR_REAL/etc/bashrc" ] then export WM_PROJECT_DIR=$WM_PROJECT_DIR_REAL fi unset WM_PROJECT_DIR_REAL fi # Location of third-party software # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ export WM_THIRD_PARTY_DIR=$WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION if [ -d "$WM_THIRD_PARTY_DIR" ] then WM_THIRD_PARTY_DIR_REAL=$(cd $WM_THIRD_PARTY_DIR && pwd -P) if [ -d "$WM_THIRD_PARTY_DIR_REAL" -a -e "$WM_THIRD_PARTY_DIR_REAL/etc/tools" ] then export WM_THIRD_PARTY_DIR=$WM_THIRD_PARTY_DIR_REAL fi unset WM_THIRD_PARTY_DIR_REAL fi # Location of site-specific templates etc # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # unset is equivalent to $WM_PROJECT_INST_DIR/site if [ -d "$WM_PROJECT_SITE" ] then export WM_PROJECT_SITE else unset WM_PROJECT_SITE fi # Location of user files # ~~~~~~~~~~~~~~~~~~~~~~ export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION # Source initialization functions # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ . $WM_PROJECT_DIR/etc/config.sh/functions # Add in preset user or site preferences: _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile prefs.sh` # Evaluate command-line parameters and record settings for later # these can be used to set/unset values, or specify alternative pref files export FOAM_SETTINGS="$@" _foamEval $@ # Clean standard environment variables (PATH, LD_LIBRARY_PATH, MANPATH) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ foamClean=$WM_PROJECT_DIR/bin/foamCleanPath #- Clean PATH cleaned=`$foamClean "$PATH" "$foamOldDirs"` && PATH="$cleaned" #- Clean LD_LIBRARY_PATH cleaned=`$foamClean "$LD_LIBRARY_PATH" "$foamOldDirs"` \ && LD_LIBRARY_PATH="$cleaned" #- Clean MANPATH cleaned=`$foamClean "$MANPATH" "$foamOldDirs"` && MANPATH="$cleaned" export PATH LD_LIBRARY_PATH MANPATH # Source project setup files # ~~~~~~~~~~~~~~~~~~~~~~~~~~ _foamSource $WM_PROJECT_DIR/etc/config.sh/settings _foamSource $WM_PROJECT_DIR/etc/config.sh/aliases # Source user setup files for optional packages # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/mpi` _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/paraview` _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/ensight` _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/gperftools` if [ ! -z "$FOAMY_HEX_MESH" ] then _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/CGAL` fi # Clean environment paths again. Only remove duplicates # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #- Clean PATH cleaned=`$foamClean "$PATH"` && PATH="$cleaned" #- Clean LD_LIBRARY_PATH cleaned=`$foamClean "$LD_LIBRARY_PATH"` && LD_LIBRARY_PATH="$cleaned" #- Clean MANPATH (trailing ':' to find system pages) cleaned=`$foamClean "$MANPATH"`: && MANPATH="$cleaned" export PATH LD_LIBRARY_PATH MANPATH #- Clean LD_PRELOAD if [ -n "$LD_PRELOAD" ] then cleaned=`$foamClean "$LD_PRELOAD"` && LD_PRELOAD="$cleaned" export LD_PRELOAD fi # Cleanup environment: # ~~~~~~~~~~~~~~~~~~~~ unset cleaned foamClean foamOldDirs # Unload initialization functions: # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ . $WM_PROJECT_DIR/etc/config.sh/functions # Source the bash completion file: # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [ "$BASH" ] && . $WM_PROJECT_DIR/etc/config.sh/bash_completion #------------------------------------------------------------------------------ proposal_v4.patch (1,622 bytes)
diff --git a/etc/bashrc b/etc/bashrc index ae19940..5f5d9d9 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -2,7 +2,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | Website: https://openfoam.org -# \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation +# \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation # \\/ M anipulation | #------------------------------------------------------------------------------ # License @@ -113,10 +113,30 @@ foamOldDirs="$WM_PROJECT_DIR $WM_THIRD_PARTY_DIR \ export WM_PROJECT_INST_DIR=$FOAM_INST_DIR export WM_PROJECT_DIR=$WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION +if [ -d "$WM_PROJECT_DIR" ] +then + WM_PROJECT_DIR_REAL=$(cd $WM_PROJECT_DIR && pwd -P) + if [ -d "$WM_PROJECT_DIR_REAL" -a -e "$WM_PROJECT_DIR_REAL/etc/bashrc" ] + then + export WM_PROJECT_DIR=$WM_PROJECT_DIR_REAL + fi + unset WM_PROJECT_DIR_REAL +fi + # Location of third-party software # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ export WM_THIRD_PARTY_DIR=$WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION +if [ -d "$WM_THIRD_PARTY_DIR" ] +then + WM_THIRD_PARTY_DIR_REAL=$(cd $WM_THIRD_PARTY_DIR && pwd -P) + if [ -d "$WM_THIRD_PARTY_DIR_REAL" -a -e "$WM_THIRD_PARTY_DIR_REAL/etc/tools" ] + then + export WM_THIRD_PARTY_DIR=$WM_THIRD_PARTY_DIR_REAL + fi + unset WM_THIRD_PARTY_DIR_REAL +fi + # Location of site-specific templates etc # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # unset is equivalent to $WM_PROJECT_INST_DIR/site |
|
*this mechanism I meant that with this environment definition, associated with the existing mechanism in 'wmake', will ensure things work as intended, namely to always respect the real path. |
|
@wyldckat: It looks like the latest bashrc (_v4) is working as expected. |
|
@jherb: Many thanks! OK, then later tonight I'll try to test carrying the installation elsewhere, to see if it works as intended and if there are any problems if other users try to compile custom code and link to this transported build. |
|
Perhaps, I have found a new problem: If I build the whole of OpenFOAM, then go into src/Pstream and call ./Allwclean or execute wclean in the subfolders, then ./Allbuild (or wmake in the subfolders) does nothing. I have to remove the content of folder platforms/linux64IccDPInt32OptINTELMPI/src/Pstream/mpi/ to get those files rebuild I also tried it in a different folder: src/TurbulenceModels/incompressible> First wclean, then wmake and nothing is build |
|
This works as expected: touch incompressibleTurbulenceModel.C wmake (it rebuilds those file and then links the corresponding library) |
|
@jherb: Good catch! The missing detail was that 'wclean' needed the same changes that were done in 'wmake', namely the real patch check. Attached are the following files: - wclean_proposal_v5 - the updated 'wclean' file - proposal_v5.patch - the updated proposal patch, including both 'bashrc' and 'wclean' I'll have to postpone to tomorrow night the test regarding moving the installation to another VM. proposal_v5.patch (2,639 bytes)
diff --git a/etc/bashrc b/etc/bashrc index ae19940..5f5d9d9 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -2,7 +2,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | Website: https://openfoam.org -# \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation +# \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation # \\/ M anipulation | #------------------------------------------------------------------------------ # License @@ -113,10 +113,30 @@ foamOldDirs="$WM_PROJECT_DIR $WM_THIRD_PARTY_DIR \ export WM_PROJECT_INST_DIR=$FOAM_INST_DIR export WM_PROJECT_DIR=$WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION +if [ -d "$WM_PROJECT_DIR" ] +then + WM_PROJECT_DIR_REAL=$(cd $WM_PROJECT_DIR && pwd -P) + if [ -d "$WM_PROJECT_DIR_REAL" -a -e "$WM_PROJECT_DIR_REAL/etc/bashrc" ] + then + export WM_PROJECT_DIR=$WM_PROJECT_DIR_REAL + fi + unset WM_PROJECT_DIR_REAL +fi + # Location of third-party software # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ export WM_THIRD_PARTY_DIR=$WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION +if [ -d "$WM_THIRD_PARTY_DIR" ] +then + WM_THIRD_PARTY_DIR_REAL=$(cd $WM_THIRD_PARTY_DIR && pwd -P) + if [ -d "$WM_THIRD_PARTY_DIR_REAL" -a -e "$WM_THIRD_PARTY_DIR_REAL/etc/tools" ] + then + export WM_THIRD_PARTY_DIR=$WM_THIRD_PARTY_DIR_REAL + fi + unset WM_THIRD_PARTY_DIR_REAL +fi + # Location of site-specific templates etc # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # unset is equivalent to $WM_PROJECT_INST_DIR/site diff --git a/wmake/wclean b/wmake/wclean index 8ccd637..3c3d80d 100755 --- a/wmake/wclean +++ b/wmake/wclean @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | Website: https://openfoam.org -# \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation +# \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation # \\/ M anipulation | #------------------------------------------------------------------------------ # License @@ -260,10 +260,11 @@ unset targetType if [ -d "$MakeDir" ] then objectsDir=$MakeDir/$WM_OPTIONS - if [[ "$PWD" = *"$WM_PROJECT_DIR"* ]] + expandPath "$PWD" + if [[ "$exPath" = *"$WM_PROJECT_DIR"* ]] then platformPath=$WM_PROJECT_DIR/platforms/${WM_OPTIONS} - objectsDir=$platformPath${PWD//$WM_PROJECT_DIR/} + objectsDir=$platformPath${exPath//$WM_PROJECT_DIR/} fi rm -rf "$objectsDir" 2>/dev/null fi wclean_proposal_v5 (8,946 bytes)
#!/bin/bash #------------------------------------------------------------------------------ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | Website: https://openfoam.org # \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation # \\/ M anipulation | #------------------------------------------------------------------------------ # 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 <http://www.gnu.org/licenses/>. # # Script # wclean # # Usage # wclean [OPTION] [dir] # wclean [OPTION] target [dir [MakeDir]] # # Description # Clean up the wmake control directory Make/\$WM_OPTIONS and remove the # lnInclude directories generated for libraries. # #------------------------------------------------------------------------------ Script=${0##*/} # Source the wmake functions # shellcheck source=scripts/wmakeFunctions . "${0%/*}/scripts/wmakeFunctions" error() { while [ "$#" -ge 1 ]; do echo "$1"; shift; done usage exit 1 } usage() { cat<<USAGE Usage: $Script [OPTION] [dir] $Script [OPTION] target [dir [MakeDir]] options: -silent | -s Ignored - for compatibility with wmake -help Print the usage Clean up the wmake control directory Make/\$WM_OPTIONS and remove the lnInclude directories generated for libraries. The targets correspond to a subset of the 'wmake' special targets: all All subdirectories, uses any Allwclean or Allclean files if they exist exe | lib | libo | libso Clean Make, any *.dep files and lnInclude directories empty Remove empty sub-directories for the requested dir. If executed in the main project directory, it will also remove deprecated object directories and respective binaries that refer to no-longer-existing source code. USAGE } #------------------------------------------------------------------------------ # Parse arguments and options #------------------------------------------------------------------------------ while [ "$#" -gt 0 ] do case "$1" in -h | -help) usage && exit 0 ;; -s | -silent) # Ignored - for compatibility with wmake shift ;; -*) error "unknown option: '$*'" ;; *) break ;; esac done #------------------------------------------------------------------------------ # Check arguments and change to the directory in which to run wclean #------------------------------------------------------------------------------ unset dir targetType MakeDir=Make if [ $# -ge 1 ] then if [ -d "$1" ] then dir=$1 else targetType=$1 fi # Specified directory name: [ $# -ge 2 ] && dir=$2 # Specified alternative name for the Make sub-directory: [ $# -ge 3 ] && MakeDir=$3 if [ "$dir" ] then cd "$dir" 2>/dev/null || { echo "$Script error: could not change to directory '$dir'" 1>&2 exit 1 } fi # Print command [ -z "$targetType" ] || targetSpace=" " echo "$Script $targetType$targetSpace${dir:-.}" fi #------------------------------------------------------------------------------ # If target not specified search up the directory tree for the Make # sub-directory, check the existence of the 'files' file and clean there if # present # ------------------------------------------------------------------------------ [ -n "$targetType" ] || cdSource #------------------------------------------------------------------------------ # Remove empty sub-directories and exit #------------------------------------------------------------------------------ if [ "$targetType" = empty ] then # First pass: clean up empty source code directories echo "Removing empty directories..." # Get sub-directories avoiding particular directories # shellcheck disable=SC2044 for dir in $(find . -mindepth 1 -maxdepth 1 \ -type d \( -name .git -prune -o -print \) ) do echo " searching: $dir" find "$dir" -depth -type d -empty -exec rmdir {} \; -print done # Second pass: clean up object directories with WM_PROJECT_DIR that don't # have respective source code folders, along with the respective binaries expandPath "$PWD" if [ "$exPath" = "$WM_PROJECT_DIR" ] then findObjectDir "$PWD" if [ -d "$objectsDir" ] then echo " Removing redundant object directories in $objectsDir" find "$objectsDir" -name 'variables' -print | \ while read -r variablesFile do # Hack'ish way of getting the original source code path depFile=$(dirname "$variablesFile") depToSource "$depFile" # Check if the original source code directory exists if [ ! -r "$sourceFile" ] then # Delete the respective binary first binaryFile=$(grep -e '^ *\(EXE\|LIB\) *= *' "$variablesFile") # Catch all file extension (o,a,so,?+) for libraries if echo "$binaryFile" | grep -qe '^ *LIB *= *' then binaryFile="${binaryFile}.*" fi # Isolate path and translate environment variables binaryFile=$(echo "$binaryFile" | \ sed -e 's/^ *\(EXE\|LIB\) *= *//' \ -e 's/(/{/g' -e 's/)/}/g' ) # Expand environment variables for path binaryFile=$(eval echo "$binaryFile") # Verbosely remove binary file if [ -n "$binaryFile" ] && [ -e "$binaryFile" ] then rm -vf "$binaryFile" 2>/dev/null fi # Remove the deprecated object directory rm -rvf "$depFile" 2>/dev/null fi done fi fi exit 0 fi #------------------------------------------------------------------------------ # Recurse the directories tree #------------------------------------------------------------------------------ if [ "$targetType" = all ] then if [ -e Allwclean ] # Consistent with Allwmake then ./Allwclean exit $? elif [ -e Allclean ] # Often used for tutorial cases then ./Allclean exit $? else # For all the sub-directories containing a 'Make' directory # shellcheck disable=SC2044 for dir in $(find . \( -type d -a -name Make \)) do dir=${dir%/Make} # Parent directory - trim /Make from the end # If Allwclean exists execute otherwise wclean if [ -e "$dir/Allwclean" ] then "$dir/Allwclean" else $0 "$dir" fi done fi fi # targetType is not needed beyond this point unset targetType #------------------------------------------------------------------------------ # Clean the 'Make' directory if present #------------------------------------------------------------------------------ if [ -d "$MakeDir" ] then objectsDir=$MakeDir/$WM_OPTIONS expandPath "$PWD" if [[ "$exPath" = *"$WM_PROJECT_DIR"* ]] then platformPath=$WM_PROJECT_DIR/platforms/${WM_OPTIONS} objectsDir=$platformPath${exPath//$WM_PROJECT_DIR/} fi rm -rf "$objectsDir" 2>/dev/null fi #------------------------------------------------------------------------------ # Remove the lnInclude directory if present #------------------------------------------------------------------------------ if [ -d lnInclude ] then rm -rf lnInclude 2>/dev/null fi #------------------------------------------------------------------------------ # Cleanup local variables and functions #------------------------------------------------------------------------------ unset Script usage error MakeDir #------------------------------------------------------------------------------ |
|
@wyldckat: If I search for similar lines in the wmake folder, I find another file (wrmdep): updateMode) if [ "$PWD" != "$WM_PROJECT_DIR" ] then echo "Cannot 'update', not in the project top-level directory" exit 1 fi I am not sure, what this file is for at all, but this if clause might also be a problem if $PWD includes the link and $WM_PROJECT_DIR now is set to the "real" path. Perhaps it would help if the error message contains the values of the two shell variables. And another question back to my original problem with compiling/linking against the Intel MPI libraries: It now works with this change (and setting the environment variable MPI_ARCH_PATH): diff --git a/wmake/rules/General/mplibINTELMPI64 b/wmake/rules/General/mplibINTELMPI64 index 278e0b0..9023547 100644 --- a/wmake/rules/General/mplibINTELMPI64 +++ b/wmake/rules/General/mplibINTELMPI64 @@ -1,3 +1,3 @@ PFLAGS = -DMPICH_SKIP_MPICXX -PINC = -isystem $(MPI_ARCH_PATH)/include64 -PLIBS = -L$(MPI_ARCH_PATH)/lib64 -lmpi +PINC = -isystem $(MPI_ARCH_PATH)/include -isystem $(MPI_ARCH_PATH)/include64 +PLIBS = -L$(MPI_ARCH_PATH)/lib64 -L$(MPI_ARCH_PATH)/lib -lmpi I searched for any information, if the Intel compiler accepts two -isystem arguments (it looks like it does) but I haven't found any. |
|
@jherb why do you need -isystem $(MPI_ARCH_PATH)/include and -isystem $(MPI_ARCH_PATH)/include64 what files are in these two directories? I have just installed icpc-19 to test and have the Intel MPI libraries but the header files are nowhere to be found so I can't test it or check the include directories. |
|
Note that the location of the Intel mpi.h file has changed between versions 17 and 19: https://bugs.openfoam.org/view.php?id=3043 I am not sure where it is in version 18 but it is likely that you need either -isystem $(MPI_ARCH_PATH)/include or -isystem $(MPI_ARCH_PATH)/include64 but not both and having both might cause problems if you have both a 32bit 64bit installation if that is an option. |
|
@henry: Yes, of course, you are right: Only one of the include (and one of the lib) folders is need. I just thought, that this might the fix the problem for everybody. But of course, I can always patch my installation, if you do not want to change this. |
|
@jherb I think it would be best to set the default paths to correspond to the latest release from Intel, could you confirm what those paths are? I only have the libraries and not the headers so I don't know where they will be in this release. I think PINC = -isystem $(MPI_ARCH_PATH)/include PLIBS = -L$(MPI_ARCH_PATH)/lib -lmpi should work for 17, 18 and 19 |
|
Intel MPI including the SDK is free for some time now: https://software.intel.com/en-us/mpi-library/choose-download https://software.intel.com/en-us/mpi-library/choose-download/linux I just installed them: The folders are named ~/intel/compilers_and_libraries/linux/mpi/intel64$ ls bin etc include lib libfabric modulefiles |
|
@jherb: Many thanks for picking up on the change needed for 'wrmdep'. This script is used for removing the dependency files '.dep', which in turn provide a list of files on which each '.C' file depends on, so that 'make' can more easily figure out if a '.C' file needs to be rebuilt after something is changed in those dependencies. The relevant section that uses '$PWD' is for cleaning up '.dep' files and symbolic links for files that were removed, usually after a 'git pull' in OpenFOAM-dev. I've tested moving the installation to another folder and compiling custom code at either locations. All tests ran just fine (running the tutorials 'incompressible/simpleFoam/pipeCyclic' and 'mesh/refineMesh/refineFieldDirs' that test two types of custom code) and OpenFOAM was pretty much portable. Although I haven't tested if ParaView would be portable enough... but I'm guessing that isn't as important either way for cluster deployments, but if it's not working then it's a topic of its own report. @henry: Please find in attachment the following files: - proposal_v6.patch - shows the changes made in the files in the tarball - proposal_v6.tar.gz - provides the modified files on OpenFOAM-dev, namely: - etc/bashrc - wmake/wclean - wmake/wrmdep I don't like having the 2 big chunks of new code in 'etc/bashrc', but the only way to clean it up requires using a local shell function, which I'll only be able to look into this Monday or Tuesday night. Having the local shell function will remove the duplicate code, but it won't reduce the line count all that much, so I'll leave it up to you on whether if it's worth to wait for the local shell function or not. proposal_v6.patch (3,670 bytes)
diff --git a/etc/bashrc b/etc/bashrc index ae19940..5f5d9d9 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -2,7 +2,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | Website: https://openfoam.org -# \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation +# \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation # \\/ M anipulation | #------------------------------------------------------------------------------ # License @@ -113,10 +113,30 @@ foamOldDirs="$WM_PROJECT_DIR $WM_THIRD_PARTY_DIR \ export WM_PROJECT_INST_DIR=$FOAM_INST_DIR export WM_PROJECT_DIR=$WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION +if [ -d "$WM_PROJECT_DIR" ] +then + WM_PROJECT_DIR_REAL=$(cd $WM_PROJECT_DIR && pwd -P) + if [ -d "$WM_PROJECT_DIR_REAL" -a -e "$WM_PROJECT_DIR_REAL/etc/bashrc" ] + then + export WM_PROJECT_DIR=$WM_PROJECT_DIR_REAL + fi + unset WM_PROJECT_DIR_REAL +fi + # Location of third-party software # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ export WM_THIRD_PARTY_DIR=$WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION +if [ -d "$WM_THIRD_PARTY_DIR" ] +then + WM_THIRD_PARTY_DIR_REAL=$(cd $WM_THIRD_PARTY_DIR && pwd -P) + if [ -d "$WM_THIRD_PARTY_DIR_REAL" -a -e "$WM_THIRD_PARTY_DIR_REAL/etc/tools" ] + then + export WM_THIRD_PARTY_DIR=$WM_THIRD_PARTY_DIR_REAL + fi + unset WM_THIRD_PARTY_DIR_REAL +fi + # Location of site-specific templates etc # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # unset is equivalent to $WM_PROJECT_INST_DIR/site diff --git a/wmake/wclean b/wmake/wclean index 8ccd637..3c3d80d 100755 --- a/wmake/wclean +++ b/wmake/wclean @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | Website: https://openfoam.org -# \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation +# \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation # \\/ M anipulation | #------------------------------------------------------------------------------ # License @@ -260,10 +260,11 @@ unset targetType if [ -d "$MakeDir" ] then objectsDir=$MakeDir/$WM_OPTIONS - if [[ "$PWD" = *"$WM_PROJECT_DIR"* ]] + expandPath "$PWD" + if [[ "$exPath" = *"$WM_PROJECT_DIR"* ]] then platformPath=$WM_PROJECT_DIR/platforms/${WM_OPTIONS} - objectsDir=$platformPath${PWD//$WM_PROJECT_DIR/} + objectsDir=$platformPath${exPath//$WM_PROJECT_DIR/} fi rm -rf "$objectsDir" 2>/dev/null fi diff --git a/wmake/wrmdep b/wmake/wrmdep index 1999b25..2cb138a 100755 --- a/wmake/wrmdep +++ b/wmake/wrmdep @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | Website: https://openfoam.org -# \\ / A nd | Copyright (C) 2015-2018 OpenFOAM Foundation +# \\ / A nd | Copyright (C) 2015-2019 OpenFOAM Foundation # \\/ M anipulation | #------------------------------------------------------------------------------ # License @@ -227,12 +227,16 @@ oldFolders) updateMode) - if [ "$PWD" != "$WM_PROJECT_DIR" ] + expandPath "$PWD" + if [ "$exPath" != "$WM_PROJECT_DIR" ] then echo "Cannot 'update', not in the project top-level directory" exit 1 fi + # Go into the real path + cd "$exPath" + echo "Removing dep files corresponding to source files that no longer exist..." fileNameList=$(find -L src applications -name '*.[CHL]' -type l) |
|
@bruno thanks for the patch, I have just applied it: commit 94642ba4d9a216c0d25ca9c65b8a0a946f0879db I agree that avoiding the code duplication by introducing a shell function does not provide sufficient benefit for the additional complexity given the poor handling of function arguments in bash. |
Date Modified | Username | Field | Change |
---|---|---|---|
2019-07-08 23:42 | jherb | New Issue | |
2019-07-15 09:59 | henry | Note Added: 0010561 | |
2019-07-15 10:01 | henry | Severity | major => minor |
2019-07-15 22:10 | jherb | Note Added: 0010565 | |
2019-07-15 22:25 | henry | Note Added: 0010566 | |
2019-07-15 22:33 | henry | Note Added: 0010567 | |
2019-07-16 09:29 | jherb | Note Added: 0010570 | |
2019-07-16 10:02 | henry | Note Added: 0010571 | |
2019-07-16 10:05 | henry | Relationship added | related to 0003301 |
2019-07-16 11:52 | paulmedwards | Note Added: 0010573 | |
2019-07-16 13:45 | jherb | Note Added: 0010574 | |
2019-07-16 14:10 | jherb | Note Added: 0010575 | |
2019-07-16 14:26 | paulmedwards | Note Added: 0010576 | |
2019-07-16 14:42 | henry | Note Added: 0010577 | |
2019-07-16 14:42 | henry | Relationship added | related to 0002490 |
2019-07-16 14:45 | henry | Note Edited: 0010577 | |
2019-07-16 14:45 | henry | Relationship added | related to 0002310 |
2019-07-16 14:54 | henry | Note Edited: 0010577 | |
2019-07-16 15:15 | wyldckat | Note Added: 0010578 | |
2019-07-16 15:22 | wyldckat | Note Added: 0010579 | |
2019-07-16 16:22 | jherb | Note Added: 0010580 | |
2019-07-16 16:36 | wyldckat | Note Added: 0010581 | |
2019-07-16 16:43 | paulmedwards | Note Added: 0010582 | |
2019-07-16 16:55 | jherb | Note Added: 0010583 | |
2019-07-16 17:42 | paulmedwards | Note Added: 0010584 | |
2019-07-16 18:11 | wyldckat | Note Added: 0010585 | |
2019-07-16 19:43 | paulmedwards | Note Added: 0010586 | |
2019-07-16 22:30 | wyldckat | Note Added: 0010587 | |
2019-07-17 00:48 | wyldckat | File Added: bashrc_proposal_v3 | |
2019-07-17 00:48 | wyldckat | File Added: proposal_v3.patch | |
2019-07-17 00:48 | wyldckat | Note Added: 0010588 | |
2019-07-17 08:55 | jherb | Note Added: 0010590 | |
2019-07-17 10:04 | jherb | Note Added: 0010591 | |
2019-07-17 10:08 | paulmedwards | Note Added: 0010592 | |
2019-07-17 10:26 | jherb | Note Added: 0010593 | |
2019-07-17 11:08 | wyldckat | Note Added: 0010594 | |
2019-07-17 11:10 | paulmedwards | Note Added: 0010595 | |
2019-07-17 11:23 | paulmedwards | Note Added: 0010596 | |
2019-07-17 12:38 | jherb | Note Added: 0010598 | |
2019-07-17 12:42 | jherb | Note Added: 0010599 | |
2019-07-17 12:43 | paulmedwards | Note Added: 0010600 | |
2019-07-17 12:49 | jherb | Note Added: 0010601 | |
2019-07-17 12:51 | paulmedwards | Note Added: 0010602 | |
2019-07-17 12:51 | wyldckat | Note Added: 0010603 | |
2019-07-17 12:52 | wyldckat | Note Added: 0010604 | |
2019-07-17 13:02 | paulmedwards | Note Added: 0010605 | |
2019-07-17 23:37 | wyldckat | File Added: bashrc_proposal_v4 | |
2019-07-17 23:37 | wyldckat | File Added: proposal_v4.patch | |
2019-07-17 23:37 | wyldckat | Note Added: 0010606 | |
2019-07-17 23:39 | wyldckat | Note Added: 0010607 | |
2019-07-18 11:49 | jherb | Note Added: 0010608 | |
2019-07-18 12:08 | wyldckat | Note Added: 0010609 | |
2019-07-18 14:47 | jherb | Note Added: 0010611 | |
2019-07-18 14:49 | jherb | Note Added: 0010612 | |
2019-07-18 23:23 | wyldckat | File Added: proposal_v5.patch | |
2019-07-18 23:23 | wyldckat | File Added: wclean_proposal_v5 | |
2019-07-18 23:23 | wyldckat | Note Added: 0010613 | |
2019-07-19 10:03 | jherb | Note Added: 0010614 | |
2019-07-19 15:50 | henry | Note Added: 0010622 | |
2019-07-19 16:00 | henry | Relationship added | related to 0003043 |
2019-07-19 16:01 | henry | Note Added: 0010623 | |
2019-07-19 20:00 | jherb | Note Added: 0010625 | |
2019-07-19 20:30 | henry | Note Added: 0010626 | |
2019-07-19 20:36 | henry | Note Edited: 0010626 | |
2019-07-19 21:57 | jherb | Note Added: 0010627 | |
2019-07-22 01:46 | wyldckat | File Added: proposal_v6.patch | |
2019-07-22 01:46 | wyldckat | File Added: proposal_v6.tar.gz | |
2019-07-22 01:46 | wyldckat | Note Added: 0010629 | |
2019-07-22 14:41 | henry | Note Added: 0010637 | |
2019-07-24 14:32 | henry | Assigned To | => henry |
2019-07-24 14:32 | henry | Status | new => resolved |
2019-07-24 14:32 | henry | Resolution | open => fixed |
2019-07-24 14:32 | henry | Fixed in Version | => dev |