#! /bin/sh # #Bourne shell program to run absorb repeatedly, changing faceml parameters #J Hester, Oct 91 #Replaces version involving mathematica # #First set initial values if [ $# -lt 6 ] then echo 'Not enough arguments on the command line.' echo 'Usage: newabs [-g] line links field increment number compid' exit fi progrm="xtal" ARCH=`mach_type` # while [ $# -gt 6 ] #while options are present do case $1 in -g) machine="graf" shift;; #have used up option *) echo $1 'is not a valid option' esac done #initialise variables from the command line number=$5 #number of times filename=$6 #filename (without extension) count=0 #count number of increments applied echo '*****Beginning Run*******' >> "$filename.cycles" # /usr/local/XTAL/bin/${progrm}_${ARCH}.x < $filename.dat | grep 'SUM(Y)' >> $filename.cycles # #go through using unchanged file while [ "$count" -lt "$number" ] do count=`expr $count + 1` #another time through #now edit dat file using awk awk 'BEGIN {lineno = 0 } { if ($1 != "faceml") { print $0 } else { lineno++ #keep count of number of faceml lines if ((lineno >= line) && (lineno < line + links)) { split($0,parts,FS) #allocate fields of line parts[field] += incr #increment this field printf "faceml %-3d %-3d %-3d %-7.6f\n",parts[2],parts[3],parts[4],\ parts[5] printf "faceml %-3d %-3d %-3d %-7.6f\n",parts[2],parts[3],parts[4],\ parts[5] >> out #also output change to record file } else print $0 } }' line=$1 links=$2 field=$3 incr=$4 out=$filename.cycles\ $filename.dat > $filename.tmp #end of file edit; now give it to xtal.... cp $filename.tmp $filename.dat # # /usr/local/XTAL/bin/${progrm}_${ARCH}.x < $filename.dat | grep 'SUM(Y)' >> $filename.cycles # done #go back for another round rm -f *.xx? # get rid of scratch files rm -f $filename.tmp #remove temporary file exit