From d2a78f7e9657ea4880cded1987a5db21ae8b50f6 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@Germany>
Date: Thu, 7 May 2009 10:37:55 +0200
Subject: [PATCH] finally drop references to ~/.OpenFOAM-<ver> (use
 ~/.OpenFOAM/<ver>)

---
 bin/foamExec       | 109 ++++++++++++++++++++-------------------------
 tutorials/Allclean |   2 +-
 tutorials/Allrun   |  13 +++---
 tutorials/Alltest  |  80 +++++++++++++++++++--------------
 4 files changed, 104 insertions(+), 100 deletions(-)

diff --git a/bin/foamExec b/bin/foamExec
index 48a6d5872f0..998bbd06439 100755
--- a/bin/foamExec
+++ b/bin/foamExec
@@ -38,8 +38,8 @@
 #
 #------------------------------------------------------------------------------
 usage() {
-   while [ "$#" -ge 1 ]; do echo "$1"; shift; done
-   cat<<USAGE
+    while [ "$#" -ge 1 ]; do echo "$1"; shift; done
+    cat<<USAGE
 
 usage: ${0##*/} [OPTION] <application> ...
 
@@ -50,16 +50,17 @@ options:
 * run a particular OpenFOAM version of <application>
 
 USAGE
-   exit 1
+    exit 1
 }
 
+
 # This script should exist in <foamInstall>/OpenFOAM-<VERSION>/bin/
 # extract the <foamInstall> and <version> elements
 # using a function preserves the command args
 getDefaults() {
-   set -- $(echo $0 | sed -e 's@/OpenFOAM-\([^/]*\)/bin/[^/]*$@ \1@')
-   foamInstall=$1
-   version=$2
+    set -- $(echo $0 | sed -e 's@/OpenFOAM-\([^/]*\)/bin/[^/]*$@ \1@')
+    foamInstall=$1
+    version=$2
 }
 
 getDefaults
@@ -67,72 +68,60 @@ getDefaults
 # parse options
 while [ "$#" -gt 0 ]
 do
-   case "$1" in
-   -h | -help)
-      usage
-      ;;
-   -v)
-      shift
-      version=$1
-      shift
-      ;;
-   --)
-      shift
-      break
-      ;;
-   -*)
-      usage "invalid option '$1'"
-      ;;
-   *)
-      break
-      ;;
-   esac
+    case "$1" in
+    -h | -help)
+        usage
+        ;;
+    -v)
+        shift
+        version=$1
+        shift
+        ;;
+    --)
+        shift
+        break
+        ;;
+    -*)
+        usage "invalid option '$1'"
+        ;;
+    *)
+        break
+        ;;
+    esac
 done
 
-if [ "$#" -lt 1 ]; then
-   usage "no application specified"
+if [ "$#" -lt 1 ]
+then
+    usage "no application specified"
 fi
 
 unset foamDotFile
 
 # Check user-specific OpenFOAM bashrc file
-for subDir in \
-   $HOME/.OpenFOAM-$version \
-   $HOME/.OpenFOAM/$version \
-;
-do
-   foamDotFile="$subDir/bashrc"
-   if [ -f $foamDotFile ]; then
-      . $foamDotFile
-      foamDotFile=okay
-      break
-   fi
-done
-
-# Use the FOAM_INST_DIR variable for locating the installed version
-if [ "$foamDotFile" != okay ]
+foamDotFile="$HOME/.OpenFOAM/$version/bashrc"
+if [ -f $foamDotFile ]
 then
-   for FOAM_INST_DIR in $foamInstall $WM_PROJECT_INST_DIR
-   do
-      for subDir in \
-         OpenFOAM-$version/etc \
-         OpenFOAM-$version/.OpenFOAM-$version \
-      ;
-      do
-        foamDotFile="$FOAM_INST_DIR/$subDir/bashrc"
-        if [ -f $foamDotFile ]; then
-           . $foamDotFile
-           foamDotFile=okay
-           break 2
+    . $foamDotFile
+    foamDotFile=okay
+else
+    # Use the FOAM_INST_DIR variable for locating the installed version
+    for FOAM_INST_DIR in $foamInstall $WM_PROJECT_INST_DIR
+    do
+        foamDotFile="$FOAM_INST_DIR/OpenFOAM-$version/etc/bashrc"
+        if [ -f $foamDotFile ]
+        then
+            . $foamDotFile
+            foamDotFile=okay
+            break
         fi
