[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #EHQ-439340]: Re: yet another, hopefully super-simple, netcdf question

Hi Greg,

> All is now working quite reasonably with my little application.
> One minor issue I have to fix. I already have a "history" global
> attribute from very first creation of the file and I'm reading in that
> attribute and appending to it. But when I try to write out the
> longer history text string, it isn't happening - only the original
> is staying. Is this because the global attributes are part of the
> entire header and cannot be increased beyond machine block
> size without essentially re-writing the entire file? I'm careful
> to check the total length of the variable and not exceed. What
> if I pad the original history string with junk filler and then overwrite
> the junk filler as I incrementally increase the text found in this
> history global attribute?

That should work fine for classic model files, as long as you do it in
"define mode", as documented here:


where it says:

  ... If this attribute is new, or if the space required to store the
  attribute is greater than before, the netCDF dataset must be in
  define mode.

That means it needs to be between nf90_redef and nf90_enddef calls,
and be sure to call nf90_close before exiting the program.

I'm surprised if you didn't get an error return when trying to expand
an attribute beyond available space if you're not in define mode.
That might be a bug in the netCDF-4 Fortran-90 implementation.

> Also, I believe my file is completely uncompressed. Again, I'm
> using classic, but netcdf4. I'll go digging deeper in online docs,
> but is there a function to call to compress data before writing
> to the output file?

No, you need to set compression properties for a variable when
defining it, using arguments to nf90_def_var.  See this section:


If you've already written a file and want to compress it without any more 
you can use the nccopy utility to copy to specify compression options:



Russ Rew                                         UCAR Unidata Program
address@hidden                      http://www.unidata.ucar.edu

Ticket Details
Ticket ID: EHQ-439340
Department: Support netCDF
Priority: Normal
Status: Closed

NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.