#!/bin/csh
#
# MM2.COM: This file has a number of tasks, it must perform an MM2 run:
#   1) Reading from $1.ins
#   2) Writing coordinates to $1.resn
#   3) Writing output to $1.out
# Afterwards it must delete all other files produced.
#
echo Running $2
if ($2 == "mm2hb") then
	mm2hb_exec < $1.ins > $1.out
	if (-f fort.1) rm fort.1
	mv fort.7 $1.resn
endif
if ($2 == "mm287") then 
	cp $1.ins CPD.MM2
	cp $1.par PARA.MM2
	rm -f TAPE4.MM2 TAPE9.MM2
	mm287_exec <<IIIII > /dev/null
1
1
0
IIIII
	mv TAPE9.MM2 $1.resn
	mv TAPE4.MM2 $1.out
	rm $1.par
endif
if ($2 == "mmp85") then
	if (-f $1.res) mv $1.res $1.reso
        mmp85_exec $1 > $1.out
	rm $1.fin
	mv $1.res $1.resn
        if (-f $1.reso) mv $1.reso $1.res
endif
if ($2 == "mm3") then
	ln -s $1.ins MM3INP
	ln -s $1.out MM3PUN
	ln -s $1.resn MM3GEO
	ln -s $1.par MM3PAR
	ln -s $mm3const MM3CON
        mm3_exec << END_OF_STUPID_INPUT >/dev/null
1
1
0
END_OF_STUPID_INPUT
        rm MM3INP MM3PUN MM3GEO MM3PAR MM3CON
endif
