#!/bin/bash --login

#PBS -N qscript
#PBS -l select=1
#PBS -l walltime=00:20:00
#PBS -A ecse0102

cd $PBS_O_WORKDIR
export OMP_NUM_THREADS=1

function main() {

    # intra node
    my_stub="input_stub01"
    my_decomp="grid 4_3_2"

    for sz in "64_48_32" "96_72_48" "128_96_64" "160_120_80" "192_144_96" ; do
	run_benchmark "${my_stub}" "size ${sz}" "${my_decomp}" 
    done

    return 0
}

# Create an input file from a stub along with required system size
# and decomposition, e.g.
#
#  run_benchmark "input_stub_file01"  "size 128_96_64" "grid 4_3_2"
#
# In fact, any key value pair can be added, provided it does not
# already appear in the stub
#
# This will produce a default input file name "input"

function run_benchmark() {

    arg_input_stub="$1"
    arg_system_size="$2"
    arg_decomp="$3"

    echo  ${arg_system_size} > input
    echo ${arg_decomp} >> input
    cat ${arg_input_stub} >> input

    echo " "
    echo " "

    aprun -n 24 -N 24 ./Ludwig.exe

    return 0
}

main "$@"

