if [ 0 = 0 ] ; then
for mask in pourc_ter pourc_oce pourc_sic pourc_lic ; do
cdo timavg -selvar,$mask /prodigfs/ipslfs/dods/fabric/lmdz/SE/ORIG/NPv5.4_SE_1982_1989_1M_histmth.nc $mask.nc
done
cdo add pourc_oce.nc pourc_sic.nc pourc_ocesic.nc
cdo remapcon,tas.nc pourc_ocesic.nc tmp.nc
fi

cat <<eod>| tmp.jnl
use tas.nc
use tmp.nc
let lat=y*(pourc_oce*0+1)
let lon=x*(pourc_oce*0+1)
reg/l=1
! shade un
!let maskcircA=if ( abs(lat+55) lt 15 and pourc_oce gt 80 ) then 1
let maskcircA=if ( abs(lat+50) le 10 and pourc_oce gt 80 ) then 1
let maskoce=if ( pourc_oce gt 80 ) then 1
let maskter=if ( pourc_oce lt 20 ) then 1
let maskNH=if ( lat gt 0 ) then 1
let maskSH=if ( lat lt 0 ) then 1
let maskNAtl=if ( lat ge 45 and lat le 60 and lon ge 310 and lon le 350 ) then 1
let maskArct=if ( lat ge 70 and pourc_oce ge 95 ) then 1
let maskSibe=if ( lat ge 40 and lon ge 50 and lon le 180 and pourc_oce le 5 ) then 1
let maskUSA=if ( lat ge 30 and lat le 55 and lon ge 250 and lon le 310 and pourc_oce le 5 ) then 1
save/clobber/file=maskcircA.nc maskcircA
save/clobber/file=maskoce.nc maskoce
save/clobber/file=maskter.nc maskter
save/clobber/file=maskNH.nc maskNH
save/clobber/file=maskSH.nc maskSH
save/clobber/file=maskNAtl.nc maskNAtl
save/clobber/file=maskArct.nc maskArct
save/clobber/file=maskSibe.nc maskSibe
save/clobber/file=maskUSA.nc maskUSA
quit
eod

ferret -script tmp.jnl
