comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Can't exit DEFINE mode in netCDF File
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Can't exit DEFINE mode in netCDF File [message #68268 is a reply to message #68119] Tue, 06 October 2009 14:45 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

>
> Folks,
>
> I am writing my first netCDF file in IDL and I am practically
> copying the code out of Ken Bowman's book. I open a file:
>
> fID = NCDF_CREATE(filename, /CLOBBER)
>
> Then, I define several global attributes, two dimensions,
> and two variables. I also define a couple of attributes
> of the variables. All in that order.
>
> Then, I attempt to get out of DEFINE mode and into DATA
> mode, so I can write the actual variables.
>
> NCDF_CONTROL, fID, /ENDEF
>
> But at this point I get the following error message:
>
> % NCDF_CONTROL: Attempt to take the file out of
> define mode (ENDEF) failed. (NC_ERROR=-45)
> % Execution halted at: TIMESERIES::CREATE_CLIMATOLOGY 2589
>
> Does anyone have ANY idea what this might be about?

The code is pretty simple:

; Create a netCDF file for storing the climatology.
fID = NCDF_Create(filename, /CLOBBER)

; Define dimensions.
xsizeID = NCDF_DIMDEF(fID, 'cols', xsize)
ysizeID = NCDF_DIMDEF(fID, 'rows', ysize)
timeID = NCDF_DIMDEF(fID, 'time', 2)

; Define variables.
vid = NCDF_VARDEF(fID, 'time', [timeID], /LONG)
vid = NCDF_VARDEF(fID, 'climatology', [xsizeID, ysizeID], /DOUBLE)

; Define variable attributes.
NCDF_ATTPUT, fID, 'time', 'units', 'Days since 1601-01-01 00:00:00'
NCDF_ATTPUT, fID, 'time', 'long_name', 'Start and end time. '
NCDF_ATTPUT, fID, 'climatology', '_FillValue', fillValue
NCDF_ATTPUT, fID, 'climatology', 'long_name', 'longish name'

; Exit DEFINE mode and into DATA mode.
NCDF_Control, fID, /ENDEF

; Write the variables.
NCDF_VarPut, fID, 'time', [time[0], time[timepts-1]]
NCDF_VarPut, fID, 'climatology', climatology

; Close the file.
NCDF_Close, fID

At one time I had global attributes in there, but I took them out
and the code worked! So I added them back one by one. Then, it
didn't work again, so I took them all back out. Now it *still*
doesn't work! Something really, really weird going on here, I think. :-(

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: interpolation of irregular satellite data
Next Topic: Re: IDLDE and java crashes

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 00:12:07 PDT 2025

Total time taken to generate the page: 0.56096 seconds