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

Re: pgf90, nf90_short



Hi Tim,

> 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.
 ...
> 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 size in bytes of each record in a netCDF file is padded out to be
a multiple of 4 for portability and efficiency.  This is implied in
the chapter on the file format, but not very easy to find.

So, if you just have a single one-dimensional record variable,
"precip", the sizes are the same whether it's byte, short, or float,
because the size in bytes of every record in a netCDF file must be
divisible by 4.  But you could store two values per record with each
value a short and it would still only take 4 bytes.  Typically, there
are more than one record variable, and record variables have other
dimensions than the record dimension, so there are many values per
record.  In that case, the padding out to a multiple of 4 bytes does
not take a significant amount of space.

--Russ