#!/bin/bash
if [ "$F77" = "" ]
then
echo "No fortran77 compiler is defined"
echo "please enter compiler's name"
read F77
else
echo "Fortran77 compiler is: "$F77
fi

NAME=make_title
FILE=$NAME.for
OBJECT=$NAME.o
EXEC=$NAME.exe
rm -f $EXEC
rm -f *.o
$F77 -c $FILE num2str.for strlen.for error.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 num2str.o strlen.o error.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
