Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADD: claw-compiler #72

Merged
merged 11 commits into from
Dec 4, 2019
10 changes: 8 additions & 2 deletions env.arolla.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ setupDefaults()
export BOOST_ROOT=/project/c14/install/kesch/boost/boost_1_67_0/
export BOOST_PATH=${BOOST_ROOT}
export BOOST_INCLUDE=${BOOST_ROOT}/include/

export YACC="bison -y"

# default options
if [ -z "${target}" ] ; then
Expand Down Expand Up @@ -142,8 +144,9 @@ setCppEnvironment()
module load cuda92/toolkit/9.2.88 craype-accel-nvidia70
module load boost/1.70.0-gmvolf-18.12-python2
module load /users/jenkins/easybuild/arolla-ln/modules/all/cmake/3.14.5
export JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-0.el7_5.x86_64"
EOF
else
else
#Use this modules in case COSMO_TESTENV is set
cat > $ENVIRONMENT_TEMPFILE <<- EOF
module unuse /apps/arolla/UES/modulefiles
Expand All @@ -156,8 +159,11 @@ else
module load slurm
# Gnu env
module load PrgEnv-gnu/19.2
module load cuda10.0/toolkit/10.0.130
export JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b10-0.el7_6.x86_64"

EOF
fi
fi

#issue with module purge
# module purge
Expand Down
1 change: 0 additions & 1 deletion env.kesch-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ setupDefaults()
export BOOST_PATH=${BOOST_ROOT}
export BOOST_INCLUDE=${BOOST_ROOT}/include/


# default options
if [ -z "${target}" ] ; then
target="gpu"
Expand Down
6 changes: 6 additions & 0 deletions env.kesch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ setupDefaults()
export BOOST_PATH=${BOOST_ROOT}
export BOOST_INCLUDE=${BOOST_ROOT}/include/

export YACC="bison -y"

# default options
if [ -z "${target}" ] ; then
Expand Down Expand Up @@ -139,6 +140,7 @@ module load gcc/5.4.0-2.26
module load cmake
module load hdf5/1.8.18-gmvolf-17.02
module load git
module load java
EOF

module purge
Expand Down Expand Up @@ -227,6 +229,7 @@ module load craype-haswell
module load CrayCCE/.17.06
module load netCDF-Fortran/4.4.4-CrayCCE-17.06
module load cmake
module load java
export GRIBAPI_COSMO_RESOURCES_VERSION=${GRIBAPI_COSMO_RESOURCES_VERSION}
EOF
else
Expand All @@ -239,6 +242,7 @@ module swap cudatoolkit/8.0.61
module load PrgEnv-CrayCCE/17.06
module load netCDF-Fortran/4.4.4-CrayCCE-17.06
module load cmake
module load java
export GRIBAPI_COSMO_RESOURCES_VERSION=${GRIBAPI_COSMO_RESOURCES_VERSION}
EOF
fi
Expand All @@ -255,6 +259,7 @@ module load craype-network-infiniband
module load PrgEnv-gnu/17.02
module load netcdf-fortran/4.4.4-gmvolf-17.02
module load cmake
module load java
export GRIBAPI_COSMO_RESOURCES_VERSION=${GRIBAPI_COSMO_RESOURCES_VERSION}
EOF
module purge
Expand All @@ -270,6 +275,7 @@ module load craype-network-infiniband
module load PrgEnv-pgi/18.5
module load netcdf-fortran/4.4.4-pgi-18.5-gcc-5.4.0-2.26
module load cmake
module load java
export GRIBAPI_COSMO_RESOURCES_VERSION=${GRIBAPI_COSMO_RESOURCES_VERSION}
EOF
module purge
Expand Down
165 changes: 165 additions & 0 deletions package_builder/build_claw.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
#!/usr/bin/env bash

# set default variables

test -n "${REBUILD}" || REBUILD=YES
test -n "${slave}" || exitError "Error : slave must be defined"

# hack for tsa
if [ "$slave" == "tsa" ] ; then
export COSMO_TESTENV=ON
slave=arolla
fi

exitError()
{
echo "ERROR $1: $3" 1>&2
echo "ERROR LOCATION=$0" 1>&2
echo "ERROR LINE=$2" 1>&2
exit $1
}

