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

Re: 970127: records



>To: address@hidden
>From: address@hidden (Bjorn Stevens)
>Subject: records
>Organization: .
>Keywords: 199701271628.JAA22433

Hi Bjorn,

> Hi, I'm writing model generated output into netcdf files and I'm having
> some memory problems.  I thought you might be able to give some advice.
> 
> My situation is that I write three dimensional model fields at different
> times.  I thought to arrange this by defining 4D records in which the
> last dimension was unlimited, and corresponded to time.  Then at each
> consecutive time I would update the time index and write the new field.
> 
> Originally I was using the routine ncvpt, and assumed that the values 
> array was a pointer to the beginning location of the data and that the
> start and count integer arrays specified where in the netcdf file to
> write the data.  But it seems that the values array is supposed to be
> of the same dimensionality as the record which the values are being
> written to, in which it isn't obvious how to write a three dimensional
> field into a four dimensional array other than to write value by value
> using ncvpt1, which is what I am doing now.  Is this the most effecient
> approach?  It seems to really really bog down the cray, but it works ok
> on the workstation.

You should be able to write a whole 3-D array section with a single call
to ncvpt and update a single time in a 4-D variable.  The value array
need not be of the same dimensionality as the variable in the file, it
merely needs to have its values in the same order as they will be
written to the file.

You have to remember that ncdump (CDL) shows dimensions in C-order
(rightmost varying fastest) which is the opposite of Fortran order
(leftmost varying fastest).

For example, if you have a FORTRAN variable dimensioned like

  parameter (LON=360, LAT=180, LEVEL=20)
  real var(LON, LAT, LEVEL)

corresponding to a netCDF variable which ncdump shows is dimensioned
like

    dimensions:
      time = unlimited;
      level = 20;
      lat = 180;
      lon = 360;
    variables:
      float var(time, level, lat, lon);
     ...

then you can put a whole time's worth of data with a single call to
ncvpt:

    integer start(4), count(4)
    data start /1, 1, 1, 1/
    data count /1, LEVEL, LAT, LON/
      ...
    ! to write the nth time
    start(1) = n
    call ncvpt(ncid, varid, start, count, var, rcode)

I hope this example helps.

--Russ