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

[netCDF #NFX-771785]: [netcdfgroup] Problem with default fill values

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.


  • Subject: [netCDF #NFX-771785]: [netcdfgroup] Problem with default fill values
  • Date: Tue, 25 Sep 2007 10:29:05 -0600

Hi,

I'm having trouble duplicating the problem you are reporting without more
information.

What is the type of the variable?  Are you actually calling the "put" method to
write the value
0 into the variable?

I have included below a small program that just creates a new netCDF file, an
integer variable named
"my_var", and writes 0 into the variable.  When I run ncdump on it, I get:

  netcdf testfill {
  variables:
          int my_var ;
  data:

   my_var = 0 ;
  }

as expected.  If instead I comment out the statement that writes the data, it
gets written with the
default fill value and when I run ncdump on it, I also get the expected
output:

  netcdf testfill {
  variables:
          int my_var ;
  data:

   my_var = _ ;
  }

Here is the program:

#include <iostream>
#include <netcdfcpp.h>
using namespace std;

// Return this in event of a problem.
static const int NC_ERR = 2;

int
main(void) {
   NcFile dataFile("testfill.nc", NcFile::Replace);
   if (!dataFile.is_valid()) {
      cout << "Couldn't open file!\n";
      return NC_ERR;
   }
   NcVar *data = dataFile.add_var("my_var", ncInt);
   int dataOut = 0;
   data->put(&dataOut);
   cout << "*** SUCCESS writing example file testfill.nc!" << endl;
   return 0;
}

--Russ


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



Ticket Details
===================
Ticket ID: NFX-771785
Department: Support netCDF
Priority: Normal
Status: Closed