
echo 'script for preprocessing datas related to groups with the help of GAP'

if !([ -d ../precalculated_groups ])
then
mkdir ../precalculated_groups
if !([ -d ../precalculated_groups ])
then
echo 'Directory ../precalculated_groups does not exist and can not be created (write permissions are missing)'
echo 'aborting...'
exit
fi
fi

echo '*******************************************************************'

echo 'give the order of the groups to be processed'
read n

automorphism='n'
echo 'calculate automorphisms groups (y/n)? [n] (may take very long)'
read ans
if [ 'a'$ans = 'ay' ]
then
automorphism='y'
fi

rm -f ../precalculated_groups/group.$n.*
rm -f ./groups/group.$n.*
echo 'calculating number of groups of order '$n
echo 'order:='$n';;' > tmp/tmp
cat tmp/tmp gap/number_of_groups.g | gap -q > tmp/tmp2
read number < tmp/tmp2
i=1
echo $number
echo $number > ../precalculated_groups/group.$n.number
echo $number > ./groups/group.$n.number

while [ $i -le $number ] ;
do
echo 'processing group of order '$n' number '$i
echo 'order:='$n';;' > tmp/datas
echo 'number:='$i';;' >> tmp/datas

if !([ -f ../precalculated_groups/group.$n.$i.cyclic_flag ])
then 
cat tmp/datas gap/cyclic_test.g | gap -q > ../precalculated_groups/group.$n.$i.cyclic_flag ;
cp ../precalculated_groups/group.$n.$i.cyclic_flag ./groups/ 
fi

if !([ -f ../precalculated_groups/group.$n.$i.abelian_flag ])
then 
cat tmp/datas gap/abelian_test.g | gap -q > ../precalculated_groups/group.$n.$i.abelian_flag ;
cp ../precalculated_groups/group.$n.$i.abelian_flag ./groups/ 
fi

if !([ -f ../precalculated_groups/group.$n.$i ])
then 
cat tmp/datas gap/Cayley_table.g | gap -q > ../precalculated_groups/group.$n.$i ;
cp ../precalculated_groups/group.$n.$i ./groups/
fi

if !([ -f  ../precalculated_groups/group.$n.$i.dispersion_filter ])
then
cat tmp/datas gap/subgroups_for_dispersion_filter.g | gap -q > ../precalculated_groups/group.$n.$i.dispersion_filter ;
fi

if !([ -f ../precalculated_groups/group.$n.$i.equipartition_filter ])
then
cat tmp/datas gap/subgroups_for_equipartition_filter.g | gap -q > ../precalculated_groups/group.$n.$i.equipartition_filter ;
fi

if [ $automorphism = 'y' ]
then
if !([ -f ../precalculated_groups/group.$n.$i.automorphisms ])
then
cat tmp/datas gap/automorphisms.g | gap -q > ../precalculated_groups/group.$n.$i.automorphisms ;
fi
fi

i=$(($i+1))
done


 
