Skip to content

nc_inq_nvars returns incorrect result for groups in 4.3.1rc5 #9

@jswhit

Description

@jswhit

Noticed this when running the test suite for netcdf4-python after updating from github master today.

The following test program illustrates the problem:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <netcdf.h>
#define FILE_NAME "test.nc"
#define GRP_NAME "phony_group"

void
check_err(const int stat, const int line, const char *file) {
    if (stat != NC_NOERR) {
        (void)fprintf(stderr,"line %d of %s: %s\n", line, file, nc_strerror(stat));
        fflush(stderr);
        exit(1);
    }
}

int
main()
{

   int ncid, varid, grpid, numvars, retval;

   if ((retval = nc_open(FILE_NAME, NC_NOWRITE, &ncid)))
   check_err(retval,__LINE__,__FILE__);

   if ((retval = nc_inq_grp_ncid(ncid, GRP_NAME, &grpid)))
   check_err(retval,__LINE__,__FILE__);

   if ((retval = nc_inq_nvars(grpid, &numvars)))
   check_err(retval,__LINE__,__FILE__);

   (void)fprintf(stdout,"number of vars %d\n", numvars);

   return 0;
}

The test file (test.nc) is created by one of the python tests. I don't see any way to upload files to github, so here's a link to the file on my Google Drive.

https://drive.google.com/file/d/0B8_SExLApAk1UWJORmRJRVc4SWs/edit?usp=sharing

Running the above test program with rc4 yields:

number of vars 1

but rc5 yields

number of vars 0

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