...
A simpler way to code the daily means is to use the WMO software grib_api and use the grib_set command. Here is an example on how to set up a daily mean for day 3:
grib_set -s stepType=avgd,stepUnits=h,startStep=48,endStep=72,indicatorOfUnitForTimeRange=11,lengthOfTimeRange=4,indicatorOfUnitForTimeIncrement=11 in.grib out.grib
where in.grib is the input file and out.grib is the output file.
...