Merge branch 'master' of ssh://opencfd@repo.or.cz/srv/git/OpenFOAM-1.5.x
[OpenFOAM-1.5.x.git] / bin / tools / RunFunctions
blob49a61a0085dcfa9ffd22cb3327b518d15b408c9e
1 #---------------------------------*- sh -*-------------------------------------
2 # =========                 |
3 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4 #  \\    /   O peration     |
5 #   \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6 #    \\/     M anipulation  |
7 #------------------------------------------------------------------------------
8 # License
9 #     This file is part of OpenFOAM.
11 #     OpenFOAM is free software; you can redistribute it and/or modify it
12 #     under the terms of the GNU General Public License as published by the
13 #     Free Software Foundation; either version 2 of the License, or (at your
14 #     option) any later version.
16 #     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 #     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 #     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19 #     for more details.
21 #     You should have received a copy of the GNU General Public License
22 #     along with OpenFOAM; if not, write to the Free Software Foundation,
23 #     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 # Script
26 #     RunFunctions
28 # Description
30 #------------------------------------------------------------------------------
32 runApplication ()
34     APP_RUN=$1; shift
36     if [ -f log.$APP_RUN ] ; then
37         echo "$APP_RUN already run on $PWD: remove log file to run"
38     else
39         echo "Running $APP_RUN on $PWD"
40         $APP_RUN $* > log.$APP_RUN 2>&1
41     fi
44 runParallel ()
46     APP_RUN=$1; shift
48     if [ -f $log.$APP_RUN ] ; then
49         echo "$APP_RUN already run on $PWD: remove log file to run"
50     else
51         if [ "$WM_MPLIB" = LAM ]
52         then
53             echo "Starting LAM using $2 machines file"
54             lamboot -v $2
55         fi
56         echo "Running $APP_RUN in parallel on $PWD using $1 processes"
57         ( mpirun -np $1 $APP_RUN -parallel < /dev/null > log.$APP_RUN 2>&1 )
58         if [ "$WM_MPLIB" = LAM ]
59         then
60             echo "Stopping LAM"
61             lamclean
62         fi
63     fi
66 compileApplication ()
68     echo "Compiling $1 application"
69     wmake $1
72 cloneCase ()
74     if [ -d $2 ] ; then
75         echo "Case already cloned: remove case directory $2 to clone"
76     else
77         echo "Cloning $2 case from $1"
78         mkdir $2
79         cpfiles="0 system constant"
80         for f in $cpfiles
81         do
82             cp -r $1/$f $2
83         done
84     fi
87 #------------------------------------------------------------------------------