Last active
December 30, 2015 10:39
-
-
Save Rod-Persky/7817149 to your computer and use it in GitHub Desktop.
OpenFOAM Build Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -l | |
#PBS -S /bin/bash | |
####### RESOURCES SETUP ####### | |
#These commands set up the Grid Environment for your job: | |
# -N [Job Name] | |
# -l nodes=[number of cores] | |
# -l ncpus=[number of cpus required] | |
# -l mem=[amount of memory required] | |
# -l walltime=[how long the job can run for] | |
# -m ae = mail on (a)bort and (e)rror | |
# -o $PBS_O_WORKDIR/[stdout file name] | |
# -e $PBS_O_WORKDIR/[stderr output file name] | |
### Select Resouces | |
#PBS -N build_foam | |
#PBS -l nodes=1:ppn=2 | |
#PBS -l mem=2gb | |
#PBS -l walltime=02:00:00 | |
### Output File | |
#PBS -o stdout.txt | |
#PBS -e stderr.txt | |
### Queue | |
#pbs -q workq | |
### Mail Options | |
#PBS -m abe | |
#PBS -M [email protected] | |
# What version of OpenFOAM are we building? | |
FVER=2.2.2 | |
# If testing in local session, or on PBS | |
if [ -z "${PBS_O_HOME+xxx}" -o -z "${PBS_O_WORKDIR+xxx}" ]; then | |
echo "Running on a local machine (PBS variables not set)" | |
export PBS_O_HOME=$HOME | |
export PBS_O_WORKDIR=`pwd` | |
export WM_NCOMPPROCS=4 | |
else | |
export WM_NCOMPPROCS=`nproc` | |
echo "load cmake" && module load cmake | |
echo "load gcc " && module load gcc | |
echo "load mpi" && module load mpi | |
echo "Load openmpi" && module load openmpi | |
echo "load scotch" && module load scotch | |
echo "load paraview" && module load paraview | |
echo "Running on PBS" | |
fi | |
echo PBS Home = $PBS_O_HOME | |
echo PBS Work = $PBS_O_WORKDIR | |
echo Files are owned by `whoami` | |
####### START PROGRAM ####### | |
SRCDIR=$PBS_O_WORKDIR/tarbells | |
EXTRAS=$PBS_O_WORKDIR/ThirdParty-$FVER/extras | |
LOGDIR=$PBS_O_WORKDIR/logs | |
BUILDDIR=/tmp | |
mkdir -p $EXTRAS | |
mkdir -p $LOGDIR | |
function RemoveExisting() { | |
# Don't delete the folder, just delete the contents | |
# especially given these folders have chmod 777 and not | |
# the parent. | |
rm -rf OpenFOAM-$FVER/* | |
rm -rf ThirdParty-$FVER/* | |
} | |
function ExtractTarbell() { | |
# Get tarbell from folder and expand | |
cd $PBS_O_WORKDIR | |
cp $SRCDIR/OpenFOAM-$FVER.tgz . | |
cp $SRCDIR/ThirdParty-$FVER.tgz . | |
tar -xzf OpenFOAM-$FVER.tgz | |
tar -xzf ThirdParty-$FVER.tgz | |
rm OpenFOAM-$FVER.tgz | |
rm ThirdParty-$FVER.tgz | |
} | |
function SetPrefsFile() { | |
# Set preferences for compiler | |
echo " | |
foamCompiler=system | |
export WM_COMPILER=Gcc | |
export WM_MPLIB=SYSTEMOPENMPI" > $PBS_O_WORKDIR/OpenFOAM-$FVER/etc/prefs.sh | |
sed -i 's|foamInstall=$HOME/$WM_PROJECT|foamInstall='$PBS_O_WORKDIR'|g' OpenFOAM-$FVER/etc/bashrc && head -n 50 OpenFOAM-$FVER/etc/bashrc | |
echo "# OpenFOAM bashrc | |
source $PBS_O_WORKDIR/OpenFOAM-$FVER/etc/bashrc | |
export PATH=$EXTRAS/bin:\$PATH" > $PBS_O_WORKDIR/OpenFOAM-$FVER-bashrc | |
} | |
function LoadEnvironment() { | |
# Load environment variables and check | |
source $PBS_O_WORKDIR/OpenFOAM-$FVER-bashrc | |
cd $PBS_O_WORKDIR/OpenFOAM-$FVER | |
./bin/foamSystemCheck | |
echo "Sometimes BASH isn't detected, don't worry..." | |
cd $PBS_O_WORKDIR | |
} | |
function BuildOpenFOAM() { | |
# Start building OpenFOAM | |
cd $PBS_O_WORKDIR/OpenFOAM-$FVER | |
./Allwmake | tee $LOGDIR/log.OpenFOAM | |
cd $PBS_O_WORKDIR | |
} | |
function BuildQT() { | |
echo "Building QT" | |
cd $PBS_O_WORKDIR/ThirdParty-$FVER | |
cp $SRCDIR/qt-everywhere-opensource-src-4.7.3.tar.gz . | |
tar -xzf qt-everywhere-opensource-src-4.7.3.tar.gz | |
rm qt-everywhere-opensource-src-4.7.3.tar.gz | |
./makeQt | tee $LOGDIR/log.BuildQT | |
cd $PBS_O_WORKDIR | |
} | |
function BuildParaview() { | |
cd $PBS_O_WORKDIR/ThirdParty-$FVER | |
_qmake=$PBS_O_WORKDIR/ThirdParty-$FVER/build/linux64Gcc/qt-everywhere-opensource-src-4.7.3/bin/qmake | |
./makeParaView -qmake $_qmake | tee $LOGDIR/log.ParaView | |
# Paraview paraFOAM | |
echo "Building paraFOAM" | |
cd $FOAM_UTILITIES/postProcessing/graphics/PV3Readers | |
./Allwmake | tee -a $LOGDIR/log.ParaView | |
cd $PBS_O_WORKDIR | |
} | |
function BuildBison(){ | |
echo "Building BISON" | |
cd $BUILDDIR | |
cp $SRCDIR/bison-2.7.tar.gz . | |
tar -xzf bison-2.7.tar.gz && rm bison-2.7.tar.gz | |
cd bison-2.7 | |
./configure --prefix=$EXTRAS | tee $LOGDIR/log.Bison | |
make | tee -a $LOGDIR/log.Bison | |
make install | tee -a $LOGDIR/log.Bison | |
rm -rf $BUILDDIR/bison-2.7 | |
cd $PBS_O_WORKDIR | |
} | |
function BuildNANO() { | |
# Install NANO text editor | |
echo "Building NANO" | |
cd $BUILDDIR | |
cp $SRCDIR/nano-2.2.6.tar.gz . | |
tar -xzf nano-2.2.6.tar.gz && rm nano-2.2.6.tar.gz | |
cd nano.2.2.6 | |
./configure --prefix=$EXTRAS | tee $LOGDIR/log.nano | |
make | tee -a $LOGDIR/log.nano | |
make install | tee -a $LOGDIR/log.nano | |
rm -rf $BUILDDIR/nano-2.2.6 | |
cd $PBS_O_WORKDIR | |
} | |
function BuildSWAK() { | |
# Install Swiss Army Knife | |
echo "Building SWAK" | |
cp $SRCDIR/swak4Foam.zip . | |
unzip swak4Foam.zip -o && rm swak4Foam.zip | |
cd swak4Foam | |
./Allwclean | tee $LOGDIR/log.SWAK | |
./Allwmake | tee -a $LOGDIR/log.SWAK | |
cd $PBS_O_WORKDIR | |
} | |
function BuildOSIG() { | |
# Install OSIG Turbomachinery | |
echo "Building OSIG" | |
cp $SRCDIR/OSIG.zip . | |
unzip OSIG.zip -o && rm OSIG.zip | |
cd OSIG/TurboMachinery/src | |
./Allclean | tee $LOGDIR/log.OSIG | |
./Allwmake | tee -a $LOGDIR/log.OSIG | |
cd ../applications | |
./Allclean | tee -a $LOGDIR/log.OSIG | |
./Allwmake | tee -a $LOGDIR/log.OSIG | |
} | |
function checkBuildDIR() { | |
ls -al /tmp | grep `whoami` | |
# Delete things from /tmp that are older than 5 days | |
# find /tmp -gid `id -g` -uid `id -u` -type d -ctime +5 -exec rm -r {} \; 2>/dev/null | |
} | |
# Build OpenFOAM | |
#RemoveExisting # Step 1, Delete the old install of this version (if any) | |
#ExtractTarbell # Step 2, Extract the source to the correct directory | |
SetPrefsFile # Step 3, Set preferences file | |
#LoadEnvironment # Step 4, Load the environment | |
#BuildOpenFOAM # Step 5, Build OpenFOAM | |
# Build programs we will always use | |
#BuildBison # Step 6, Build BISON 2.7 | |
#BuildNANO # Step 7, Build Nano text editor | |
# Build Plugins | |
#BuildQT # Step 8, Build QT to get qmake | |
#BuildParaview # Step 9, Build Paraview to get paraFOAM | |
#BuildSWAK # Step 10, Build SWAK for extra features | |
#BuildOSIG # Step 11, Build OSIG for addSwirlandRotatio |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment