How to compute and save online volume fluxes through a transect?

I am running a regional simulation of the Persian Gulf and need accurate
volume fluxes through the Strait of Hormuz for a salt/volume budget.

When computing the flux from average files, I integrate the velocity over
the transect using the time-averaged layer thicknesses (dz). However,
because the vertical grid is terrain-following and time-varying, the time
average of u·dz ≠ (time average of u) × (time average of dz). This
nonlinear correlation between velocity and layer thickness is neglected
when using average files, and our tests show the resulting bias is of the
same order of magnitude as the net E-P flux through the strait, which are
not negligible for a precise volume budget.

Saving history files at every time step is not feasible at higher
resolutions.

I understand that CROCO already computes this transport internally as
Huon (the u-flux across cell faces, u·dz·dy), which is the exact
quantity needed. The question is therefore not about how to compute it,
but about how to accumulate and save a time-average of Huon — or
equivalently a time-averaged section-integrated transport — as a
diagnostic output during the simulation, analogous to how average files
accumulate time-mean fields for other variables.

Any guidance on existing diagnostics, CPP keys, or implementation
approaches for saving averaged Huon (or a derived section transport)
would be very much appreciated.