CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Bugs (http://www.cfd-online.com/Forums/openfoam-bugs/)
-   -   Cleaning up PATH and LD_LIBRARY_PATH when switching between different versions of OpenFOAM (http://www.cfd-online.com/Forums/openfoam-bugs/62494-cleaning-up-path-ld_library_path-when-switching-between-different-versions-openfoam.html)

mbeaudoin March 12, 2008 05:19

Hello, This is not a bug pe
 
Hello,

This is not a bug per se, just a little suggestion for improvement.

When switching between different versions of OpenFOAM from the same active shell, let's say switching to OpenFOAM 1.4.1 from a shell previously initialized for OpenFOAM 1.3, the directories pointed by the "old" values of FOAM_USER_APPBIN and FOAM_USER_LIBBIN will not get cleaned up from the environment variables PATH and LD_LIBRARY_PATH when sourcing the "new" environment (sourcing the new $WM_PROJECT_DIR/$FOAM_DOT_DIR/bashrc or cshrc).

Here is the small modification we did to our copy of the file $WM_PROJECT_DIR/$FOAM_DOT_DIR/bashrc in order to correct this. The new instructions are in blue.

<hr width=75% size=2>

#- Clean path/PATH. Remove anything under top-level foam directory.
cleanPath=`$cleanProg "$PATH" "$WM_PROJECT_INST_DIR"`
if [ $? -eq 0 ]; then
PATH="$cleanPath"
fi

#- Clean LD_LIBRARY_PATH
export LD_LIBRARY_PATH=`$cleanProg "$LD_LIBRARY_PATH" "$WM_PROJECT_INST_DIR"`

#- Clean MANPATH
export MANPATH=`$cleanProg "$MANPATH" "$WM_PROJECT_INST_DIR"`


#- Clean everything that looks a bit too much like an old $FOAM_USER_APPBIN from PATH
cleanPath=`$cleanProg "$PATH" "$HOME/$WM_PROJECT/$LOGNAME"`
if [ $? -eq 0 ]; then
PATH="$cleanPath"
fi

#- Clean everything that looks a bit too much like an old $FOAM_USER_LIBBIN from LD_LIBRARY_PATH
export LD_LIBRARY_PATH=`$cleanProg "$LD_LIBRARY_PATH" "$HOME/$WM_PROJECT/$LOGNAME"`


# FOAM: set-up FOAM release-specific environment
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SOURCE(){
foamDotFile=$1
. $1
foamDotFile=
}
SOURCE $WM_PROJECT_DIR/.bashrc


<hr width=75% size=2>
A similar modification could be applied to the file $WM_PROJECT_DIR/$FOAM_DOT_DIR/cshrc as well.

Martin

henry March 12, 2008 05:29

Good suggestion, I will put it
 
Good suggestion, I will put it in and also the equivalent in cshrc.

Thanks

Henry


All times are GMT -4. The time now is 17:48.