NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
Hello, I'm trying to update some older code to use PDL::NetCDF but I'm having problems writing to existing nc files. For example, if we have a simple cdl file: netcdf testme { dimensions: recNum = UNLIMITED ; variables: int time_nominal( recNum ) ; time_nominal:long_name = "time nominal"; time_nominal:_FillValue = -99999; time_nominal:units = "seconds since 1970-01-01 00 UTC"; :title = "test cdl"; :version = 1.1; } and we run ncgen: ncgen -o testnc.nc testme.cdl Then we try to open the file with a perl script using PDL::NetCDF and write to it: use PDL; use PDL::NetCDF; use PDL::Char; 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(); This is the error I see: Cannot write read-only netCDF file testnc.nc at ./testme.pl line 9 But if I first delete the file that I created with ncgen and run the same code again it will run successfully and this is the output from ncdump: netcdf testnc { dimensions: recNum = 3 ; variables: double time_nominal(recNum) ; data: time_nominal = 1, 2, 3 ; } But then if I run this code one more time (without deleting the file) I will get the error again. Is there something else I can do to tell PDL::NetCDF to write to the existing file, even though my MODE is O_RDWR? Or is this a known issue? Thanks, Brice Lambi
netcdfgroup
archives: