#!/bin/bash
if [ "$F77" = "" ]
then
echo "No fortran77 compiler is defined"
echo "please enter compiler's name"
read F77
else
echo "Fotran77 compiler is: "$F77
fi
NAME=make_dk_data
FILE=$NAME.for
OBJECT=$NAME.o
EXEC=$NAME.exe
rm -f $EXEC
rm -f *.o
$F77 -c $FILE get_nlines.for exec.for strlen.for error.for num2str.for
if [ ! -f $OBJECT ] # executable does not exist
then
    echo 'There was a problem while compiling '$OBJECT
    exit 1 # Error code 1: there was a compilation error
fi

$F77 -o $EXEC $OBJECT get_nlines.o exec.o strlen.o error.o num2str.o

if [ ! -f $EXEC ] # executable does not exist
then
    echo 'There was a problem while compiling '$EXEC
    exit 1 # Error code 1: there was a compilation error
else
    echo 'Executable was successfully generated: '$EXEC
fi
exit 0
