#!/bin/bash
#===============================================================================
#
# cg_name_generator.sh - generates file names 
#
#-------------------------------------------------------------------------------
#
# Copyright (C) 2016 Hinnerk Stueben
#
# This file is part of BQCD -- Berlin Quantum ChromoDynamics program
#
# BQCD is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# BQCD is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with BQCD.  If not, see <http://www.gnu.org/licenses/>.
#
#------------------------------------------------------------------------------

set -u
#------------------------------------------------------------------------------
function Usage
{
cat << 'EOF' 1>&2
Usage: cg_name_generator.sh <name> <extension> [<args_passed>]
EOF
exit 1
}

if (($# < 2)); then Usage; fi

name=$1
extension=$2
shift 2

typeset -i simd=0

for i in $*
do
    case $i in
        simd) simd=1;;
    esac
done

block=

case $name in
    d2|d21|d102)
        for block in void block; do
        for dagger in void dagger; do
        for first in void first; do
        for mu in x y z t; do
        for rkind in 4 8; do
            if [[ $first = first ]]; then
                case $mu in
                    y|z) continue ;;
                esac
            fi
            echo $(./cg_d.sh --print-filename version=$name mu=$mu \
                   $first $dagger $block rkind=$rkind "$@")$extension
        done
        done
        done
        done
        done
        ;;

    c2|co)
        case $extension in
            .c)
                prefix=tmp-cg_
                s=s_
                ;;
             .e90|.f90|.F90)
                prefix=tmp-cg_
                if ((simd)); then
                    s=s
                else
                    s=
                fi
                ;;
        esac

        for block in '' _block; do
        for clover_type in _c1 _c2; do
        for spincol_type in _sc _sc22; do
        for precision in _r8$s _r4$s; do
            echo $prefix$name$block$clover_type$spincol_type$precision$extension
        done
        done
        done
        done
        ;;

    proj)
        prefix=tmp-cg_
        extension=.F90
        if ((simd)); then
            s=s
        else
            s=
        fi
        for spincol_type in _sc _sc22; do
        for dagger in _ _dag_; do
        for mu in y z t; do
        for fb in f b; do
        for precision in _r4$s _r8$s; do
            echo $prefix$name$dagger$mu$fb$spincol_type$precision$extension
        done
        done
        done
        done
        done
        ;;

    projection)
        prefix=tmp-cg_
        extension=.F90
        if ((simd)); then
            s=s
        else
            s=
        fi
        for spincol_type in sc sc22; do
        for dagger in _ _dag_; do
        for precision in _r4$s _r8$s; do
            echo $prefix$name$dagger$spincol_type$precision$extension
        done
        done
        done
        ;;
esac

exit