-     done
-   done
+    done
 fi
 
-if [ "$foamDotFile" != okay ];
+
+if [ "$foamDotFile" != okay ]
 then
-   echo "Error : bashrc file could not be found for OpenFOAM-$version" 1>&2
-   exit 1
+    echo "Error : bashrc file could not be found for OpenFOAM-$version" 1>&2
+    exit 1
 fi
 
 # Pass on the rest of the arguments
diff --git a/tutorials/Allclean b/tutorials/Allclean
index f3d601c48d9..57f63c776cc 100755
--- a/tutorials/Allclean
+++ b/tutorials/Allclean
@@ -36,7 +36,7 @@ echo "--------"
 echo "Cleaning tutorials ..."
 echo "Removing backup files"
 find . -type f \( -name "*~" -o -name "*.bak" \) -exec rm {} \;
-find . \( -name 'core' -o -name 'core.[1-9]*' \) -exec rm {} \;
+find . \( -name core -o -name 'core.[1-9]*' \) -exec rm {} \;
 find . \( -name '*.pvs' -o -name '*.OpenFOAM' \) -exec rm {} \;
 rm logs testLoopReport > /dev/null 2>&1
 
diff --git a/tutorials/Allrun b/tutorials/Allrun
index d06a98cca05..bfc2241656e 100755
--- a/tutorials/Allrun
+++ b/tutorials/Allrun
@@ -48,15 +48,19 @@ logReport () {
     UzSS=`grep -E "Uz[:| ]*solution singularity" $1`
     completed=`grep -E "^[\t ]*[eE]nd" $1`
 
-    if [ "$fatalError" ] ; then
+    if [ "$fatalError" ]
+    then
         echo "$appAndCase: ** FOAM FATAL ERROR **"
         return
-    elif [ "$UxSS" -a "$UySS" -a "$UzSS" ] ; then
+    elif [ "$UxSS" -a "$UySS" -a "$UzSS" ]
+    then
         echo "$appAndCase: ** Solution singularity **"
         return
-    elif [ "$completed" ] ; then
+    elif [ "$completed" ]
+    then
         completionTime=`tail -10 $log | grep Execution | cut -d= -f2 | sed 's/^[ \t]*//'`
-        if [ "$completionTime" ] ; then
+        if [ "$completionTime" ]
+        then
             completionTime="in $completionTime"
         fi
         echo "$appAndCase: completed $completionTime"
@@ -90,5 +94,4 @@ done
 
 find . -name "log.*" -exec cat {} \; >> logs
 
-
 # ----------------------------------------------------------------- end-of-file
diff --git a/tutorials/Alltest b/tutorials/Alltest
index 4e0107fdcc6..69eb8b9a28a 100755
--- a/tutorials/Alltest
+++ b/tutorials/Alltest
@@ -27,25 +27,30 @@
 #     Alltest
 #
 # Description
+#     quickly tests the tutorials and writes out the scheme/solver information
 #
 #------------------------------------------------------------------------------
 
 cd ${0%/*} || exit 1    # run from this directory
 
-# FUNCTIONS
-#
-printUsage () {
-cat <<EOF
-Usage: $0
-Quickly tests the tutorials and writes out the scheme/solver information
-
-Options are:
--d         sets up a default scheme on all schemes
--h         help
-EOF
+usage() {
+    while [ "$#" -ge 1 ]; do echo "$1"; shift; done
+    cat<<USAGE
+
+usage: $0 [OPTION]
+
+options:
+  -d            sets up a default scheme on all schemes
+  -h            this usage
+
+* quickly tests the tutorials and writes out the scheme/solver information
+
+USAGE
+    exit 1
 }
 
-setDefaultFvSchemes () {
+
+setDefaultFvSchemes() {
 cat<<EOF
 gradSchemes { default Gauss linear; }
 divSchemes
@@ -72,23 +77,27 @@ snGradSchemes { default corrected; }
 fluxRequired { default yes; }
 EOF
 }
+
 #
 # VARIABLE
 #
-MAIN_CONTROL_DICT=
+unset MAIN_CONTROL_DICT
 
 for i in \
-  $HOME/.$WM_PROJECT-$WM_PROJECT_VERSION \
-  $HOME/.$WM_PROJECT/$WM_PROJECT_VERSION \
-  $HOME/.$WM_PROJECT \
-  $WM_PROJECT_DIR/etc \
-  ;
+    $HOME/.$WM_PROJECT/$WM_PROJECT_VERSION \
+    $HOME/.$WM_PROJECT \
+    $WM_PROJECT_DIR/etc \
+    ;
 do
-  if [ -f "$i/controlDict" ]; then
-     MAIN_CONTROL_DICT="$i/controlDict"
-     break
-  fi
+    if [ -f "$i/controlDict" ]
+    then
+        MAIN_CONTROL_DICT="$i/controlDict"
+        break
+    fi
 done
+
+[ -f "$MAIN_CONTROL_DICT" ] || usage "main controlDict not found"
+
 TUTORIALS_DIR=.
 TEST_RUN_DIR=../tutorialsTest
 FV_SCHEMES=\
@@ -110,16 +119,16 @@ DEFAULT_SCHEMES=0
 # OPTIONS
 #
 OPTS=`getopt hd $*`
-if [ $? -ne 0 ] ; then
-    echo "Aborting due to invalid option"
-    printUsage
-    exit 1
+if [ $? -ne 0 ]
+then
+    usage "Aborting due to invalid option"
 fi
 eval set -- "$OPTS"
-while [ $1 != -- ]; do
+while [ $1 != -- ]
+do
     case $1 in
         -d) DEFAULT_SCHEMES=1;;
-        -h) printUsage; exit 1;;
+        -h) usage;;
     esac
     shift
 done
@@ -129,14 +138,15 @@ shift
 # MAIN
 #
 
-if [ -d "$TEST_RUN_DIR" ] ; then
+if [ -d "$TEST_RUN_DIR" ]
+then
     rm -rf $TEST_RUN_DIR
 fi
 
 echo "Modifying ${MAIN_CONTROL_DICT}"
 if [ -e ${MAIN_CONTROL_DICT}.org ]
 then
-    echo "File " ${MAIN_CONTROL_DICT}.org " already exists"
+    echo "File ${MAIN_CONTROL_DICT}.org already exists"
     echo "Did Alltest fail in some way and then run again?"
     exit 1
 fi
@@ -155,20 +165,21 @@ echo "Copying the tutorials"
 cp -a ${TUTORIALS_DIR} ${TEST_RUN_DIR}
 
 echo "Modifying the controlDicts to run only one time step"
-cd ${TEST_RUN_DIR}
+cd ${TEST_RUN_DIR} || exit 1
 
 for CD in `find . -name "controlDict*"`
 do
     mv ${CD} ${CD}.org
     sed \
-   -e s/"\(startFrom[ \t]*\)\([a-zA-Z]*\);"/"\1 latestTime;"/g \
+    -e s/"\(startFrom[ \t]*\)\([a-zA-Z]*\);"/"\1 latestTime;"/g \
     -e s/"\(stopAt[ \t]*\)\([a-zA-Z]*\);"/"\1 nextWrite;"/g \
     -e s/"\(writeControl[ \t]*\)\([a-zA-Z]*\);"/"\1 timeStep;"/g \
     -e s/"\(writeInterval[ \t]*\)\([0-9a-zA-Z.-]*\);"/"\1 1;"/g \
     ${CD}.org > ${CD}
 done
 
-if [ $DEFAULT_SCHEMES = 1 ] ; then
+if [ $DEFAULT_SCHEMES = 1 ]
+then
     echo "Modifying the fvSchemes to contain only default schemes"
     for FV_SC in `find . -name fvSchemes`
     do
@@ -205,7 +216,8 @@ do
             done
         echo `grep solver ${LOG} | cut -d" " -f4` >> $SOLVERS_TEMP
         done
-        if [ -f $SCHEMES_TEMP ] ; then
+        if [ -f $SCHEMES_TEMP ]
+        then
             cat $SCHEMES_TEMP | sort -u >> $SCHEMES_FILE
         fi
     done
-- 
GitLab