[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
20031212: pgf90, nf90_short
- Subject: 20031212: pgf90, nf90_short
- Date: Fri, 12 Dec 2003 11:29:25 -0700
Tim,
> To: <address@hidden>
> From: Tim Hoar <address@hidden>
> Subject: pgf90, nf90_short (fwd)
> Organization: NCAR/CGD
The above message contained the following:
> I am creating a netcdf file but do not seem to be getting the right
> _size_ file.
>
> I have a variable of length 18811 and the netCDF file is
> the same size if I code this thing as a NF90_SHORT or a NF90_FLOAT.
>
> This is with the pgf90 4.1-2 compiler on poorman (RH 9.0), and the
>
> /usr/local/netcdf-3.5.1-beta5-pgi-hpf-cc-4.1-2/libnetcdf.a library.
>
> :netCDF_library_version = "3.5.0 of Aug 28 2002 15:59:11 $" ;
>
>
> if(.not. byteSizesOK()) then
> print *, "Compiler does not appear to support required kinds of variables."
> stop
> end if
>
> Does not error out ...
>
> Any ideas?
>
>
> call check(NF90_def_var(ncid=ncFileID, name="precip", xtype=NF90_short, &
> dimids = TimeDimID, varid=PrcpVarID))
> call check(NF90_put_att(ncFileID, PrcpVarID, "long_name",
> "daily total precipitation"))
> call check(NF90_put_att(ncFileID, PrcpVarID, "units", "mm"))
>
> The (current) length of the (unlimited) TimeDimID is 18811
>
> Without the precip variable, the file size is: 77064 bytes.
> Coded as a short, file size is: 152472
> Coded as a float, file size is: 152472
> Coded as a double, file size is: 227716
>
> 77064 + 18811*2 = 114686 ( off by a bunch )
> 77064 + 18811*4 = 152308 ( off by 164 bytes )
> 77064 + 18811*8 = 227552 ( off by 164 bytes )
The "problem" is that the "precip" variable is a 1-D record variable (i.e.,
it uses the unlimited dimension. When such variables are written to
disk, they are put into a system-independent format by an XDR layer
within the netCDF library. When this layer writes out a single netCDF
record -- as it does for every element of the "precip" variable -- it
pads the output record to a 4-byte boundary for reasons having to do
with the XDR standard.
If the "precip" variable wasn't a netCDF record variable, then the
"short" form of the resulting file would be smaller than the "float"
form of the file.
In summary, having a single, short, record variable doesn't get you
anything over a single, float, record variable.
> ## Tim Hoar, Associate Scientist email: address@hidden ##
> ## Geophysical Statistics Project phone: 303-497-1708 ##
> ## National Center for Atmospheric Research FAX : 303-497-1333 ##
> ## Boulder, CO 80307 http://www.cgd.ucar.edu/~thoar ##
Regards,
Steve Emmerson