This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
> > 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. If you want to monitor progress on when this bug gets fixed, see: https://bugtracking.unidata.ucar.edu/browse/NCF-335 --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 > > 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