Invalid cube file

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)