#!/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=forcing_profile_1D
FILE=$NAME.for
OBJECT=$NAME.o
EXEC=$NAME.exe
rm -f $EXEC
rm -f *.o
$F77 -c $FILE Planck.for Planck_Int_wavnb.for spectral.for files.for add_slash_if_absent.for get_nlines.for strlen.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 Planck.o Planck_Int_wavnb.o spectral.o files.o add_slash_if_absent.o get_nlines.o strlen.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
