I missed the attached file, sorry. I can read it fine using a recent
version of ncdump with recent netcdf and HDF5 libraries. This is a netcdf4
file made with NCO 4.6.1 and a relatively old netcdf library version, old
enough that the _NCProperties attribute is absent. Superblock 2 suggests
it is probably not a format compatibility issue. My best guess is one of
those file lock problems on your system.
On Sun, Mar 24, 2019 at 6:40 PM Dave Allured - NOAA Affiliate <
dave.allured@xxxxxxxx> wrote:
> Sourish,
>
> You are getting this confusing error because the underlying HDF5 layer
> supporting netcdf4 format is currently limited to only pass/fail return
> codes. A fail status is returned simply as "HDF error", regardless of the
> details. This means that when some program such as ncap2 tries to
> initially open a netcdf4 file, it can't tell the difference between file
> not found, and some other format problem, without adding messy and
> redundant error analysis code. I wish this situation could be improved.
>
> Since your file actually exists, try some other methods to see what HDF5
> and netcdf might not like. First see if ncdump works. You can check the
> file signature in the first 8 bytes with the "file" command or the simple
> "od" command. Then try HDF tools such as h5dump and h5debug. Make sure
> your HDF5 tools are relatively recent. It would be quite helpful to get
> the HDF5 error stack to print under ncap2. If you figure out how to do
> that, please let the rest of us know.
>
> Here are several more probable causes of HDF error on open, with an
> existing file.
>
> * The file is network mounted, and you did not disable HDF5 file locking.
> * The file was created with a later version of HDF5, without the proper
> backward compatibility setting.
> * The file or path is read protected.
> * On Mac OS, the file is in a pseudo locked state due to a recent program
> crash.
> * Oh yeah, triple check the file name and path. This happens more often
> than we like to admit.
>
> It is possible that you really have a broken netcdf4 file. In my
> experience, such reports are usually one of these other things in
> disguise. HTH.
>
> --Dave
>
>
> On Sun, Mar 24, 2019 at 4:40 PM Sourish Basu <Sourish.Basu@xxxxxxxxxxxx>
> wrote:
>
>> Hello all,
>>
>> I am trying to add two variables and put the result in a third one with
>> ncap2, and I have this strange error:
>>
>> $ ncap2 -L 6 -4 -h -A -s
>> 'co2_flux_natural=bio_flux_opt+fire_flux_imp+ocn_flux_opt' guineapig.nc
>> ERROR: nco__open() unable to open file "guineapig.nc"
>> nco_err_exit(): ERROR Short NCO-generated message (usually name of
>> function that triggered error): nco__open()
>> nco_err_exit(): ERROR Error code is -101. Translation into English with
>> nc_strerror(-101) is "NetCDF: HDF error"
>> nco_err_exit(): ERROR NCO will now exit with system call
>> exit(EXIT_FAILURE)
>>
>> Which is extremely strange, because the file guineapig.nc *does* exist
>> in the current folder:
>>
>> $ ls -l guineapig.nc
>> -rw-r--r-- 1 i i 4862322 Mar 24 16:28 guineapig.nc
>>
>> What is more, I can use ncap2 to perform the exact same operation on
>> some other files without a problem. Which leaves me very confused as to
>> why ncap2 fails and tells me that this file does not exist, when it
>> clearly does and is writable. The guineapig is attached. Anyone has any
>> idea?
>>
>> Thanks,
>>
>> Sourish
>>
>