[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[netCDF #ZHC-323580]: creating x,y,z 3d volumes
- Subject: [netCDF #ZHC-323580]: creating x,y,z 3d volumes
- Date: Sat, 27 Jun 2009 09:45:40 -0600
Hi Louis,
> Description of problem: I would like to build up a 3D volume one layer at a
> time. Can I do it as follows?
> Using the C library.
>
> start[0] = 0; //time = unlimited
> start[1] = 0; // nlev
> start[2] = 0; // lat
> start[3] = 0; // lon
>
> end[0] = 1;
> end[1] = 0;
> end[2] = num_lat;
> end[3] = num_lon;
>
> lvl = 0;
> do
> {
> {read data}
> start[1] = lvl;
> end[1] = lvl;
> if ((erret = nc_put_vara_float(ncid, var_id, out_start, out_end, out_data)))
> errprt(prog, erret, "Cannot write data");
> lvl = lvl +1;
> }while ( lvl < num_lev);
No, because the argument you have called "out_end" is documented as
count
A vector of size_t integers specifying the edge lengths along each
dimension of the block of data values to be written. To write a
single value, for example, specify count as (1, 1, ... , 1). The
length of count is the number of dimensions of the specified
variable. The elements of count correspond to the variable's
dimensions. Hence, if the variable is a record variable, the first
element of count corresponds to a count of the number of records to
write.
Note: setting any element of the count array to zero causes the
function to exit without error, and without doing anything.
So you want to set
end[1] = 1;
and leave it unchanged from that value in your loop to write just
one level (and just one time) for each iteration of the loop. You may
also want to change the name of the variable from "end" to "count" or
something similar, to make the code easier to maintain.
Otherwise your code looks OK.
--Russ
Russ Rew UCAR Unidata Program
address@hidden http://www.unidata.ucar.edu
Ticket Details
===================
Ticket ID: ZHC-323580
Department: Support netCDF
Priority: Normal
Status: Closed