From 6091cdb0a5119e1b0524b67bcf2d36f039ecf50a Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@Germany>
Date: Sun, 2 Jan 2011 18:42:26 +0100
Subject: [PATCH] BUG: incorrect log-check in runParallel (RunFunctions)

STYLE: minor rewording, drop grep/sed in favour of sed only
---
 bin/tools/RunFunctions                          | 17 +++++++++--------
 tutorials/basic/laplacianFoam/flange/Allrun     |  2 +-
 tutorials/combustion/engineFoam/kivaTest/Allrun |  4 ++--
 .../sonicFoam/ras/nacaAirfoil/Allrun            |  2 +-
 4 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/bin/tools/RunFunctions b/bin/tools/RunFunctions
index d259693f360..dddb60debed 100644
--- a/bin/tools/RunFunctions
+++ b/bin/tools/RunFunctions
@@ -2,7 +2,7 @@
 # =========                 |
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
-#   \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
+#   \\  /    A nd           | Copyright (C) 2008-2010 OpenCFD Ltd.
 #    \\/     M anipulation  |
 #------------------------------------------------------------------------------
 # License
@@ -25,23 +25,23 @@
 #     RunFunctions
 #
 # Description
-#
+#     Miscellaneous functions for running tutorial cases
 #------------------------------------------------------------------------------
 
 getApplication()
 {
-    grep application system/controlDict | sed "s/application *\([a-zA-Z]*\);/\1/"
+    sed -ne 's/^ *application *\([a-zA-Z]*\) *;.*$/\1/p' system/controlDict
 }
 
 runApplication()
 {
     APP_RUN=$1
+    APP_NAME=${1##*/}
     shift
-    APP_NAME=${APP_RUN##*/}
 
     if [ -f log.$APP_NAME ]
     then
-        echo "$APP_NAME already run on $PWD: remove log file to run"
+        echo "$APP_NAME already run on $PWD: remove log file to re-run"
     else
         echo "Running $APP_RUN on $PWD"
         $APP_RUN $* > log.$APP_NAME 2>&1
@@ -51,14 +51,15 @@ runApplication()
 runParallel()
 {
     APP_RUN=$1
+    APP_NAME=${1##*/}
     shift
 
-    if [ -f $log.$APP_RUN ]
+    if [ -f log.$APP_NAME ]
     then
-        echo "$APP_RUN already run on $PWD: remove log file to run"
+        echo "$APP_NAME already run on $PWD: remove log file to re-run"
     else
         echo "Running $APP_RUN in parallel on $PWD using $1 processes"
-        ( mpirun -np $1 $APP_RUN -parallel < /dev/null > log.$APP_RUN 2>&1 )
+        ( mpirun -np $1 $APP_RUN -parallel < /dev/null > log.$APP_NAME 2>&1 )
     fi
 }
 
diff --git a/tutorials/basic/laplacianFoam/flange/Allrun b/tutorials/basic/laplacianFoam/flange/Allrun
index db939bed764..be6367359fa 100755
--- a/tutorials/basic/laplacianFoam/flange/Allrun
+++ b/tutorials/basic/laplacianFoam/flange/Allrun
@@ -11,7 +11,7 @@ runAnsysToFoam()
 {
     if [ -f log.ansysToFoam ]
     then
-        echo "ansysToFoam already run on $PWD: remove log file to run"
+        echo "ansysToFoam already run on $PWD: remove log file to re-run"
     else
         echo "ansysToFoam: converting mesh $1"
         ansysToFoam $1 -scale $2 > log.ansysToFoam 2>&1
diff --git a/tutorials/combustion/engineFoam/kivaTest/Allrun b/tutorials/combustion/engineFoam/kivaTest/Allrun
index 6c86823f996..21d4983a939 100755
--- a/tutorials/combustion/engineFoam/kivaTest/Allrun
+++ b/tutorials/combustion/engineFoam/kivaTest/Allrun
@@ -11,7 +11,7 @@ runKivaToFoam()
 {
     if [ -f log.kivaToFoam ]
     then
-        echo "kivaToFoam already run: remove log file to run"
+        echo "kivaToFoam already run: remove log file to re-run"
     else
         echo "kivaToFoam: converting kiva file"
         kivaToFoam -file $1 > log.kivaToFoam 2>&1
@@ -23,7 +23,7 @@ restartApplication()
 {
     if [ -f log-2.$1 ]
     then
-        echo "$1 already run: remove log file to run"
+        echo "$1 already run: remove log file to re-run"
     else
         echo "Running $1"
         $1 > log-2.$1 2>&1
diff --git a/tutorials/compressible/sonicFoam/ras/nacaAirfoil/Allrun b/tutorials/compressible/sonicFoam/ras/nacaAirfoil/Allrun
index 03afe0bd219..6142b9557c8 100755
--- a/tutorials/compressible/sonicFoam/ras/nacaAirfoil/Allrun
+++ b/tutorials/compressible/sonicFoam/ras/nacaAirfoil/Allrun
@@ -11,7 +11,7 @@ runStarToFoam()
 {
     if [ -f log.star3ToFoam -o -f log.starToFoam ]
     then
-        echo "star3ToFoam already run on $PWD: remove log file to run"
+        echo "star3ToFoam already run on $PWD: remove log file to re-run"
     else
         echo "star3ToFoam: converting mesh $1"
         star3ToFoam $1 > log.star3ToFoam 2>&1
-- 
GitLab