1#!/bin/bash 2 3nargs=6 4 5function die() { 6echo -e "${1}" 7exit 1 8} 9 10# check that user entered proper number of args 11if [[ "${#}" -ne "$nargs" ]] 12then 13die "\n Check usage: \n $0\n <Number of cores (for procs_case)>\n <Starting time step for the average> \n Accumulate error field? <0/1>\n Accumulate phase average fields? <0/n_avg_fields> \n Copy vorticity field from the last time step? <0/1>\n Copy dwal field from the last time step? <0/1>" 14fi 15 16cores=$1 17start_ts=$2 18accu_error=$3 19accu_phavg=$4 20copy_vort=$5 21copy_dwal=$6 22 23outputfile='AcuStat_input.dat' 24 25 26ls -lrt $cores-procs_case/restart-dat.*.1 | grep -v '^lr'> tmp 27cat tmp | awk -F dat '{print $2}' | sed 's/^\.//g' | sed 's/\.1//g' | sort -n > tmp2 28rm tmp 29 30 31if [ -f tmp3 ] ; then 32 rm tmp3 33fi 34 35iline=0 36while read ts; do 37 iline=$((iline+1)) 38 if [ "$iline" -gt "1" ] ; then 39 diffts=$((ts-tsold)) 40 #echo $iline $ts $tsold $diffts 41 if [ "$ts" -ge "$start_ts" ] ; then 42 echo $ts $diffts >> tmp3 43 fi 44 fi 45 tsold=$ts 46done < tmp2 47rm tmp2 48 49nlines=`wc -l tmp3 | awk '{print $1}'` 50 51# Print first the info for the AcuStat executable 52notice='# Number of restart files to read' 53echo "$nlines $notice" > $outputfile 54notice='# Accumulate error field? (0/1)' 55echo "$accu_error $notice" >> $outputfile 56notice='# Accumulate phase_average field? (0/n phase average fields)' 57echo "$accu_phavg $notice" >> $outputfile 58notice='# copy vorticity field? (0/1)' 59echo "$copy_vort $notice" >> $outputfile 60notice='# copy dwal? (0/1)' 61echo "$copy_dwal $notice" >> $outputfile 62cat tmp3 >> $outputfile 63rm tmp3 64 65# Print now the usage of the script 66echo ' ' >> $outputfile 67echo '### What follows is a short manual and is not read by AcuStat ###' >> $outputfile 68echo "This Script is primary used to accumulate the statistics from the ybar field and write the solution from the last time step." >> $outputfile 69echo "This script can also handle additional fiels. In summary, it writes the following fields: " >> $outputfile 70echo " 1) solution of the last time step;" >> $outputfile 71echo " 2) accumulated ybar field;" >> $outputfile 72echo " 3) If requested (optional), accumulated error field;" >> $outputfile 73echo " 4) If requested (optional), accumulated phase average fields;" >> $outputfile 74echo " 5) If requested (optional), vorticity field (from the last time step);" >> $outputfile 75echo " 6) If requested (optional), dwal field (from the last time step)." >> $outputfile 76echo "The next lines contain the time steps series for restart files along with the associated number of time steps inside the ybar, error and yphavg fields." >> $outputfile 77 78mv $outputfile $cores-procs_case 79 80 81