#!@SHELL@ # # Performs an adaptive simulation with molecuilder exec_prefix=@prefix@ MOLECUILDER="$exec_prefix/molecuilder" JOINER="$exec_prefix/joiner" CRUNCHER="/mount/bespin/heber/build/mpqc-2.3.0/bin/mpqc" CONVERTER="/mount/bespin/heber/tmp/mpqc/espack2mpqc.sh" PREPARER="/mount/bespin/heber/tmp/mpqc/convertresults.sh" SUFFIX="in" function check() { #1 MESSAGE if [ $? -eq 0 ]; then if [ -z $1 ]; then echo "ok." else echo "ok: $1." fi else if [ -z $1 ]; then echo "failed." else echo "failed: $1." fi exit 1 fi } if [ -z $3 ]; then echo "Usage: $0 " echo "i.e. $0 test.conf 1.55 -5" exit 1 else config=$1 DIR=`dirname $config` distance=$2 order=$3 fi returncode="0" while [ "$returncode" -eq "0" ]; do # don't go higher than 6th order # break down the molecule with molecuilder echo -n "Fragmenting molecule $DIR adaptively ... " $MOLECUILDER $config -e $exec_prefix -f $distance $order 2>/dev/null 1>/dev/null returncode=$? check $returncode if [ "$returncode" -eq "0" ]; then # find maximum number of digits digit=1 while [ ! -e "$DIR/BondFragment`printf "%0${digit}d" 0`.conf" ]; do let digit=$digit+1 done let digit=$digit+1 if [ -e "$DIR/BondFragment`printf "%0${digit}d" 0`.conf" ]; then let lesser=$digit-1 echo "Shifting found fragments with $lesser digits to those with $digit digits ..." #dirs for file in $DIR/BondFragment`i=0;while [ $i -lt $lesser ]; do let i=$i+1; echo -n "?"; done`; do mv $file ${file/Fragment/Fragment0} done #files for file in $DIR/BondFragment`i=0;while [ $i -lt $lesser ]; do let i=$i+1; echo -n "?"; done`.*; do mv $file ${file/Fragment/Fragment0} done else let digit=$digit-1 fi echo "Found $digit digits." # evaluate each fragment dir=`pwd` cd $DIR j=0; while [ -e "BondFragment`printf "%0${digit}d" $j`.conf" ]; do name="BondFragment`printf "%0${digit}d" $j`" if [ ! -e "$name.out" ]; then # if not evaluated yet echo -n "Converting $name.conf ..." sh $CONVERTER "$name.conf" check #/opt/packages/mpichgm-1.2.7..15/bin/mpirun.ch_gm -machinefile $PBS_NODEFILE -np 8 /mount/bespin/heber/workspace/espack/pcp/bin/pcp -v -a 86000 $DIR/BondFragment`printf "%0${digit}d" $j`.conf if [ -e "$name.$SUFFIX" ]; then echo -n "Evaluating $name.$SUFFIX ..." $CRUNCHER "$name.$SUFFIX" >"$name.out" check fi fi let j=$j+1 done cd $dir echo "Evaluated $j fragments." # join the resulting energies into a single file and create EnergyPerFragment file echo -n "Preparing results ..." sh $PREPARER $DIR check echo -n "Joining energies ..." $JOINER $DIR/ pcp >/dev/null check else echo "Desired accuracy of 10^$order reached." fi # returncode=1 done