TEMP=$@
eval set -- "$TEMP --"
fwd_args=""
compiler_target="all"
while true; do
case "$1" in
--dir|-d) package_basedir=$2; shift 2;;
--idir|-i) install_dir=$2; shift 2;;
--local) install_local="yes"; shift;;
--compiler|-c) compiler_target=$2; shift 2;;
-- ) shift; break ;;
* ) fwd_args="$fwd_args $1"; shift ;;
esac
done

if [[ -z ${package_basedir} ]]; then
exitError 3221 ${LINENO} "package basedir has to be specified"
fi
if [[ -z ${install_dir} ]]; then
exitError 3225 ${LINENO} "package install dir has to be specified"
fi

# Setup
echo $@
base_path=$PWD
setupDefaults

if [[ ${install_local} == "yes" ]]; then
install_path_prefix_="${base_path}/install"
else
install_path_prefix_="${install_dir}/claw"
fi

build_compiler_target()
{

export compiler=$1
local install_path=$2
echo "Compiling and installing for $compiler (install path: $install_path)"

install_args="-i ${install_path}/"

if [ ! -d ${install_path} ] ; then
mkdir -p ${install_path}
fi

setFortranEnvironment

if [ $? -ne 0 ]; then
exitError 3331 ${LINENO} "Invalid fortran environment"
fi

writeModuleList ${base_path}/modules.log loaded "FORTRAN MODULES" ${base_path}/modules_fortran.env

echo "Building for ${compiler} compiler"

# Build claw-compiler dependency apache-ant
echo "=============================="
echo "Build claw-compiler dependency: apache-ant"
if [ ! -d ${package_basedir}/hpc-scripts ] ; then
git clone [email protected]:clementval/hpc-scripts.git ${package_basedir}/hpc-scripts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we probably should copy this under meteowiss, I ll add a todo (no change needed for this PR)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see #73

fi
cd ${package_basedir}/hpc-scripts/cscs
if [[ ! -f ../../ant/apache-ant-1.10.2/bin/ant || $REBUILD == YES ]] ; then
if [ $REBUILD == YES ] ; then
echo `pwd`
echo "Rebuilding apache-ant"
echo "rm -rf ../../ant"
rm -rf ../../ant
fi
./install.ant -i ../../ant || error_exit "Error : apach-ant build failed"
fi
cd ../../ant/apache-ant-1.10.2
export ANT_HOME=`pwd`

cd $base_path

# Build claw-compiler
echo "=============================="
echo "Build claw-compiler"
if [ ! -d ${package_basedir}/claw-compiler ] ; then
git clone [email protected]:claw-project/claw-compiler.git ${package_basedir}/claw-compiler
fi

cd ${package_basedir}/claw-compiler

export claw_compiler_install=$install_path_prefix_

if [[ ! -f $claw_compiler_install/bin/clawfc || $REBUILD == YES ]]; then
if [ $REBUILD == YES ] ; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get the error because REBUILD is not define, so you should give it a default in the head of your script or always check for existence

echo `pwd`
echo "Rebuilding claw-compiler"
echo "rm -rf build"
rm -rf build
fi

export PATH=$ANT_HOME/bin:$PATH

# Get OMNI Compiler as submodule
git submodule init
git submodule update

if [ ! -d build ] ; then
mkdir build
fi
cd build

if [[ "${slave}" == "kesch" ]] || [[ "${slave}" == "arolla" ]] ; then
cmake -DCMAKE_INSTALL_PREFIX="$claw_compiler_install" ..
elif [[ "${slave}" == "daint" ]] || [[ "${slave}" == "tave" ]]; then
cmake -DCMAKE_INSTALL_PREFIX="$claw_compiler_install" -DOMNI_MPI_CC="MPI_CC=cc" -DOMNI_MPI_FC="MPI_FC=ftn" ..
fi

# Compile and run unit tests
# make all transformation test && make install
make
make install

#remove build directories
cd $base_path
rm -rf ant/ claw-compiler/ hpc-scripts/
fi

if [ $? -ne 0 ]; then
exitError 3333 "Unable to compile claw with ${compiler}"
fi

# Copy module files
cp modules_fortran.env ${install_path}/modules.env
unsetFortranEnvironment

}

# Build
if [ "${compiler_target}" != "all" ]; then
if [ "${install_local}" != "yes" ] ; then
install_path_prefix_="${install_path_prefix_}/${compiler_target}"
fi
build_compiler_target "${compiler_target}" "${install_path_prefix_}"
else
for c_ in ${compilers[@]}; do
build_compiler_target "${c_}" "${install_path_prefix_}/$c_/"
done
fi