#!/bin/bash
set -u
#set -xv

resolution=${1:?"you must provide the resolution: 1 025 or 12"}

machine=$( hostname | sed -e "s/[0-9]*//g" )

case $machine in 
    "beaufixlogin") ncore_node=40 ;;
    "curie")        ncore_node=16 ;;
    "irene")        ncore_node=48 ;;
esac

case $ncore_node in
    16)
    case ${resolution} in
	"1")  list="4*4 8*4 8*8 8*16 24*10 24*22 40*24 45*48 72*66" ;;
	"025")list="8*4 8*8 16*8 20*12 24*22 32*32 48*42 72*58 96*81 144*110 144*201" ;;
	"12") list="16*16 32*16 40*26 80*26 80*51 96*85 160*102 216*150" ;;
    esac
    ;;
    40)
    case ${resolution} in
	"1")  list="8*5 8*10 10*16 20*16 20*30 40*33 40*66 60*66 120*55" ;;
	"025")list="8*5 10*8 16*10 20*16 20*32 40*32 60*42 96*55 96*110 120*173" ;;
	"12") list="20*14 20*26 40*26 60*34 80*51 96*85 160*102 240*137" ;;
    esac
    ;;
    48)
    case ${resolution} in
	"1")  list="8*6 12*8 24*10 24*16 24*30 30*48 40*66 72*66" ;;
	"025")list="8*6 12*8 16*12 24*16 24*32 48*32 48*64 96*64 96*134 144*173 144*241" ;;
	"12") list="16*15 24*22 48*22 48*42 80*51 96*85 160*102 240*137" ;;
    esac
    ;;
esac

for ii in $list
do
    grep "( ${ii/\*/ x } ), " best_jpni_jpnj_eorca${resolution}
    echo "$ii = $ncore_node * $( echo "scale=3 ; $ii/${ncore_node}" | bc ) = $( echo $ii | bc )"
done

for cores in $list
do
    ./submit_bench $cores $ncore_node ${resolution}
done

