Subject: | NetCDF - Cannot write _FillValue attribute |
Date: | Tue, 26 Apr 2011 16:46:24 -0400 |
To: | <bug-PDL-NetCDF [...] rt.cpan.org> |
From: | Gary Fu <gfu [...] sigmaspace.com> |
Hi,
I'm using NetCDF version 4.07 with NetCDF4 support.
In the example below, I tried to write the '_FillValue' attribute to a
variable. It works if I open the file with the default format
(NC_FORMAT_CLASSIC), but it fails if I use the format
NC_FORMAT_NETCDF4_CLASSIC. Is this a bug or a feature that I don't know
about it.
Thanks,
Gary
4:39pm 840 gfu@sigma-113:~/modaps/modis2netcdf$ uname -a
Linux sigma-113.hbsss.local 2.6.18-164.el5 #1 SMP Thu Sep 3 03:28:30 EDT
2009 x86_64 x86_64 x86_64 GNU/Linux
4:38pm 838 gfu@sigma-113:~/modaps/modis2netcdf$ perl -e 'use
PDL::NetCDF; print "$PDL::NetCDF::VERSION\n"'
4.07
4:38pm 839 gfu@sigma-113:~/modaps/modis2netcdf$ perl -e 'use
PDL::NetCDF; print "NetCDF4\n" if (PDL::NetCDF::isNetcdf4)'
NetCDF4
---------------------------------------------------------------------------------
#! /usr/local/bin/perl -w
use strict;
use PDL;
use PDL::NetCDF;
my ($nc_file) = @ARGV;
#my $nc = PDL::NetCDF->new ($nc_file, {REVERSE_DIMS => 1});
#my $nc = PDL::NetCDF->new ($nc_file,
{NC_FORMAT=>PDL::NetCDF::NC_FORMAT_CLASSIC});
my $nc = PDL::NetCDF->new ($nc_file,
{NC_FORMAT=>PDL::NetCDF::NC_FORMAT_NETCDF4_CLASSIC});
my $sds_name = 'Longitude';
my @dim_names = ('X', 'Y');
my $data = float zeros(100,100);
$nc->put ($sds_name, \@dim_names, $data);
my $attr_name = '_FillValue';
my $attr_val = float pdl [999.];
$nc->putatt ($attr_val, $attr_name, $sds_name);
$nc->close();
---------------------------------------------------------------------------------------
4:30pm 830 gfu@sigma-113:~/modaps/modis2netcdf$ t.pl x.nc
putatt: Cannot put PDL attribute -- NetCDF: Attempt to define fill
value when data already exists. at t.pl line 24