Miscellaneous
^^^^^^^^^^^^^
+Fix .gro file formatting with large boxes
+"""""""""""""""""""""""""""""""""""""""""
+
+The |Gromacs| manual says the box components in the .gro file
+format are separated by spaces. But no space was printed when
+a box component, except for the first, was 1000 nm or larger
+or an off-diagonal component was -100 nm or smaller.
+Now at least one space is always printed. Content that was written
+in a way that already had at least one space between components
+is unchanged. Existing parsers that conform to the documentation
+and expect whitespace separation will continue to work in all cases.
+
+:issue:`3176`
if ((box[XX][YY] != 0.0f) || (box[XX][ZZ] != 0.0f) || (box[YY][XX] != 0.0f) || (box[YY][ZZ] != 0.0f) ||
(box[ZZ][XX] != 0.0f) || (box[ZZ][YY] != 0.0f))
{
- fprintf(out, "%10.5f%10.5f%10.5f%10.5f%10.5f%10.5f%10.5f%10.5f%10.5f\n",
+ fprintf(out, "%10.5f %9.5f %9.5f %9.5f %9.5f %9.5f %9.5f %9.5f %9.5f\n",
box[XX][XX], box[YY][YY], box[ZZ][ZZ],
box[XX][YY], box[XX][ZZ], box[YY][XX],
box[YY][ZZ], box[ZZ][XX], box[ZZ][YY]);
}
else
{
- fprintf(out, "%10.5f%10.5f%10.5f\n",
+ fprintf(out, "%10.5f %9.5f %9.5f\n",
box[XX][XX], box[YY][YY], box[ZZ][ZZ]);
}
}