#! /bin/sh # shell script file to extract single column of individual year data # from hydrobal.out file # # At the command prompt type # hydfilter hydrobal.out # # columns of interest in hydrobal.out are: # 4 - start day of hydrobalance period # 5 - starting soil water content (mm) # 6 - starting snow water content (mm) # 7 - end day of hydrobalance period # 8 - ending soil water content (mm) # 9 - ending snow water content (mm) # 10 - rainfall for period (mm) # 11 - runoff for period (mm) # 12 - evaporation for period (mm) # 13 - transpiration for period (mm) # 14 - drainage for period (mm) # 15 - check for period (mm) # # Since results are appended to harvest.rep, this should be # examined or moved or deleted before running this script # # create file to use dm to screen hydrobal.out file # in files with multiple operations conglomerate those without crops growing # by checking for transpiration and skipping those with it. # the x100 term limits this to 12 (8*12=96 columns)harvest events # in a harvest.out file, since the x100 is placed to give a zero result # only 8 harvest events are processed below numcol=15 chkcol=13 # check column, divide between growth and non growth periods maxoper=7 maxcolp=`expr $maxoper \* $numcol + 1 column=$2 echo if N=$numcol then x$column else x$maxcolp >screen.dm for mult in $(seq $maxoper) do totcol=`expr $mult \* $numcol` tckcol=`expr $totcol + $chkcol` # total columns to reach check column on multiple operations column=`expr $totcol + $2` echo if \(N\>$totcol\) AND \(x$tckcol=0\) then x$column else x$maxcolp >>screen.dm done # # remove text from hydrobal.out and put spaces in place of / so column count is correct hydstrip $1 temp #seldir=`echo -r $1 | sed 's/harvest_en.out//g'` #filerep=$seldir'yield.rep' # # calculate annual average yield (maximum 8 harvests maximum 2 years) #dm Escreen.dm temp0 #dm x1+x2+x3+x4+x5+x6+x7+x8+x9 temp1 # # copy temporary file into original directory #cp temp1 $filerep # # remove excess files #rm screen.dm #rm temp #rm temp0 #rm temp1