#!/bin/csh

echo "usage: 2createOBSMODtable posicp_file prop_file dir OD-Number"
echo "dir = where you want the table to be created: should include full path" 
echo "prop_file: include full path to prop_file"

set exstat = 0

     set pos = $1
     set HCSS_PROPS = $2 
     set here = $3 
     set od = $4

if ( ! -e ${here}/PACS_DUR_OD${od}.txt ) then 
	touch ${here}/PACS_DUR_OD${od}.txt
else
	rm ${here}/PACS_DUR_OD${od}.txt
endif

set pwd = `pwd`
grep "OBS MODE" $pos > tmp
cut -c52-120 tmp > tmpobsmode

foreach file ( `cat tmpobsmode` )
java -Xmx512M -Dproperty.path="${HCSS_PROPS}" -Dhcss.cus.outputfile="${here}/msg${file}.txt" herschel.cus.gui.Cus -defdurtotal $file
cat ${here}/msg${file}.txt >> ${here}/PACS_DUR_OD${od}.txt
end

