#!/bin/bash

sizes=( 16 64 256 1024 )
topologies=( line torus hcube )
repartitions=( 1 N )
types=( I R )
platforms=( cluster grid )
ratios=( 10.1 1.1 1.10 )

cat <<EOF
\\documentclass[a4paper]{article}

\\usepackage[T1]{fontenc}
\\usepackage[utf8]{inputenc}
\\usepackage{lmodern}
\\usepackage[margin=1.5cm]{geometry}
\\usepackage{graphicx}
\\usepackage[francais]{babel}

%%% workaround warnings about PDF 1.5 not supported
\\pdfminorversion 5

\\newcommand{\\IG}[1]{%
  \\includegraphics[width=6cm]{#1}}

\\begin{document}

EOF

for siz in "${sizes[@]}"; do
    for top in "${topologies[@]}"; do
        for rep in "${repartitions[@]}"; do
            test $siz = "1024" -a $rep = "1" && continue
            cat <<EOF
\\begin{figure}
  \\centering
EOF
            for typ in "${types[@]}"; do
                for pla in "${platforms[@]}"; do
                    for rat in "${ratios[@]}"; do
                        cat <<EOF
  \\IG{results-$typ$rep-$rat/plat-$pla$siz/topo-$top.pdf}%
EOF
                    done
                    cat <<EOF

EOF
                done
            done
            case $rep in
                1) r="all on an only node";;
                N) r="on all nodes";;
                *) r="??? $rep ???";;
            esac
            case $top in
                hcube) t="hypercube";;
                    *) t="$top";;
            esac
            cat <<EOF
  \\caption{$siz nodes, $t topology, initially $r}
\\end{figure}
\\clearpage

EOF
        done
    done
done

cat <<EOF
\end{document}
EOF