! err700_save_mod_att.jnl
! ticket 1480: do not write a modulo axis when saving a modulo
! axis with region longer than the modulo length.
! If it's just one grid-cell too long, write one cell less so 
! the axis can still be a valid modulo axis

! write a dataset to use, modulo attribute
define axis/x=20:377.5:2.5/units=degrees_east/modulo xlon
sh axis xlon
let var = x[gx=xlon]

save/clobber/file=a1.nc var
sp ncdump -h a1.nc
go bn_reset

! Now set a region and write data. The axis length would be 362.5
use a1
sh axis xlon
set region/x=0:360
stat x[gx=xlon] ! 145 points

! but we see that the region is just one cell too big, and 
! save it with length 360.
save/clobber/file=a.nc var

! previously the x axis had a modulo attribute and length 362.5
! The modulo=360 didnt match the length of the axis so on using the 
! file there was a note, modulo attribute ignored. Now the axis is 
! the intended length.
sp ncdump -h a.nc

go bn_reset
use a
sh axis `var,return=xaxis`

go bn_reset

! Now set a bigger region and write data. The axis length is 372.5
use a1
sh axis xlon
set region/x=0:370

! Now issues a note, not writing modulo attribute.
save/clobber/file=a.nc var

! previously the x axis still had the modulo attribute
sp ncdump -h a.nc

go bn_reset
use a
sh axis `var,return=xaxis`

! test the machinery for a file with attribute modulo=" "

use coads_climatology
sh att (`sst,return=xaxis`)
set region/x=1:361  

save/clobber/file=a.nc/y=0/l=1 sst

go bn_reset
use a
sh att (`sst,return=xaxis`)

! previously the axis, of length 362, was marked modulo.
show axis `sst,return=xaxis`


