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, Here is a bug found in ncdump utility delivered with netCDF V3.6.0. The bug appears when attributes have a zero length. In this case, it tries to show them as 0 length string but the way it is implemented is buggy. The value shown depends on the non empty preceding attribute. If it is a string, the first letter of this string is repeated as the value of all empty following attributes (due to a reuse of allocated data not initialized). Below is an exemple (the last 3 attributes have 0 values): :Data_provider = "Data provider" ; :Experiment_name = "D" ; :Project_name = "D" ; :Experiment_description = "D" ; Notice that it also depends on the OS and compiler (or libc). On Linux/gcc it appears, on Solaris/Workshop C it does not. There is another problem when printing control characters (bug or not ?)as attributes: except for a few of them (\r\f...) the other are printer 'as is'
and make the output file mainly unreadable (by eyes, not by ncgen). You can find joined a patch which can be used to correct these problems (I did also make it for CVS version 1.9 and 1.10). Cheers, Ph. Poilbarbe. CLS - Space Oceanography Group mailto:Philippe.Poilbarbe@xxxxxx http://www.cls.fr
--- ncdump.c.orig 2004-11-16 22:38:16.000000000 +0100 +++ ncdump.c 2005-01-13 09:41:35.200874000 +0100 @@ -2,6 +2,7 @@ * Copyright 1993, University Corporation for Atmospheric Research * See netcdf/README file for copying and redistribution conditions. * $Header: /upc/share/CVS/netcdf-3/ncdump/ncdump.c,v 1.12 2004/11/16 21:38:16 russ Exp $ + * 2004/01/29: Ph. Poilbarbe: Corrected for 0 length attributes and control characters *********************************************************************/ #include <stdio.h> @@ -197,7 +198,10 @@ Printf ("\\\""); break; default: - Printf ("%c",uc); + if (iscntrl(uc)) + Printf("\\%03o",uc); + else + Printf ("%c",uc); break; } Printf ("\""); @@ -306,11 +310,10 @@ if (att.len == 0) { /* show 0-length attributes as empty strings */ att.type = NC_CHAR; - att.len = 1; } switch (att.type) { case NC_CHAR: - att.string = (char *) malloc(att.len); + att.string = (char *) malloc(att.len+1); if (!att.string) { error("Out of memory!"); NC_CHECK( nc_close(ncid) );
netcdfgroup
archives: