#!/bin/sh
if test ! -s karplus.f
  then
cp /usr/local/chorg/ugteach/karplus.f karplus.f
  fi
if test ! -s  .cvDebug
  then
cp /usr/local/chorg/bin/.cvDebug .cvDebug
  fi
if test -x $1.uxe
then
       echo You have previously compiled $1.f
       echo Do you want to run the program now?
       echo Type yes or y to run, n or N to recompile $1.f
       read ans
       if test "$ans" = ""
       then
                ans=y
       fi
       if test $ans = y -o $ans = yes -o $ans = Y -o $ans = YES
        then
                ./$1.uxe
                exit 0
        fi
fi
if test ! -s $1.f
  then
  echo No such file - $1.f
  exit 1
  fi
f77 -static -share_all -g -C -c -col120 -listing $1.f
if test $? != 0
then
        echo ERROR Compilation of $1.f failed
        echo Listing placed in $1.lis
        mv $1.L $1.lis
        exit 1
fi
echo Compilation of $1.f completed
echo Listing placed in $1.lis
mv $1.L $1.lis
cp $1.f $1.backup
cp $1.f ugf.f
f77 -static -share_all -o $1.uxe $1.o  $UGTEACH/fastf.o
if test $? != 0
then
        echo *ERROR* Link of $1.o failed
        exit 1
fi
echo Link of $1.o completed
echo Executing $1.uxe now:
echo Try running the debugger: cvd $1.uxe if numerical output incorrect. ./$1.uxe