
rm -f SMB.dat dSMB.dat

for YYYY in `seq 1981 2010` ; do
ferret <<EOF
use MARv3.12-yearly-ERA5-$YYYY.nc
set mem/size=10000
list/nohead/format=(f50.1)/file=SMB.dat/append smb
list/nohead/format=(f50.1)/file=dSMB.dat/append dsmb
quit
EOF
done

ferret <<EOF
use MARv3.12-yearly-ERA5-1980.nc
define axis/t=1981:2010:1 time
define grid/x=smb/y=smb/t=time gg
set mem/size=10000
file/var=smb/col=1/grid=gg SMB.dat
file/var=dsmb/col=1/grid=gg dSMB.dat
save/clob/file=smb.nc smb[d=2,l=@ave],dsmb[d=3,l=@ave]
quit
EOF
