#!/bin/bash

## Just run code in recipes, use it carefully
## example: use cdo to make cache file. Since cdo is quicker than ncl.
#;DIAG_NORCPM; RUNTHESECODES: echo '    no codes run here.'

infile='sst_01_WAtl_ts.nc'
outputfile='sst_01_WAtl_ts_JJA.nc'
season='JJA'
test -f $infile || (echo 'ERROR, infile not present: '$infile ; exit 1)
test -z $outputfile && (echo 'ERROR, outputfile not specific '$outputfile ; exit 1) || true
test -z $season && (echo 'ERROR, season not specific: '$season ; exit 1) || true

shifttime=''
if [ "$season" == "DJF" ] ;then
    shifttime='-shifttime,-2mo'
fi
cdo  -yearmean $shifttime -selseason,$season  $infile $outputfile


