#PBS -N Ahaha
#PBS -l nodes=1:ppn=2
#PBS -j oe
#PBS -l walltime=2000:00:00
cd $PBS_O_WORKDIR

echo my job id is $PBS_JOBID | tee  mvapich2.log
echo run nodes is following: | tee -a mvapich2.log
cat $PBS_NODEFILE | tee  -a mvapich2.log

echo begin time is `date` | tee -a  mvapich2.log
id=`echo $PBS_JOBID|awk -F. '{print $1}' `
NP=`cat $PBS_NODEFILE|wc -l`
qstat -f1 $PBS_JOBID | grep exec_host | awk '{print $3}' | tr '+/' '\n ' | awk 'NR==1 {node=$1; count=1; core[count]=$2; next}; $1==node {count++; core[count]=$2}; $1!=node {printf("%s:%d binding=user:",node,count); for(i=1;i<count;i++) printf("%d,",core[i]); printf("%d\n",core[count]); node=$1; count=1; core[count]=$2}; END {printf("%s:%d binding=user:",node,count); for(i=1;i<count;i++) printf("%d,",core[i]); printf("%d\n",core[count])}' >rankfile.${id}

./ptraj lag  2>&1 | tee -a mvapich2.log

echo end time is `date` | tee -a  mvapich2.log

