#!/bin/bash

function check_okay {
	if [ $? -ne 0 ]
	then
		exit 1
	fi
}


function do_one {
	cp $1 inlist_ex
	check_okay
	rm -rf $2
	echo 'run' $1
	./rn1
	check_okay
  if [ ! -r $2 ]
  then
  	echo
  	echo "******************************************************************"
  	echo 'failed to create' $2 'when running' $1
  	echo "******************************************************************"
  	echo
  	exit 1
  fi
  echo
  echo 'finished' $1
  echo
	echo '***'
	echo '***'
	echo '***'
	echo '***'
	echo '***'
	echo '***'
	echo
}

do_one inlist_ex1_1 2.0_Mj_greyatm_0_Gyr.mod
do_one inlist_ex1_2 2.0_Mj_greyatm_10_Gyr.mod


echo 'finished all inlists for ex1'
