#!/bin/csh -f
#    sort and awk must be gnusort and gnuawk
#   if the script said you should set an alias, see
#   the lines down to "-----------" below
if( $#argv != 1 && $#argv != 3) then
 echo   "Usage: fordpmjet  configfile"
 echo           "or"
 echo   "fordpmjet  configfile GLBfile INPfile"
 echo   "If GLB and INP files are not specified, dpmjet.GLB and dpmjet.inp"
 echo   "are assumed"
 exit 1
endif
if( -f /usr/local/bin/gawk ) then
	alias awk /usr/local/bin/gawk
else if ( -f /usr/local/bin/awk ) then
	alias awk /usr/local/bin/awk
else if( -f /usr/bin/awk ) then
#   should be Linux
else
	echo "set awk as an alias of gnu awk in Scrpt/fordpmjet"
	exit 1
endif
if( -f /usr/local/bin/sort ) then
	alias sort /usr/local/bin/sort
else if( -f /bin/sort ) then
#  should be Linux
else if( -f /usr/bin/sort ) then
    alias sort /usr/bin/sort
else
	echo "set sort as an alias of gnu sort in Scrpt/fordpmjet"
	exit 1
endif

# --------------------------
	 
if($#argv == 3) then
	(source $EPICSTOP/Scrpt/fordpmjetGLB $1) > $2
	echo $2 "has been created"
        ($EPICSTOP/Scrpt/fordpmjetINP $1) > $3
	echo $3 "has been created"
else
	(source $EPICSTOP/Scrpt/fordpmjetGLB $1) > dpmjet.GLB
	echo "dpmjet.GLB has been created"
	(source $EPICSTOP/Scrpt/fordpmjetINP $1) > dpmjet.inp
	echo "dpmjet.inp has been created"
endif
   







