#!/bin/ksh
set -e
# bind two records into one
# ryj: this is a kludge to fix the bugs in the daily diagnostics
# ryj: snw should be binded every 8 records (output frequency in 3hr)
# ryj: but I binded them every 4 records like other dynamics variables 
# ryj: here I bind again every 2 records to get daily values

if [ $# -ne 3 ] ; then
  echo "Error in $0: invalid number of arguments $#"
  exit 1
fi

pfx=$1
inp=$2
out=$3

release inp
access  inp ${pfx}_${inp}

if [[ $(ggstat inp|grep GRID |wc -l ) -gt 365 ]]; then
  echo "C* BINSML     2"|ccc binsml inp ${pfx}_${out}
else
  echo "C* BINSML     1"|ccc binsml inp ${pfx}_${out}
fi

release inp
