[ . . . ]
let ave = VMRN2O[k=@ave, l=@ave]
repeat/I=1:144 (repeat/J=1:143 (define symbole lat=`i`; save/append/file=grid_($lat)_`j`.nc ave))
I'd like to just add that you don't have to generate different files for different latitudes; you can just add latitude "slices" to an existing file. Again, just to show the basic idea, here is pseudo code:
repeat/L=1:lmax ( \
repeat/j=1:jmax ( \
You calculate the average latitude by latitude and add the result to the file.
Another consideration is: if at all possible, x=@ave and y=@ave should be calculated at the same time, because Ferret is smart enough to special-case this to calculate the true area average over the lon-lat grid boxes.
So, my recommendation would be to calculate the x-y average (var[x=@ave,y=@ave]) for each K and each L and store the result in a temporary netCDF file; then open the file and calculate the z average for each L.
Ryo