#!/bin/bash

HOST=$(hostname -s 2> /dev/null)

if [ "" != "${HOST}" ] && [ "" != "${CONFIG}" ] && [ -e ${BUILDKITE_BUILD_CHECKOUT_PATH}/.env/${HOST}_${CONFIG}.env ]; then
  source ${BUILDKITE_BUILD_CHECKOUT_PATH}/.env/${HOST}_${CONFIG}.env
fi

if [ "" = "${SRUN}" ]; then
  export SRUN=$(which srun 2> /dev/null)
fi

if [ "" != "${SRUN}" ]; then
  if [ "" = "${LAUNCH_USER}" ]; then
    export LAUNCH_USER=buildkite-slurm
  fi
  if [ "" = "${PARTITIONS}" ]; then
    export PARTITIONS="bdx"
  fi
fi

if [ "" != "${BUILDKITE_BUILD_CHECKOUT_PATH}" ]; then
  export TOOL_COMMAND=${BUILDKITE_BUILD_CHECKOUT_PATH}/scripts/tool_inspector.sh
fi

#export TOOL_REPORT_ONLY=1
export TOOL_FILTER=libxsmm

