Fix averaging problem of spatialDecompose.f90

I was wrong about this
"Samples with distance larger than half boxLength should be ignored"

Those samples should not have been simply discarded.
They contribute zero to the sum but should be counted as one frame of the
total number of frames for averaging.

So I checkout spatialDecompose.f90 of the old commit 34ef83
and start this modification based on it.

I also (manually) included the patches of the latest two commits 16905 2959b
into this modification.