#!/bin/sh
# 
# Script that runs a MCP grid for SiS
# FLS 06-06-22

i=1

rm -rf $1_grid.chi2

for M in 1.0e16
do
  for h in 5.0e-7 1.0e-6 1.2e-6 1.5e-6 2.0e-6 3.0e-6
  do
      echo "Grid Point $i [Mdot=$M, h=$h]"
      echo "Grid Point $i [Mdot=$M, h=$h]" > $1_junk.grid
      cat $1.grid $1_junk.grid > $1_junk2.grid
      mv $1_junk2.grid $1.grid
      rm -f $1_junk.grid
      head -27 $1.inp > $1_junk.inp
      echo "G $h $M" > $1_junk2.inp
      cat $1_junk.inp $1_junk2.inp > $1_junk3.inp
      rm $1_junk.inp $1_junk2.inp
      tail -16 $1.inp > $1_junk.inp
      cat $1_junk3.inp $1_junk.inp > $1_$i.inp
      
      rm -f $1_junk*
      ./runit $1_$i > $1_$i.conv
      cd ../prf
      cp -f $1.inp $1_$i.inp
      ./prf $1_$i ../mcp/ > $1_$i.junk
      rm $1_$i.junk
      cd ../plotit
      cp -f $1.inp $1_$i.inp
      ./plot $1_$i ../mcp/
      cat $1_grid.chi2 $1_$i.chi2 > $1_junk.dat
      mv -f $1_junk.dat $1_grid.chi2
      cd ../mcp
      i=`expr $i + 1`  
  done
done
