#!/bin/bash


hostname=$(hostname)




if [[ "isc17" == ${hostname:0:5} ]]; then
    export MODULEPATH=/gsfs/jtacquaviva/software/modules:$MODULEPATH
    module purge
    module load ddn/mvapich/3.1.4
    module load root/hdf5/1.10.4
    #module load root/ior/git-20181107
    module load root/ior/git-20181123
    #module list
    export TD="/gsfs/jtacquaviva/testfiles"
    export WD="/gsfs/jtacquaviva/git/ddn-ime-evaluation/benchmark"
#    export NODES=( \
#        isc17-c02 isc17-c03 isc17-c04 isc17-c05 \
#        isc17-c06 isc17-c07 isc17-c08 isc17-c09 \
#        isc17-c12 isc17-c13 isc17-c14 isc17-c15 \
#        isc17-c18 isc17-c22 isc17-c01 )

    export NODES=( isc17-c02 isc17-c03 isc17-c04 isc17-c05 isc17-c06 isc17-c08 isc17-c09 isc17-c11 isc17-c12 isc17-c13 isc17-c14 isc17-c15 isc17-c18 isc17-c22 isc17-c23 isc17-c01 )


elif [[ "m" == ${hostname:0:1} ]]; then
    . /sw/rhel6-x64/tcl/modules-3.2.10/Modules/3.2.10/init/sh
    export MODULEPATH=$MODULEPATH:/work/ku0598/k202107/software/modules
    module purge
    module load intel/18.0.2
    module load fca/2.5.2431
    module load mxm/3.4.3082
    module load bullxmpi_mlx_mt/bullxmpi_mlx_mt-1.2.9.2
    module load k202107/hdf5/1.10.4
    module load k202107/ior/git-20181108
    #module list
    export TD="/mnt/lustre01/work/ku0598/k202107/git/ddn-ime-evaluation/benchmark/wd"
    export WD="/mnt/lustre01/work/ku0598/k202107/git/ddn-ime-evaluation/benchmark"
    export NODES=()
else
    echo "Configuration failed: Cluster $hostname is not supported. Quitting."
    exit 1
fi



# Provides a list of good hosts (that contains QDR connection)
function hosts() {
    num="$1"
    hlist=${NODES[0]}
    for POS in $(seq 1 $(($num - 1))) ; do 
        hlist="$hlist,${NODES[$POS]}"
    done
    echo $hlist
}


# Lustre cache on DDN cluster ist 32108MB. Test file has to be at least twice as large therefore: DATASIZE = 76800MB
#DATASIZE=$((4800 * 1024 * 1024 * 16))
DATASIZE=$((48000 * 1024 * 1024 * 16))

COUNT_ARR=( $(seq 1) )
TYPE_ARR=( "read" )
API_ARR=( "IME") # "MPIIO" ) #
FS_ARR=( "fuse") # "gpfs"
#NN_ARR=( 16 )
#PPN_ARR=( 8 )
NN_ARR=( 2 1 16 8 4 )
PPN_ARR=( 1 8 4 )
T_ARR=( $((10*1024*1024)) $((1*1024*1024)) $((100*1024)) $((16*1024)) )

#COUNT_ARR=( $(seq 3) )
#TYPE_ARR=( "write" )
#API_ARR=( "POSIX")
#NN_ARR=( 1 )
#PPN_ARR=( 8 )
#T_ARR=( $((10*1024*1024)) )

export IOR="$(which ior)"
export MPIEXEC="$(which mpiexec)"

type ior >/dev/null 2>&1     || { echo >&2 "I require ior but it's not installed.  Aborting."; exit 1; }
type mpiexec >/dev/null 2>&1 || { echo >&2 "I require mpiexec but it's not installed.  Aborting."; exit 1; } 
