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 #67145 is a reply to message #67144] Mon, 06 July 2009 12:38 Go to previous messageGo 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:

> Hello,
>
> I've encountered a strange problem with some netCDF output using IDL.
>
> I define a character string array variable in my output netCDF file like so:
>
> VarId = NCDF_VARDEF( fid, 'Absorber_Units_Name', [32,n_Absorbers_DimId], /CHAR)
>
> where the "32" is the maximum string length.
>
> Now if I try to set a fill value attribute for that variable, like so
>
> NCDF_ATTPUT, fid, VarId, '_FillValue', ' '
> or
> NCDF_ATTPUT, fid, VarId, '_FillValue', 0B
>
> when I run the code I get the following error when I take the file out of
> define mode:
>
> % NCDF_CONTROL: Attempt to take the file out of define mode (ENDEF) failed.
> (NC_ERROR=-45)
>
> If I simply comment out the call to NCDF_ATTPUT for these character
> variables, there's no problem.
>
> I do this sort of thing (i.e. _FillValue of " " for character string
> variables) all the time using the Fortran90 API to netCDF so I assume an
> empty space is a valid fill value.
>
> Has anyone else encountered this behaviour in IDL? I.e. is this a known bug
> in the IDL netCDF interface, or do I need to do something special with
> character fill values?
>
> Thanks for any info.
>
> cheers,
>
> paulv
>
>

NCDF_VARDEF needs dimension ID, not dimension size. The following code
works for me:

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', ' '
ncdf_control, ncid, /endef
ncdf_close, ncid

and 'ncdump test.nc' produces:

netcdf test {
dimensions:
dim1 = 32 ;
dim2 = 9 ;
variables:
char absorber_units_name(dim2, dim1) ;
absorber_units_name:_fillvalue = " " ;
data:

absorber_units_name =
"",
"",
"",
"",
"",
"",
"",
"",
"" ;
}

NCDF_VARDEF does not print an error message, it returns -1 on failure :-(

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 16:04:51 PDT 2025

Total time taken to generate the page: 0.00332 seconds