Re: [netcdfgroup] trouble with NF_PUT_VARA_REAL

Dan,

I do not see a prior value assigned to "lev" in line 3 of your code. What is it? If anything other than 1, then that explains why Q is all missing values in the last two lines you displayed. If lev is between 2 and 72, then look for a block of data, or scattered data, hidden lower in the output from ncdump.

The dataset dimensions as viewed by ncdump should be in the REVERSE order from the variable dimensions in fortran. See this page in the users' guide on fortran data access:

http://www.unidata.ucar.edu/software/netcdf/docs/netcdf/Fortran-Section-Access.html

However, you can reverse the displayed dimension order by using the -b or -f options with ncdump, and make it line up with fortran. See ncdump documentation.

Because of the ordering problem, perhaps, you may have a subscript out of range for NF_PUT_VARA_REAL. Therefore no data was written to the Netcdf file. You really should check the returned status codes from ALL calls to the Netcdf library, and stop immediately when status .ne. NF_NOERR, with a helpful message.

Also, set valid_range to appropriate min and max values for your data set, or else entirely leave out this attribute. Failure to fix this will probably not bother ncdump, but it may hide the data from certain other common softwares that are attribute sensitive.

--Dave A.
NOAA/PSD/CIRES

On 10/4/2010 2:42 PM, Dan Kokron wrote:
Hello all,

I am attempting to use the NF_PUT_VARA_REAL routine to write a series of
two dimensional arrays where each array represents a quantity on a
single horizontal level.  The array is sized 1152x721 and there are 72
levels to be written.  An ncdump of the resulting file shows that all of
the values for 'Q' are '_' instead of real physical values.

Any ideas?

Should the dataset dimensions have the same order as the variable
dimensions?

Here are my 'start' and 'count' arrays.  I can probably get rid of the
time dimension since the file will never contain more than one time.

        start(1) = 1
        start(2) = 1
        start(3) = lev
        start(4) = 1
        count(1) = 1152
        count(2) = 721
        count(3) = 1
        count(4) = 1
        STATUS = NF_PUT_VARA_REAL(fid, varid, start, count, VAR)

ncdump of the resulting file gives

dimensions:
         lon = 1152 ;
         lat = 721 ;
         lev = 72 ;
         time = UNLIMITED ; // (1 currently)
variables:
         double lon(lon) ;
                 lon:long_name = "longitude" ;
                 lon:units = "degrees_east" ;
         double lat(lat) ;
                 lat:long_name = "latitude" ;
                 lat:units = "degrees_north" ;
         double lev(lev) ;
                 lev:long_name = "vertical level" ;
                 lev:units = "layer" ;
                 lev:positive = "down" ;
                 lev:coordinate = "eta" ;
                 lev:standard_name = "model_layers" ;
         int time(time) ;
                 time:long_name = "time" ;
                 time:units = "minutes since 2009-01-01 00:00:00" ;
                 time:time_increment = 60000 ;
                 time:begin_date = 20090101 ;
                 time:begin_time = 0 ;
         float Q(time, lev, lat, lon) ;
                 Q:long_name = "specific_humidity" ;
                 Q:units = "1" ;
                 Q:_FillValue = 1.e+15f ;
                 Q:missing_value = 1.e+15f ;
                 Q:fmissing_value = 1.e+15f ;
                 Q:scale_factor = 1.f ;
                 Q:add_offset = 0.f ;
                 Q:standard_name = "specific_humidity" ;
                 Q:vmin = 1.e+15f ;
                 Q:vmax = 1.e+15f ;
                 Q:valid_range = 1.e+15f, 1.e+15f ;

data:

  Q =
   _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
_, _,
     _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
_,




  • 2010 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: