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.

The new code is on lines 222-255.

Also use the right number of DOFs to estimate pressure in `energy/control/energy_control_inter_real.c`.

There is also some style cleanup, with no semantic changes.