Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nc_inq_nvars returns incorrect result for groups in 4.3.1rc5 #9

Closed
jswhit opened this issue Dec 8, 2013 · 5 comments
Closed

nc_inq_nvars returns incorrect result for groups in 4.3.1rc5 #9

jswhit opened this issue Dec 8, 2013 · 5 comments

Comments

@jswhit
Copy link

jswhit commented Dec 8, 2013

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
@qkoziol
Copy link
Contributor

qkoziol commented Dec 9, 2013

Hi Jeff,
Thanks for the test file & code, I'll take a look at this shortly.

    Quincey

On Dec 7, 2013, at 8:49 PM, Jeff Whitaker notifications@github.com wrote:

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


Reply to this email directly or view it on GitHub.

@WardF
Copy link
Member

WardF commented Dec 10, 2013

I've added the test contributed by Jeff to the master development branch.

@qkoziol
Copy link
Contributor

qkoziol commented Dec 11, 2013

(BTW, still working on the other failures)

On Dec 10, 2013, at 4:58 PM, Ward Fisher notifications@github.com wrote:

I've added the test contributed by Jeff to the master development branch.


Reply to this email directly or view it on GitHub.

@qkoziol
Copy link
Contributor

qkoziol commented Dec 16, 2013

Hi Jeff,
I've just submitted a pull request with a changeset that addresses the issue you found. Hopefully it'll get folded into the main distribution shortly and you can give it a whirl.

Quincey

On Dec 7, 2013, at 8:49 PM, Jeff Whitaker notifications@github.com wrote:

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


Reply to this email directly or view it on GitHub.

@jswhit
Copy link
Author

jswhit commented Dec 16, 2013

Quincey: Looks like that pull request was merged, since my test case
now works with github master. Thanks!

-Jeff

Quincey Koziol mailto:notifications@github.com
December 15, 2013 7:10 PM
Hi Jeff,
I've just submitted a pull request with a changeset that addresses the
issue you found. Hopefully it'll get folded into the main distribution
shortly and you can give it a whirl.

Quincey

On Dec 7, 2013, at 8:49 PM, Jeff Whitaker notifications@github.com
wrote:

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


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub
#9 (comment).

@WardF WardF closed this as completed Dec 23, 2013
edhartnett added a commit to NetCDF-World-Domination-Council/netcdf-c that referenced this issue Jan 31, 2018
…_rename_is_coming

Merged some fixes from Greg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants