Skip to content

Commit

Permalink
added optional args for fftw_include/fftw_lib
Browse files Browse the repository at this point in the history
  • Loading branch information
anabiman committed Sep 6, 2019
1 parent af2baac commit a21ece7
Showing 1 changed file with 52 additions and 19 deletions.
71 changes: 52 additions & 19 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
# Email: andrew.gaam [at] gmail [dot] com
# Description: entry script for compiling/testing tinker.gpu
# Usage example:
# ./setup.sh --install --fftw_dir /usr/lib/x86_64-linux-gnu --tinker_dir ../../tinker/source --acc pgc++
# ./setup.sh --install --fftw_dir ../src/build-travis/fftw --tinker_dir ../src/build-travis/tinker/source
# export FFTW_DIR=/usr/lib/x86_64-linux-gnu
# export TINKER_DIR=../../tinker/source
# export ACC=pgc++
# ./setup.sh --install --fftw_dir ${FFTW_DIR} --tinker_dir ${TINKER_DIR} --acc ${ACC}

function create_build {

Expand All @@ -30,8 +32,7 @@ function install {
if [ ! -d "build" ]; then pre_install; fi

cd build
make fftw_dir=$1 libtinker_dir=$2 acc=$3 host=$4
echo "Compilation successful. Now run test cases via: make test"
make fftw_include=$1 fftw_lib=$2 libtinker_dir=$3 acc=$4 host=$5
}

function clean {
Expand All @@ -41,16 +42,12 @@ function clean {

function test {

if [ ! -d "build" ]; then install $1 $2 $3 $4; fi
if [ ! -d "build" ]; then install $1 $2 $3 $4 $5; fi

cd build
make test fftw_dir=$1 libtinker_dir=$2 acc=$3 host=$4
echo "Test cases successfully completed."
make test fftw_include=$1 fftw_lib=$2 libtinker_dir=$3 acc=$4 host=$5
}


#!/bin/bash

POSITIONAL=()
while [[ $# -gt 0 ]]
do
Expand All @@ -75,25 +72,35 @@ case $key in
;;
--tinker_dir)
TINKER_DIR="$2"
shift # past argument
shift # past value
shift
shift
;;
--fftw_dir)
FFTW_DIR="$2"
shift # past argument
shift # past value
shift
shift
;;
--fftw_include)
FFTW_INCLUDE="$2"
shift
shift
;;
--fftw_lib)
FFTW_LIB="$2"
shift
shift
;;
--acc)
ACC="$2"
shift # past argument
shift # past value
shift
shift
;;
--host)
HOST=1
;;
--default)
DEFAULT=YES
shift # past argument
shift
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
Expand All @@ -103,6 +110,8 @@ esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters

# default args
# ============
if [ -z ${HOST} ]; then
HOST=1
fi
Expand All @@ -111,17 +120,41 @@ if [ -z ${ACC} ]; then
ACC=g++
fi

if [ -z ${FFTW_DIR} ]; then
if [ -z ${FFTW_LIB} ]; then
echo "Error! fftw_lib or fftw_dir must be supplied."
exit 1
fi

if [ -z ${FFTW_INCLUDE} ]; then
echo "Error! fftw_include or fftw_dir must be supplied."
exit 1
fi
fi

if [ -z ${FFTW_INCLUDE} ]; then
FFTW_INCLUDE=${FFTW_DIR}/include
fi

if [ -z ${FFTW_LIB} ]; then
FFTW_LIB=${FFTW_DIR}/lib
fi

if [ -z ${TINKER_DIR} ]; then
TINKER_DIR=../tinker/source
fi

if [ ! -z ${BUILD} ]; then
pre_install
else
if [ ! -z ${INSTALL} ]; then
install ${FFTW_DIR} ${TINKER_DIR} ${ACC} ${HOST}
install ${FFTW_INCLUDE} ${FFTW_LIB} ${TINKER_DIR} ${ACC} ${HOST}
else
if [ ! -z ${CLEAN} ]; then
clean
else
if [ ! -z ${TEST} ]; then
test ${FFTW_DIR} ${TINKER_DIR} ${ACC} ${HOST}
test ${FFTW_INCLUDE} ${FFTW_LIB} ${TINKER_DIR} ${ACC} ${HOST}
fi
fi
fi
Expand Down

0 comments on commit a21ece7

Please sign in to comment.