netcdf-c icon indicating copy to clipboard operation
netcdf-c copied to clipboard

ncdump: change the error message when opening an empty file

Open jypeter opened this issue 8 months ago • 0 comments

One of our PhD students reported this morning that our local ncdump version was too old, because he could not open a file he had generated in our HPC center (where ncdump was giving the expected output) and downloaded on our local servers

It turned out that the local disk was full and that he was trying to open empty files :-)

It's not the first time we have run into this kind of silly problem. The student was not a noob and he used ncdump -k on both the source and the local (empty) file. He did not went as far as using md5sum on both files, which would have told him that they were different

Seems to me that it would be easy to test this special empty file case and display a specific and useful/helpful error message. There may be other special cases to test

The problem can be easily reproduced the following way:

 >nc-config --version
netCDF 4.9.2

 >touch stupid_empty_file.nc

 >ls -l stupid_empty_file.nc
-rw-r--r-- 1 XXXXX YYY 0 Mar  6 14:00 stupid_empty_file.nc

 >ncdump -k stupid_empty_file.nc
ncdump: stupid_empty_file.nc: NetCDF: Unknown file format

 >ncdump -h stupid_empty_file.nc
ncdump: stupid_empty_file.nc: NetCDF: Unknown file format

jypeter avatar Mar 06 '25 13:03 jypeter