#!/bin/bash

if [ $# != 4 ]; then
	echo "Usage: $0 g lgr lgc m" >&2
	exit 1
fi

g=$1
lgr=$2
lgc=$3
m=$4
n=$((g<<lgr))
h=$((n-m))
gdir="g${g}_lgr${lgr}_lgc${lgc}_n${n}"
mdir="m${m}_h${h}"
mkdir -p ${gdir}/${mdir}
for k in {01..40}; do
	now=`date`
	echo "${now}: $h $m $lgr $k $g $lgc 100000 10" >> run.log
	stdbuf -o 0 ./target/release/cuckoo_simulation $h $m $lgr $k $g $lgc 100000 10 > ${gdir}/${mdir}/k${k}.out 2>&1 &
done
wait
