#!/bin/sh
#
# make variants from bem model file
# invoked by -p option of bem
#

mfil=${1%.m}.m
if [ $# -lt 2 ]
then
   tfil=${1%.m}.t
else
   tfil=${2%.t}.t
fi

if [ ! -f $mfil ]
then
   echo "File" $mfil "not found."
   exit 1
fi
if [ ! -r $tfil ]
then
   echo "File" $tfil "not found."
   exit 1
fi 

$BEMDIR/var.pl $mfil $tfil
n=$?

if [ $n -eq 99 ]
then
   bem ${tfil%.t}.t
   exit 99	
else
   i=1
   while [ $i -le $n ]
   do
      bem ${tfil%.t}.v$i.t
      i=$[$i+1]
   done
   exit 0
fi
