Skip to content

nc_open(<file schema>) returns NC_NOERR on non-NCZarr stores #2656

@czender

Description

@czender

Hi Gurus,

I invoke nc_open() with a file:// schema to determine whether a given
directory contains a valid NCZarr store.
It appears that nc_open(ncz_fl,NC_NOWRITE,&id) always succeeds if ncz_fl
is a valid path that already exists, regardless of whether
the existing path leads to an NCZarr store, a non-netCDF file, an empty directory, or a
directory full of non-NCZarr stuff. I am using netCDF 4.9.2, current
development snapshot on MacOS.

For example, the nc_open(ncz_fl,NC_NOWRITE,&id) returns NC_NOERR if

ncz_fl == file:///Users/zender/ncz_dnd/foo#mode=nczarr,file
and the directory (or file) /Users/zender/ncz_dnd/foo exists. Full stop.
nc_open(ncz_fl) succeeds when 1. foo contains an NCZarr store (yay!),
2. when foo exists but is a completely empty directory (boo!),
and 3. when foo is a directory filled with completely non-NCZarr contents (boo!),
and 4. when foo is any file (including non-netCDF files).
In the latter three cases I expect nc_open() to fail with an error such as

#define NC_ENOTNC (-51) /**< Not a netcdf file */

or

#define NC_ENOOBJECT (-141) /**< Some object not found */

Is this the observed behavior of nc_open() intentional? If so, why?
I thought nc_open() would return NC_NOERR only for existing netCDF files,
as implied by the nc_open() documentation.
Or am I missing something NCZarr-y?

Many thanks,
Charlie

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions