Added periodic boundary support and dim > 0.

dim < 0 (genbox automatically creates re2) seems to be buggy,
so this gets around it by generating a plain-text rea and
then calling reatore2