#! /bin/csh

# This is a typical Unix script for running a program such as MINOS.
# It should be called "runmps" and marked executable (via chmod +x runmps).
# Note that file names of the form fort.* may be machine-dependent.
#
# 30 May 1991: Original version written by Philip Gill for a DECstation 3100.
#              DECstation and Sun systems use names like fort.4.
# 15 Dec 1995: HP 9000 systems use names like ftn04.
# 23 Jul 2003: Executables no longer have .exe suffix.
# 12 Feb 2014: runmps created from minos551/test/run


 if ({$1}x == x) then
      echo '  Script for running minos on an MPS file in ~/mps'
      echo './runmps minos pilots       runs minos with pilots.mps, pilots.spc'
      echo './runmps minos pilots lp    runs minos with pilots.mps, lp.spc'
      exit
 endif

 set PROB = $1
 if ({$2}x != x)  then
      set PROB = $2
 endif

 set SPECS = $PROB
 if ({$3}x != x)  then
      set SPECS = $3
 endif
 echo "Defining $2 files"
 echo "Will use $SPECS.spc"

#rm	fort.4	>& /dev/null
#rm	fort.10	>& /dev/null


 \cp -fp        $SPECS.spc  fort.4

 if (! -e ~/mps/$PROB.mps) then
    echo Error: ~/mps/$PROB.mps  not found
    exit
 endif

 \cp -p   ~/mps/$PROB.mps   fort.10	
 \cp -fp        $PROB.basis fort.11  >& /dev/null
 ls -l {$PROB}*   
 if ($SPECS != $PROB) then 
    ls  -l {$SPECS}*
 endif

# Run the specified executable.
./$1

 \cp -fp fort.9  $PROB.out		
 \cp -fp fort.12 $PROB.newbasis  >& /dev/null

#rm fort.4	
#rm fort.9	>& /dev/null
#rm fort.10	
#rm fort.12	>& /dev/null
