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

[netCDF #YJQ-627045]: Problem with return code NC_EBADTYPE (NetCDF3) in Fortran program



Hi Arjen,

> I am trying to write a single integer value to a NetCDF file and I get
> the return code -45 (NC_EBADTYPE). Here are (hopefully useful) fragments
> of the code:
> 
> The variable is created using:
> ierror = nf90_def_var( ncidout, name, nf90_int, (/ ntimeid /), timeid )
> 
> where the ntimeid is a unlimited dimension.
> 
> I use the following code to write a value:
> 
> integer function dlwqnc_write_wqtime( ncidout, timeid, record, time )
> integer, intent(in) :: ncidout
> integer, intent(in) :: timeid
> integer, intent(in) :: record
> integer, intent(in) :: time
> 
> integer               :: ierror
> integer, dimension(1) :: values
> integer, dimension(1) :: start
> integer, dimension(1) :: count
> 
> dlwqnc_write_wqtime = nf90_noerr
> 
> values = time
> start  = record
> count  = 1
> ierror = nf90_put_var( ncidout, timeid, values, start, count )
> if ( ierror /= nf90_noerr ) then
> dlwqnc_write_wqtime = ierror
> return
> endif
> 
> end function dlwqnc_write_wqtime
> 
> The variable record has the value 1 and this is the first time the
> program tries to write a value to the time variable.
> ierror = nf90_put_var( ncidout, timeid, values, start, count )
> What is going wrong? I can send you the entire program, but it relies
> on a large file.

Though we can't reproduce the problem, here's two things to try.
First, make sure you explicitly set record=0 before calling
nf90_put_var, because if it's just unitialized, as in the 
fragment you sent, I'm not sure what kinds of behavior to
expect.

Secpnd, since strat and count are optional parameters to 
nf90_put_var, you ought to use the argument keyword to
specify which is which, with:

  ierror = nf90_put_var( ncidout, timeid, values, start=start, count=count )

I would have thought your Fortran compiler would emit a
warngin or error when you try to use optional parameters
without identifying them ...

> I came across a similar problem at
> 
> https://bugtracking.unidata.ucar.edu/browse/NCF-172
> 
> but that seems to be a problem with NetCDF4, whereas I am using 3.6.1.

First that's a pretty old version, from February 2006, and it's 
impractical for us to reproduce or fix bugs in 9-year old software.

But if you could provide a small example that fails, I could try
to reproduce it using netCDF-4 (which still supports all the
netCDF-3 API and functionality) to see what's really going on.

--Russ

> Regards,
> 
> Arjen
> DISCLAIMER: This message is intended exclusively for the addressee(s)
> and may contain confidential and privileged information. If you are not
> the intended recipient please notify the sender immediately and destroy
> this message. Unauthorized use, disclosure or copying of this message
> is strictly prohibited. The foundation 'Stichting Deltares', which
> has its seat at Delft, The Netherlands, Commercial Registration Number
> 41146461, is not liable in any way whatsoever for consequences and/or
> damages resulting from the improper, incomplete and untimely dispatch,
> receipt and/or content of this e-mail
> .
> 
> 
Russ Rew                                         UCAR Unidata Program
address@hidden                      http://www.unidata.ucar.edu



Ticket Details
===================
Ticket ID: YJQ-627045
Department: Support netCDF
Priority: Normal
Status: Closed