#!/bin/bash
#PBS -S /bin/bash

## Set Walltime here in HH:MM:SS Format
#PBS -l walltime=250:00:00

## Set the number of nodes and PROCESSORS PER NODE(ppn)
#PBS -l nodes=1:ppn=2

## Mention the Memory required by your job
## Not to exceed 2GB/processor 
#PBS -l pmem=250mb

## The queue in which you want to put the job
#PBS -q default

## Job name that is displayed on qstat
#PBS -N upr_0_298

## Output file from the PBS SCRIPT
#PBS -o cg_upr_0


cd $PBS_O_WORKDIR

echo "Current working directory is `pwd`"

echo "Node file:"
echo "---------------------"
cat $PBS_NODEFILE
echo "---------------------"
NPROC=`cat $PBS_NODEFILE|wc -l`
echo "Running on $NPROC processors."

#### Creating Node File for NAMD ####
JobID=`echo $PBS_JOBID | cut -f1 -d'.'`
nodefile=./$JobID.nodelist
echo group main > $nodefile
nodes=`cat $PBS_NODEFILE`

for node in $nodes
  do 
  echo host $node >> $nodefile
done

echo "Created Nodefile : $nodefile"

##The folder/directory where the namd executable are located
NAMDDIR=/home/panwar/sourav/NAMD_2.10_Linux-x86_64-TCP

export CONV_RSH=ssh

echo "Starting run at: `date`"
#### CHANGE the names for the NAMD input (.conf file) and the output (.log file) ###
$NAMDDIR/charmrun +p$NPROC ++nodelist $nodefile $NAMDDIR/namd2 cg_rupr.iw_run.conf > cg_rupr.iw_run.log

echo "Job finished at: `date`"

