#!/bin/ksh -e
#
# get annual mean from monthly mean gp, tp or xp file

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

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

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

if [[ $inp == @(brfr|crpf|grsf|tree|vegf) ]]; then
  echo "                100." | ccc xlin inp finp
else
  cp inp finp
fi

printf "C* BINSML    12    0    0   12                                        \n"  > ic.binsml
printf "C            31   28   31   30   31   30   31   31   30   31   30   31\n" >> ic.binsml
binsml finp ${pfx}_${out} input=ic.binsml

release inp finp

