Juanes
September 9, 2026, 11:49pm
1
In attempting to open a particular cube file, I get the following error:
Error while reading file ... . Invalid cube file.
problem_cube.txt (6.0 MB)
I generated a simpler (smaller) test cube file with the same code and it opens fine. Note the trouble one opens and visualizes just fine with IQmol.
fine_cube.txt (338.9 KB)
Any idea what could be wrong?
Yes. Internally, we store Cube data as float instead of double to save memory. We’re generally only rendering orbitals, etc. so the loss of precision isn’t a big deal and lets users handle larger cubes on lower-end hardware.
In this case, there was an underflow - a value too small for a float. Clearly that bug has been there for ages, but no one reported it.
Now, it reads in double and converts to float (e.g., 1.0e-34 => 0.0)
master ← ghutchis:fix-cube-underflow-float
opened 12:54AM - 10 Sep 26 UTC
Add a specialized template for lexicalCast for float to actually read as double … and cast to float to avoid underflow in the future (e.g., 1.0e-34, etc.)
Developer Certificate of Origin
Version 1.1
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.