#! /bin/sh

umask 0

PATH=/usr/bin:/bin:$PATH

quit() {
    echo "Exiting..."
    exit 1
}


R64=`cat -s .r64`

INSTALL_DIR=`cat -s .emos`

echo
echo "*******************************************************************"
echo  "If you choose default directories for grib tables or libgribex$R64.a "
echo  "you must have root permission to do that."
echo "*******************************************************************"
echo

echo "Installing ECMWF Grib tables, Local Definition Template and"
echo "Gribex library into $INSTALL_DIR ... "


trap "" 2 3

for i in `cat .list` ; do
    tar cf - $i | (cd $INSTALL_DIR; tar xf - )
done
for i in `cat .templates` ; do
    tar cf - $i | (cd $INSTALL_DIR; tar xf - )
done
cp libgribex$R64.a $INSTALL_DIR/.
echo

echo "*******************************************************************"
echo
echo "Installation complete!"
echo
echo "*******************************************************************"
echo
echo "   You can see example of decoding GRIB product and how to make"
echo "Makefile for that purpose in example directory. Invoke 'make' and"
echo "start executable version of program agrdemo.F :"
echo
echo "./agrdemo -i data/latlon.grib"
echo
echo "where is latlon.grib file with latitude/longitude grids."
echo "   You can use some other file with gaussian grids and spherical"
echo "harmonic fields. " 
echo
echo "*******************************************************************"

exit 0


