#!/bin/sh

#####
#	copy the source model here
#####
cp ../OCEAN/ocean.mod .

MYPWD=`pwd`

for DIST in 0300 0400 0500 0600 0700 0800 0900 1000 
do

echo $DIST

rm -f *.[ZRT]EX *.[ZRT]DD *.[ZRT]SS *.[ZRT]DS

if [ ! -d ${DIST} ]
then
	mkdir $DIST
fi

#####
#	note that for synchronization it is necessary t hat the
#	defile be itentical with the DISTANT used in the
#	slat2d96 (actually the slat2d96 only needs the path proportions
#####

cat > cmdfil << EOF
200	'../OCEAN/sregn96.egn'
2000	'../SHIELD/sregn96.egn'
EOF
slat2d96 -D ${DIST} -C cmdfil

cat > cmdfil << EOF
200	'../OCEAN/slegn96.egn'
2000	'../SHIELD/slegn96.egn'
EOF
slat2d96 -D ${DIST} -C cmdfil

cat > dfile << EOF
${DIST} 1 8192  0 0
EOF

spulse96 -FUND -EQEX -V -p -l 1  -d dfile -LAT -2 > file96
cat file96 | f96tosac -B -T
mv *.[ZRT]EX *.[ZRT]DD *.[ZRT]SS *.[ZRT]DS $DIST
mv *.egn $DIST
cd $DIST
gsac << EOF
r *.[ZRT]EX *.[ZRT]DD *.[ZRT]SS *.[ZRT]DS 
rtr
int
w
q
EOF
#####
#	NOW DO MFT FOR THE Z COMPONENT, edit the MFT96CMP to handle the lategn
#####
sacmft96 -f 0${DIST}*.ZSS -PMIN 4.000000 -PMAX 100.000000 -a0 50.000000 -A -VMIN 0.100000 -VMAX 5.000000 -U cm    -R -S -A
mv MFT96CMP MFT96CMPZSS.LAT
ed MFT96CMPZSS.LAT << EOF
/sdpegn/
s/YLIN/YLIN -LAT/
w
q
EOF
sh MFT96CMPZSS.LAT 
cat MFT96.PLT SREGNU.PLT SACSPC96.PLT > ZSS.PLT

#####
#	NOW DO MFT FOR THE T COMPONENT, edit the MFT96CMP to handle the lategn
#####
sacmft96 -f 0${DIST}*.TSS -PMIN 4.000000 -PMAX 100.000000 -a0 50.000000 -A -VMIN 0.100000 -VMAX 5.000000 -U cm    -L -S -A
mv MFT96CMP MFT96CMPTSS.LAT
ed MFT96CMPTSS.LAT << EOF
/sdpegn/
s/YLIN/YLIN -LAT/
w
q
EOF
sh MFT96CMPTSS.LAT 
cat MFT96.PLT SLEGNU.PLT SACSPC96.PLT > TSS.PLT




cd ${MYPWD}


done

rm -fr file96 dfile cmdfil
