if [ $# -eq 0 ]
then
	root="scr"
else
	root="$1"
fi

# create root.m file
cat <<EOF | grep -v "^#" >${root}.m
#rate constant		reactants -> products
#values for chymotrypsin from hammes, enzyme catalysis and regulation
#for hydrolysis of N-acetyl-L-Trp ethyl ester (Table 7-3, page 129)
1.e8	E + S -> X1
2.1e5	X1 -> E + S
35	X1 -> X2 + P1
0.84	X2 -> E + P2
EOF

# create root.p file
cat <<EOF | grep -v "^#" >${root}.p
#iopt
1
#itol	istate	jt	itask
4	1	2	1
#ml	mu	ixpr	mxstep	mxhnil	mxordn	mxords
#iwork1	iwork2	iwork5	iwork6	iwork7	iwork8	iwork9
0	0	0	500	0	0	0
#tcrit	h0	hmax	hmin
#rwork1	rwork5	rwork6	rwork7
0.	0.	0.	0.
#start_time  end_time  {time_step|0}  deflt_tolerance  [first_time  time_factor]
#0.0	0.0001	.000003	1.0e-10
#0	1.0e6	0	1.0e-10	1.e-9	1.2589253
0	1.0e6	0	1.0e-10	1.e-9	1.2589254117
#species	initial concn		absol. tolerance	relat. tolerance
E	1.e-4	1.e-10	1.e-9
S	1.e-4	1.e-10	1.e-9
X1	0	1.e-10	1.e-9
X2	0	1.e-10	1.e-9
P1	0	1.e-10	1.e-9
P2	0	1.e-10	1.e-9
EOF

#run it and graph it
react ${root} | tee ${root}.r | prep | ttygraph
