[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bug in netcdf?
- Subject: Re: bug in netcdf?
- Date: Tue, 28 Jan 1997 09:21:28 -0700
> From: Robert Fischer <address@hidden>
> To: Russ Rew <address@hidden>
> Organization: Harvard Seismology
Hi Bob,
> i'm trying the following with netcdf 2.4.3:
>
> netcdf lapo {
> dimensions:
> ncol = 2 ;
> variables:
> double ata(ncol, ncol) ;
> ata:remark = "Squared matrix for normal eq. (A^T A)" ;
>
> data:
>
> ata = 1,2,3,4;
>
> }
>
> run ncgen on it (or try the equivalent in C-code), and you get:
>
> (pilgrim:1.29)~/sc/prg/inv> ncgen -o x.cdf x.cdl
> ncvardef: Invalid number of dimensions 2 > 1
>
> the code in question is in var.c:
>
> if(ndims > 0 )
> {
> if(handle->dims == NULL || ndims > handle->dims->count )
> {
> NCadvise(NC_EINVAL, "Invalid number of dimensions %d > %d",
> ndims, (handle->dims != NULL) ? handle->dims->count : 0) ;
> return(-1) ;
> }
> }
>
> i don't believe the above case is (or should be) an error. am i right in
> saying that var.c is wrong? maybe change it to something like:
>
> if(ndims > 0 )
> {int ddims;
> let ddims = number of DISTINCT dimensions;
>
> if(handle->dims == NULL || ndims > handle->dims->count )
> {
> NCadvise(NC_EINVAL, "Invalid number of dimensions %d > %d",
> ndims, (handle->dims != NULL) ? handle->dims->count : 0) ;
> return(-1) ;
> }
> }
>
> or maybe to speed it up, change to:
>
> if(ndims > 0 )
> {
> if(handle->dims == NULL)
> {
> NCadvise(NC_EINVAL, "Invalid number of dimensions %d > %d",
> ndims, (handle->dims != NULL) ? handle->dims->count : 0) ;
> return(-1) ;
> }
> }
Yes, you're right, this is a bug.
I've appended a recent reply about this to another user who pointed out
the problem.
--Russ
_____________________________________________________________________
Russ Rew UCAR Unidata Program
address@hidden http://www.unidata.ucar.edu
Subject: Re: 970108: Bug in netCDF 2.4.3
In-reply-to: Your message of "Wed, 08 Jan 1997 10:47:16 MST."
Date: Wed, 08 Jan 1997 11:19:30 -0700
From: Russ Rew <address@hidden>
>To: address@hidden
>Subject: Bug in netCDF 2.4.3
>Organization: Laboratoire de Dynamique Moleculaire, Institut de Biologie
>Structurale
>Keywords: 199701081017.DAA11848
Hi Konrad,
> first of all, thanks for netCDF. It's just what I need for my daily
> work in computational chemistry.
Thanks for letting us know that it's useful to you.
> I think I found a bug in the current version. I was trying to create a
> file with one variable for a 3x3 matrix representing a tensor. The
> file had just one dimension, xyz = 3, and the variable was to be defined
> as polarizability(xyz, xyz). But ncvardef() didn't like that definition
> and claimed "Invalid Argument". Looking at the source code in var.c
> I found the following test:
>
> if(ndims > 0 )
> {
> if(handle->dims == NULL || ndims > handle->dims->count )
> {
> NCadvise(NC_EINVAL, "Invalid number of dimensions %d >
> %d",
> ndims, (handle->dims != NULL) ?
> handle->dims->count : 0) ;
> return(-1) ;
> }
> }
>
> This means I can't create a variable whose rank is higher than the
> number of dimensions defined in the file. It doesn't take into account
> the possibility of using one dimension more than once in a variable
> definition.
>
> I suspect the second part of this test (ndims > handle->dims->count)
> can be removed without causing any harm, since the dimension ids
> will be checked for validity later on anyway.
Yes, this is a bug in netcdf-2.4.3, but it's fixed in the current alpha
release of the netCDF-3 C interface, available as
ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-3.1a.tar.Z
Thanks for reporting the problem. One inelegant workaround, if you
don't want to recompile the source or try alpha pre-release, would be to
add another dimension of size 1 but not use it.
--Russ
_____________________________________________________________________
Russ Rew UCAR Unidata Program
address@hidden http://www.unidata.ucar.edu