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

Re: 20021220: Problem with netcdf-3.5.0



>To: address@hidden
>cc: address@hidden,
>cc: address@hidden,
>cc: address@hidden
>From: Mototaka Nakamura <address@hidden>
>Subject: Problem with netcdf-3.5.0
>Organization: UCAR/Unidata
>Keywords: 200212201834.gBKIYAt02338

Hi,

> I have encountered a strange problem with NetCDF routine(s) provided in
> netcdf-3.5.0, and am seeking a help.  
> 
> When I try to write data into variables on an existing NetCDF file, the
> write command, NF_PUT_VARA_REAL, fails with an error code 22 (invalid
> argument), only when the size of the array is within a certain range or
> perhaps  size of dimensions have a certain relationship.  The problem is
> not caused by the size of the array per sa.  
> 
> As an example, I am attaching 2 simple programs that demonstrate this
> problem.  (testNC1 creates an NetCDF file and testNC2 writes into the
> created file)  When "lonin1" is varied (lonin2=lonin1-1), the write
> statement in testNC2 (nf_put_vara_real) fails between lonin1=1000 and
> lonin1=1300.  When lonin1 is reduced to 900 or increased to 1500, the
> write statement is executed without an error.  Another peculiar thing
> about this problem is that the problem goes away when I make
> lonin1=latin1 even if lonin1 is in the failing range with latin1=800.  
> 
> I would much appreciate your help on this problem.  Pleaese let me know
> soon if you need further information from me.  I will be out of town,
> Dec 24 - Jan 5.  Incidentally, I am running these programs on a single
> processor of SGI Origin 2000.  

The netCDF file you are trying to create with testNC1 is too large
unless the netCDF library you are using has been compiled with Large
File Support (LFS).  You have 7 large variables that each require more
than 1.29 Gbytes, so the size of file you are trying to write is
larger than 9 Gbytes.  With a netCDF library compiled without LFS, the
size of netCDF files is limited to about 2.14 Gbytes.  There is more
information about this in the netCDF FAQ document, under the answer to
the question "Is it possible to create netCDF files larger than 2
Gbytes?":

  http://www.unidata.ucar.edu/packages/netcdf/faq.html#lfs

Even with a netCDF library built with LFS, you will still not be able
to write your data using the structure you have specified, because
it would violate the format restriction that offsets to the start of
all non-record variables must be less than 2**31, so that the offsets
can fit in the 32-bit integers reserved for this purpose in the
current file format.  You could write two of these variables in a
netCDF file without violating the restriction, but the offset of the
beginning of the third variable from the beginning of the data would
exceed 2**31 bytes, so writing it would result in an error.

You may be able to restructure your data to fit it all in a single
netCDF file, if you make use of the unlimited dimension to make sure
that the offset of the start of each record variable within a record
is less than about 2.14 Gbytes.  For more information, see the Large
File Support section of the User's Guide:

  
http://www.unidata.ucar.edu/packages/netcdf/f90/Documentation/f90-html-docs/guide9.html#2236524

where the following example of a 2.4 Tbyte file is presented:

  netcdf bigfile2 {
    dimensions: 
       x=2000;
       y=5000;
       z=10;
       t=UNLIMITED;         // 1000 records, for example
    variables:
       double x(x);         // coordinate variables
       double y(y);
       double z(z);
       double t(t);
                            // 3 record variables, 2.4 Gbytes per record
       double var1(t, x, y, z);
       double var2(t, x, y, z);
       double var3(t, x, y, z);
  }

If there were a single "time" dimension for your data and it was the
unlimited dimension, for example, then you could easily store the data
in a structure such as this:

  netcdf testForce2 {
  dimensions:
          xi_u = 1099 ;
          xi_v = 1100 ;
          xi_rho = 1100 ;
          eta_u = 800 ;
          eta_v = 799 ;
          eta_rho = 800 ;
          time = UNLIMITED ;  // currently 368
  variables:
          float time(time) ;
          float sustr(time, eta_u, xi_u) ;
          float svstr(time, eta_v, xi_v) ;
          float swrad(time, eta_rho, xi_rho) ;
          float swflux(time, eta_rho, xi_rho) ;
          float shflux(time, eta_rho, xi_rho) ;
          float SST(time, eta_rho, xi_rho) ;
          float dQdSST(time, eta_rho, xi_rho) ;
  }

and the length of the time dimension could grow as large as desired.

The next version of the netCDF format will remove this restriction,
but we're still seeking resources for the necessary development ...

Incidentally, if you want to save time writing large files like this,
and you know you will write all of the data so pre-filling it with fill
values is not necessary, then you can avoid the costly pre-filling by
specifying no-fill mode:

      ! write data with no pre-filling
      omode = nf_set_fill(ncid, NF_NOFILL)

as described in section 5.12 of the Fortran netCDF User's Guide:

  http://www.unidata.ucar.edu/packages/netcdf/guidef/guidef-10.html#HEADING10-0

--Russ

_____________________________________________________________________

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