#!/bin/csh -f
#	this is a modification for writing one formula in
#       compact fortranform.  Orlando dec 89
#
#
#
#----------------------------------anopt------------------------------------
#
#                     ********  A N  O P T  *********
#
#
#                       programmed by Robert A. O'Barr                
#                            9 September 1989 
#
#                    email adress:  merino@osiris.ucsd.edu
# 
#-----------------------------------------------------------------------------
  



# math is executed in directory ctrlmath
# where init.m automatically loads codeone.m
      cd ctrlmath
      math  
      cd ..

      if ( -e .gk ) then 
                    else goto leave
      endif

      set warn = "no"

# print out readable formulas
      cat .gk > formulas

# compact the formula and
# check to make sure gk doesn't have too many
# continuation lines

      cp .gk /tmp/$$.file
#      sed -f sremove /tmp/$$.file > .gk
      set len = `wc -l .gk | colrm 9`
      echo ".gk" $len | spacer
      set len = `wc -l .gk | colrm 9`
      if($len >= 19) then
            echo "Warning: gk(i) is too long"
            set warn = "yes"
      endif


# compact the formulas and
# execute csh replace
#      replace

# exit if too many continuation lines
      if $warn == "yes" then
         echo ""
         echo "compiling error: too many continuation lines"
         echo ""
      endif


leave:
	echo " "
	echo -n "input filename for function in fortranform: "
	set fname = $<
	cp .gk $fname

#      if $warn == "yes" then
         echo ""
         exit
#      endif
end:
      rm -f /tmp/temp /tmp/$$file 
