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

Home » Public Forums » archive » Re: NCDF_ATTPUT _FillValue problem for string arrays?
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: NCDF_ATTPUT _FillValue problem for string arrays? [message #67134] Tue, 07 July 2009 00:17 Go to previous message
Foldy Lajos is currently offline  Foldy Lajos
Messages: 268
Registered: October 2001
Senior Member
On Mon, 6 Jul 2009, Paul van Delst wrote:

> AHA!!!
>
> When I change your above test code to use the conventional fill value
> attribute name as specified in the netCDF Interface Guide, "_FillValue", I
> get the following:
>
> ncid=ncdf_create('test.nc', /clobber)
> dim32=ncdf_dimdef(ncid, 'dim1', 32)
> n_absorbers_dimid=ncdf_dimdef(ncid, 'dim2', 9)
> varid = ncdf_vardef( ncid, 'absorber_units_name', [dim32,n_absorbers_dimid], /char)
> ncdf_attput, ncid, varid, '_FillValue', ' ' ; <---**** Note the attribute name
> ncdf_control, ncid, /endef
> ncdf_close, ncid
>
> IDL> .run blah
> % Compiled module: $MAIN$.
> % NCDF_CONTROL: Attempt to take the file out of define mode (ENDEF) failed.
> % (NC_ERROR=-45)
> % Execution halted at: $MAIN$ 6 scratch/blah.pro
>
>
> So:
> - if I use "_fillvalue" for the attribute name, the code works fine.
> - if I use "_FillValue" for the attribute name, the code crashes.
>

I have found the solution: _FillValue needs to be the same type as the
variable. ' ' is an IDL string, which is converted to something, probably
BYTE. So let's add an explicite /CHAR to ncdf_attput:

ncid=ncdf_create('test.nc', /clobber)
dim32=ncdf_dimdef(ncid, 'dim1', 32)
n_absorbers_dimid=ncdf_dimdef(ncid, 'dim2', 9)
varid = ncdf_vardef( ncid, 'absorber_units_name', [dim32,n_absorbers_dimid], /char)
ncdf_attput, ncid, varid, '_FillValue', ' ', /CHAR
ncdf_control, ncid, /endef
ncdf_close, ncid

It works now! :-)

regards,
lajos
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Are user-defined private methods possible?
Next Topic: IDL 7.1 dialog_pickfile segmentation fault

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

Current Time: Wed Oct 08 13:44:31 PDT 2025

Total time taken to generate the page: 0.00414 seconds