[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #CQB-428218]: nf90_inq_type: too many arguments



Hi Dave,

> Followup.  There is another bug in the F77 version of this function.
> This is a cfortran bug.  My patch for nf90_inq_type will not work
> unless this other bug is also fixed.
> 
> 1.  In fort-nc4.c, line 81, the type spec for the third argument must
> be PSTRING, not STRING.
> 
> Original in netcdf-fortran 4.2:
> FCALLSCFUN4(NF_INT, nc_inq_type, NF_INQ_TYPE, nf_inq_type,
> NCID, FINT2CINT, STRING, PSIZET)
> 
> Changes to:
> FCALLSCFUN4(NF_INT, nc_inq_type, NF_INQ_TYPE, nf_inq_type,
> NCID, FINT2CINT, PSTRING, PSIZET)
> 
> I tested the F77 and F90 fixes on Mac OS 10.7.4 with gfortran 4.7.1.
> Both nf_inq_type and nf90_inq_type (the four argument version) seem to
> be working fine now.
> 
> Please implement these fixes for the next release.  Thank you.
> 
> --Dave
> 
> On Mon, Aug 27, 2012 at 4:01 PM, Dave Allured <address@hidden> wrote:
> > This is a bug report against NetCDF-Fortran version 4.2, and
> > apparently all previous Netcdf-4 releases with a Fortran 90 interface.
> >
> > The function nf90_inq_type is documented as having five arguments.
> > However, it simply calls nf_inq_type in the F77 interface, which has
> > only four arguments.  In netcdf4_func.f90, line 265:
> >
> >     nf90_inq_type = nf_inq_type(ncid, xtype, name, size, nfields)
> >
> > The last argument nfields is superfluous, and does not match the F77
> > prototype, so this is actually an illegal statement.  This looks like
> > a fairly obvious cut and paste error from another function in the same
> > family.  Since the F77 function is an external function, most
> > compilers will not catch the argument mismatch.
> >
> > Also note that the corresponding C function has only four arguments.
> > In summary, I believe the F77 and C definitions are correct, and the
> > current F90 definition is in error.
> >
> > I recommend the following fixes:
> >
> > 1.  In netcdf4_func.f90, remove all references to the extra nfields
> > argument, in 3 places according to my count.
> >
> > 2.  Remove the extra argument from the on-line documentation for 
> > nf90_inq_type.
> >
> > 3.  Fix possible calls to nf90_inq_type from the F90 test suite and
> > elsewhere.  My quick search in 4.2 source found no such references.
> >
> > 4.  Consider adding tests for this function.
> >
> > This change will cause a compile error in user programs that call
> > nf90_inq_type.  I speculate that this function is not widely used, and
> > the few people who do use it will appreciate the bug fix.

Thanks for reporting the bug and supplying a fix!  It's recorded as a Jira
issue:

  https://www.unidata.ucar.edu/jira/browse/NCFORTRAN-20

I included a small test, incorporated your fix to the code and documentation, 
and committed the fix, so it will be in the next release (version 4.2.1).

--Russ

Russ Rew                                         UCAR Unidata Program
address@hidden                      http://www.unidata.ucar.edu



Ticket Details
===================
Ticket ID: CQB-428218
Department: Support netCDF
Priority: Normal
Status: Closed