From 1025c3c4d348e1a67825f962efbde2d853da5cce Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@Germany> Date: Mon, 16 Jun 2008 10:39:22 +0200 Subject: [PATCH] eliminate .OpenFOAM-VERSION references in dotFoam and other files --- bin/mpirunDebug | 23 +++++++------- src/OSspecific/Unix/Unix.C | 20 +++---------- src/OpenFOAM/include/OSspecific.H | 2 -- wmake/wmakeLockScheduler | 50 +++++++++++++++++-------------- wmake/wmakeScheduler | 13 +++----- 5 files changed, 49 insertions(+), 59 deletions(-) diff --git a/bin/mpirunDebug b/bin/mpirunDebug index b0a53cdc63e..eec15134391 100755 --- a/bin/mpirunDebug +++ b/bin/mpirunDebug @@ -80,27 +80,25 @@ $ECHO "Choose running method: 1)gdb+xterm 2)gdb 3)log 4)xterm+valgrind: \c" read method if [ "$method" -ne 1 -a "$method" -ne 2 -a "$method" -ne 3 -a "$method" -ne 4 ]; then printUsage - exit 1 + exit 1 fi $ECHO "Run all processes local or distributed? 1)local 2)remote: \c" read spawn if [ "$spawn" -ne 1 -a "$spawn" -ne 2 ]; then printUsage - exit 1 + exit 1 fi -# check ~/.OpenFOAM-VERSION -# check <site>/etc -# check <site>/.OpenFOAM-VERSION +# check ~/.$WM_PROJECT/$WM_PROJECT_VERSION/ +# check ~/.$WM_PROJECT/ +# check <installedProject>/etc/ if [ "$WM_PROJECT" ]; then - : ${FOAM_DOT_DIR:=.$WM_PROJECT-$WM_PROJECT_VERSION} - for i in \ - $HOME/$FOAM_DOT_DIR \ + $HOME/.WM_PROJECT/$WM_PROJECT_VERSION \ + $HOME/.WM_PROJECT \ $WM_PROJECT_DIR/etc \ - $WM_PROJECT_DIR/$FOAM_DOT_DIR \ ; do if [ -f "$i/bashrc" ]; then @@ -112,7 +110,12 @@ fi # Construct test string for remote execution. # Source OpenFOAM settings if OpenFOAM environment not set. -sourceFoam='[ "$WM_PROJECT" ] || . '"$sourceFoam" +# attempt to preserve the installation directory 'FOAM_INST_DIR' +if [ "$FOAM_INST_DIR" ]; then + sourceFoam='[ "$WM_PROJECT" ] || '"FOAM_INST_DIR=$FOAM_INST_DIR . $sourceFoam" +else + sourceFoam='[ "$WM_PROJECT" ] || '". $sourceFoam" +fi echo "**sourceFoam:$sourceFoam" diff --git a/src/OSspecific/Unix/Unix.C b/src/OSspecific/Unix/Unix.C index e50444a2360..b2c89395e59 100644 --- a/src/OSspecific/Unix/Unix.C +++ b/src/OSspecific/Unix/Unix.C @@ -213,25 +213,13 @@ bool Foam::chDir(const fileName& dir) Foam::fileName Foam::dotFoam(const fileName& name) { - // Search for file 'name' in: - // 1) ~/.OpenFOAM-VERSION/, ~/.OpenFOAM/VERSION/ or ~/.OpenFOAM/ - // 2) $WM_PROJECT_INST_DIR/site/VERSION or $WM_PROJECT_INST_DIR/site/ - // 3) $WM_PROJECT_DIR/etc/ - // Search user files: // ~~~~~~~~~~~~~~~~~~ - // Check for user file in ~/.OpenFOAM-VERSION/ - fileName fullName = home()/(word(".OpenFOAM-") + FOAMversion)/name; - if (exists(fullName)) - { - return fullName; - } - fileName searchDir = home()/".OpenFOAM"; if (dir(searchDir)) { // Check for user file in ~/.OpenFOAM/VERSION - fullName = searchDir/FOAMversion/name; + fileName fullName = searchDir/FOAMversion/name; if (exists(fullName)) { return fullName; @@ -252,7 +240,7 @@ Foam::fileName Foam::dotFoam(const fileName& name) if (dir(searchDir)) { // Check for site file in $WM_PROJECT_INST_DIR/site/VERSION - fullName = searchDir/"site"/FOAMversion/name; + fileName fullName = searchDir/"site"/FOAMversion/name; if (exists(fullName)) { return fullName; @@ -272,14 +260,14 @@ Foam::fileName Foam::dotFoam(const fileName& name) if (dir(searchDir)) { // Check for shipped OpenFOAM file in $WM_PROJECT_DIR/etc - fullName = searchDir/"etc"/name; + fileName fullName = searchDir/"etc"/name; if (exists(fullName)) { return fullName; } } - // Nothing found + // Not found return fileName::null; } diff --git a/src/OpenFOAM/include/OSspecific.H b/src/OpenFOAM/include/OSspecific.H index d071cf6cd07..33e474cdf3a 100644 --- a/src/OpenFOAM/include/OSspecific.H +++ b/src/OpenFOAM/include/OSspecific.H @@ -89,8 +89,6 @@ bool chDir(const fileName& dir); //- Search for @em name in the following hierarchy: // -# personal settings: -// - ~/.OpenFOAM-\<VERSION\> -// <em>(old style)</em> // - ~/.OpenFOAM/\<VERSION\>/ // <em>for version-specific files</em> // - ~/.OpenFOAM/ diff --git a/wmake/wmakeLockScheduler b/wmake/wmakeLockScheduler index b8db7492f79..8182ad4b766 100755 --- a/wmake/wmakeLockScheduler +++ b/wmake/wmakeLockScheduler @@ -37,7 +37,8 @@ # Sources the relevant cshrc/bashrc if not set. # # WM_PROJECT_DIR, WM_PROJECT and WM_PROJECT_VERSION will have been set -# before calling this routine +# before calling this routine. +# FOAM_INST_DIR may possibly have been set (to find installation) # # Usage # wmakeScheduler COMMAND @@ -45,7 +46,7 @@ # # wmakeScheduler -count # count the total number of slots available in WM_HOSTS -# eg, WM_NCOMPPROCS=$(wmakeScheduler -count) +# eg, export WM_NCOMPPROCS=$(wmakeScheduler -count) # #------------------------------------------------------------------------------- lockDir=$HOME/.wmakeScheduler @@ -81,35 +82,40 @@ case $SHELL in ;; esac -# check ~/.$WM_PROJECT-$WM_PROJECT_VERSION/ # check ~/.$WM_PROJECT/$WM_PROJECT_VERSION/ # check ~/.$WM_PROJECT/ # check <installedProject>/etc/ -# check <installedProject/.$WM_PROJECT-$WM_PROJECT_VERSION/ if [ "$WM_PROJECT" ]; then - : ${FOAM_DOT_DIR:=.$WM_PROJECT-$WM_PROJECT_VERSION} - - for i in \ - $HOME/$FOAM_DOT_DIR \ - $HOME/.$WM_PROJECT/$WM_PROJECT_VERSION \ - $HOME/.$WM_PROJECT \ - $WM_PROJECT_DIR/etc \ - $WM_PROJECT_DIR/$FOAM_DOT_DIR \ - ; - do - if [ -f "$i/$shellRc" ]; then - sourceFoam="$i/$shellRc" - break - fi - done + for i in \ + $HOME/.$WM_PROJECT/$WM_PROJECT_VERSION \ + $HOME/.$WM_PROJECT \ + $WM_PROJECT_DIR/etc \ + ; + do + if [ -f "$i/$shellRc" ]; then + sourceFoam="$i/$shellRc" + break + fi + done fi # Construct test string for remote execution. # Source WM_PROJECT settings if WM_PROJECT environment not set. +# attempt to preserve the installation directory 'FOAM_INST_DIR' case $sourceFoam in - */cshrc) sourceFoam='if ( ! $?WM_PROJECT ) source '"$sourceFoam";; - */bashrc) sourceFoam='[ "$WM_PROJECT" ] || . '"$sourceFoam";; +*/bashrc) + if [ "$FOAM_INST_DIR" ]; then + sourceFoam='[ "$WM_PROJECT" ] || '"FOAM_INST_DIR=$FOAM_INST_DIR . $sourceFoam" + else + sourceFoam='[ "$WM_PROJECT" ] || '". $sourceFoam" + fi + ;; + +*/cshrc) + # TODO: csh equivalent to bash code (preserving FOAM_INST_DIR) + sourceFoam='if ( ! $?WM_PROJECT ) source '"$sourceFoam" + ;; esac # quote double-quotes for remote command line @@ -160,7 +166,7 @@ do if lockfile -r0 "$lockFile" 2>/dev/null; then # Set colour colour=${colours[$colourIndex]} - #echo "** host=$host colourIndex=$colourIndex colour=$colour" + ## echo "** host=$host colourIndex=$colourIndex colour=$colour" if [ "$host" = "$HOST" ]; then if [ "$colour" ]; then diff --git a/wmake/wmakeScheduler b/wmake/wmakeScheduler index 1be15abd87c..14f4d904028 100755 --- a/wmake/wmakeScheduler +++ b/wmake/wmakeScheduler @@ -37,7 +37,8 @@ # Sources the relevant cshrc/bashrc if not set. # # WM_PROJECT_DIR, WM_PROJECT and WM_PROJECT_VERSION will have been set -# before calling this routine +# before calling this routine. +# FOAM_INST_DIR may possibly have been set (to find installation) # # Usage # wmakeScheduler COMMAND @@ -45,7 +46,7 @@ # # wmakeScheduler -count # count the total number of slots available in WM_HOSTS -# eg, WM_NCOMPPROCS=$(wmakeScheduler -count) +# eg, export WM_NCOMPPROCS=$(wmakeScheduler -count) # #------------------------------------------------------------------------------- lockDir=$HOME/.wmakeScheduler @@ -81,21 +82,15 @@ case $SHELL in ;; esac -# check ~/.$WM_PROJECT-$WM_PROJECT_VERSION/ # check ~/.$WM_PROJECT/$WM_PROJECT_VERSION/ # check ~/.$WM_PROJECT/ # check <installedProject>/etc/ -# check <installedProject/.$WM_PROJECT-$WM_PROJECT_VERSION/ if [ "$WM_PROJECT" ]; then - : ${FOAM_DOT_DIR:=.$WM_PROJECT-$WM_PROJECT_VERSION} - for i in \ - $HOME/$FOAM_DOT_DIR \ $HOME/.$WM_PROJECT/$WM_PROJECT_VERSION \ $HOME/.$WM_PROJECT \ $WM_PROJECT_DIR/etc \ - $WM_PROJECT_DIR/$FOAM_DOT_DIR \ ; do if [ -f "$i/$shellRc" ]; then @@ -203,7 +198,7 @@ do fi done done - # Not found any free slots. Rest a bit. + # Did not find any free slots. Rest a bit. sleep 1 done -- GitLab