#!/bin/sh
set -e
# 1. get annual mean from monthly mean
# 2. subtract 273.16

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

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

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

# get annual mean from monthly mean
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
$RTEXTBLS/lopgm_o4xa/binsml inp itmp input=ic.binsml

echo "                  1.   -273.16" | ccc xlin itmp ${pfx}_${out}

release inp itmp
