! err72_dynamic_gather.jnl
! 9/25/2017 Ticket 2561
!  6/19, code changes for SET MEM in terms of Mbytes. But
!  here, the SET MEMORY commands are done in terms of megawords,
!  as we're thinking of grid sizes

! Combination of two transforms, and split/gather ops

cancel data/all
cancel memory
DEFINE SYMBOL saved_memory_size = ($FERRET_BYTES_MEM)

! dataset from bn_dynamic_gather.jnl
use tmp/test_dyn_mem.nc  

! w/ default amount of memory this doesn't need a split-gather
! This result is correct
list/nohead v1000[x=@ave,y=@ave,k=@sum,L=@sum]
show memory/diag

! Now use smaller memory, so it'll split/gather in the T
! direction. The answer in v7.2 was wrong.
cancel memory
set mem/siz=10
list/nohead v1000[x=@ave,y=@ave,k=@sum,L=@sum]
show memory/diag

! With an even smaller amount of memory, a different
! incorrect result was listed with v7.2.
cancel memory
set mem/siz=1
list/nohead v1000[x=@ave,y=@ave,k=@sum,L=@SUM]
sh mem/diag

! clean up
SET MEMORY/SIZE=($saved_memory_size)
