Rewrote the calculation of the number of DOFs.

It was broken for the combination of PIMD, centroid freezing and ghost
atoms present in the system. This fixes it.
Merge branch 'n_DOF' into H2