You cannot delete something that is not a pointer and deleting a pointer that was not 'new'-ed will cause an error, as you saw. A NcFile object could only be close by its destructor, but it also has a .close() method: https://unidata.github.io/netcdf-cxx4/classnetCDF_1_1NcFile.html#ad5fe1f98a48fb6c310eb294913cd141a
Forum