Unidata - To provide the data services, tools, and cyberinfrastructure leadership that advance Earth system science, enhance educational opportunities, and broaden participation. Unidata
         
  advanced  
 

Re: [netcdfgroup] PDL::NetCDF cannot write to existing netcdf files

Also in the docs it mentions:

If this file exists and you want to write to it, prepend the name with
the '>' character: ">name.nc"

So with this code:

my $nc = PDL::NetCDF->new(">testnc.nc", {MODE=>O_RDWR,REVERSE_DIMS=>1});

I get the same error:

MODE set and testnc.nc starts with >: suppressing > at ./testme.pl line 7
Cannot write read-only netCDF file testnc.nc at ./testme.pl line 9



Brice Lambi wrote:
> The docs don't mention an open function and I've tried various things to
> find one, but it doesn't seem to exist.  In the examples on the website:
> 
> http://search.cpan.org/~dhunt/PDL-NetCDF-4.01/netcdf.pd
> 
> They have this example:
> 
>   # opening existing file for reading and writing
>   $nc = PDL::NetCDF->new ("file2.nc", {MODE => O_RDWR,
>                         REVERSE_DIMS => 1});
> 
> Which is what I'm doing, but I get the same error when I try to put data
> (line 9 is the $nc->put).
> 
> Thanks,
> Brice
> 
> 
> Ted Mansell wrote:
>> I don't know anything about PDL, but I see the function is "new" so
>> maybe there is an "open" function call?  Perhaps "new" assumes that the
>> file doesn't exist already and doesn't like it when it does.  (Is line 9
>> the "my $nc =" or "$nc->put"?)
>>
>> -- Ted
>>
>>
>> On Jul 15, 2009, at 4:03 PM, Brice Lambi wrote:
>>>
>>> my $nc = PDL::NetCDF->new("testnc.nc", {MODE=>O_RDWR|REVERSE_DIMS=>1});
>>> my $data = pdl [1,2,3];
>>> $nc->put('time_nominal', ['recNum'], $data);
>>> $nc->close();
>>>
> 
> _______________________________________________
> netcdfgroup mailing list
> netcdfgroup@xxxxxxxxxxxxxxxx
> For list information or to unsubscribe,  visit: 
> http://www.unidata.ucar.edu/mailing_lists/ 


 
 
  Contact Us     Site Map     Search     Terms and Conditions     Privacy Policy     Participation Policy
 
National Science Foundation (NSF) UCAR Community Programs   Unidata is a member of the UCAR Community Programs, is managed by the University Corporation for Atmospheric Research, and is sponsored by the National Science Foundation.
P.O. Box 3000     Boulder, CO 80307-3000 USA     Tel: 303-497-8643     Fax: 303-497-8690