#! /bin/sh -
#SCRIPT TO RUN FULL EMPIRE PACKAGE

file=$1
work=`pwd`

# RUN X-SEC CALCULATIONS & EXFOR PROCESSING

../scripts/runE $file

# RUN EMPEND, & ENDRES (ENDF FORMATING) 

../scripts/format $file  

# RUN ENDF-6 CHECKING CODES

../scripts/verify $file

# RUN PREPROCESSING CODES IN PREPRATION FOR PLOTTING 
# PLOTC4 IS RUN IF THE LAST PRAMETER BELOW IS SET TO 2

../scripts/process $file $2
 
# RUN PLOTC4 (disabled, hit 'Plot' on GUI (or run plot) to get PLOTC4 plots)

#../scripts/plot $file 1

# REMOVE INTERMEDIATE ENDF FILES

rm $work/$file-l.endf   2>/dev/null
rm $work/$file-lin.endf 2>/dev/null
rm $work/$file-f.endf   2>/dev/null
rm $work/$file-rec.endf 2>/dev/null
rm $work/$file-e.endf   2>/dev/null
#rm $work/$file-s.endf   2>/dev/null


# REMOVE EMPTY FILES

if [ ! -s $file-omp.dir ]; then 
       rm $file-omp.dir  2>/dev/null
fi
if [ ! -s $file-lev.col ]; then 
       rm $file-lev.col  2>/dev/null
fi
if [ ! -s $file.war ]; then 
       rm $file.war  2>/dev/null
fi
if [ ! -s $file-ecis.in ]; then 
       rm $file-ecis.in  2>/dev/null
fi
if [ ! -s $file-ecis.out ]; then 
       rm $file-ecis.out  2>/dev/null
fi
if [ ! -s $file-inp.fis ]; then 
       rm $file-inp.fis  2>/dev/null
fi

exit
