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

[netCDF #EGM-614629]: ncgen/ncdump



Alison,

> Thanks for your quick response. The example you give does work for
> string variables. What I am looking for is a way to format attributes in
> the same way, so that I can include readable text in a global comment
> attribute.
> 
> I tried putting this in my CDL file:
> 
> :comment="Comment line 1\n",  "Comment line 2\n", "Comment line 3\n";
> 
> Running ncgen, and then ncdump on the resulting .nc file shows this:
> 
> :comment = "Comment line 1\nComment line 2\nComment line 3" ;
> 
> What I would like is for it to show this:
> 
> :comment = "Comment line 1",
> "Comment line 2",
> "Comment line 3" ;
> 
> So that a lengthy comment is formatted in a way that is readable by
> someone looking at the file. Is it possible to do this?

No, not currently. You've identified a bug in ncdump.  I believe it should
use the same code for output of attribute strings that is does for output
of string variables.

I'll add an entry about this to our bug-tracking system. Thanks for the bug
report.

--Russ


> Alison
> 
> On 6/20/2015 8:38 AM, Unidata netCDF Support wrote:
> > Hi Alison,
> >
> >> Organization: Desert Sage Software
> >> Package Version: 4.3.0
> >> Operating System: Linux 64-bit
> >> Description of problem: Hello,
> >> How do I specify a multi-line string in CDL such that ncgen -k 3 (enhanced 
> >> model) generates a netcdf file that when ncdump'ed will interpret the 
> >> embedded newlines in string attributes as line breaks? This is necessary 
> >> for readability of lengthy comment attributes. I have tried this 
> >> attribute: comment = "line one\n line two", and ncdump prints that 
> >> verbatim on one line instead of interpreting the \n as a newline and 
> >> breaking into two lines. Thanks for any help you may provide,
> >> Alison
> > Assume following is in str.cdl:
> >
> > netcdf str {
> > dimensions:
> > strlen=32;
> > variables:
> > char str(strlen);
> > data:
> > str="line1\n", "line2\n", "line3\n", "last line";
> > }
> >
> > Then this does what you want:
> >
> > $ ncgen -b -k 3 str.cdl
> > $ ncdump str.nc
> > netcdf str {
> > dimensions:
> > strlen = 32 ;
> > variables:
> > char str(strlen) ;
> > data:
> >
> > str = "line1\n",
> > "line2\n",
> > "line3\n",
> > "last line" ;
> > }
> >
> > Please let us know if this doesn't work for you ...
> >
> > --Russ
> >
> > Russ Rew                                         UCAR Unidata Program
> > address@hidden                      http://www.unidata.ucar.edu
> >
> >
> >
> > Ticket Details
> > ===================
> > Ticket ID: EGM-614629
> > Department: Support netCDF
> > Priority: Normal
> > Status: Closed
> >
> >
> 
> --
> Alison Walker
> address@hidden
> (928) 714-9471
> 
> 

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



Ticket Details
===================
Ticket ID: EGM-614629
Department: Support netCDF
Priority: Normal
Status: Closed