#!/bin/tcsh
echo Start Job

cd  /work/bishop/$SYS/

set BINDDIR = "/home/bishop/bin/NAMD_2.7_Linux-x86_64-ibverbs"
set NAMD = "$BINDDIR/namd2"
set CHARM = "$BINDDIR/charmrun"
set nodefile = "$PBS_JOBID.nodelist"
set cpufile = "$PBS_JOBID.cpulist"

echo $nodefile

##echo group main >! $nodefile
set nodes = `cat $PBS_NODEFILE`
echo "group main"  > $nodefile
foreach node ( $nodes )
  echo "host $node" >> $nodefile
end

set np = `grep -v group $nodefile  | wc -l`
set out = $PBS_JOBID.out

uniq $nodefile >  tmp
mv tmp $cpufile
set nh = `grep -v group $cpufile  | wc -l`

date
pwd

pget -f /tempZone/home/ANSC//$SYS/$IN.coor  $IN.coor
pget -f /tempZone/home/ANSC//$SYS/$IN.vel   $IN.vel
pget -f /tempZone/home/ANSC/$SYS/$IN.xsc   $IN.xsc
pget  /tempZone/home/ANSC/$SYS/sys.parm  sys.parm
pget  /tempZone/home/ANSC/$SYS/sys.crd   sys.crd

$CHARM ++nodelist $nodefile ++p $np  $NAMD  $OUT.conf > $OUT.out

foreach EXT ( xst dcd dvd out coor vel xsc )
 pput -f ./$OUT.$EXT /tempZone/home/ANSC/$SYS/$OUT.$EXT
end


