The problem with your
method is that you need the perpendicular component at each
gridpoint. Ryo's method will work for that:
> The basic principle is "easy": Let our "coast line"
exactly follow the outline of the gridboxes that form
Australia. In this case, the "cross-shore direction" is
either zonal or meridional exactly. Therefore, the
cumulative sum you want is the running sum of u Δx or v Δy,
depending on the orientation of the local "coastline".
But you would have to do that before unwrapping. Or, carry
along a marker for the "outward" direction of each gridface.
And surely this is a tedious calculation, very easy to make
a mistake.
Thank you for the explanation. I totally agree with you
that it's "very easy to make a mistake". I trace the
coastline and detect which direction it bends. That
information determines which direction is "outward".
It's a tedious programming. Here the property that my
fluxes exactly satisfy Gauss's theorem helped me debug my
code, because any error results in unexplained convergence
or divergence.
Having said that, next time (if there is next time), I'll
try your divergence theorem method. If we gradually expand
the box, we'll get the cumulative transport across the
boundary that extends when the box expands. Should be
easier to implement than my current one.
Best regards,
Ryo