#!/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_composition
FILE=$NAME.for
OBJECT=$NAME.o
EXEC=$NAME.exe
rm -f $EXEC
rm -f $OBJECT
$F77 -c $FILE read_model.for strlen.for read_mixratios.for read_molparam.for write_files.for num2str.for get_nlines.for read_nu.for error.for exec.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 read_model.o strlen.o read_mixratios.o read_molparam.o write_files.o num2str.o get_nlines.o read_nu.o error.o exec.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
