> 07/22 David Simas -- "imap" argument of netCDF function "ncvargetg"
>
> ------------------------------------------------------------
>
> Subject: "imap" argument of netCDF function "ncvargetg"
> From: dsimas@xxxxxxxxxxxx (David Simas)
> Date: Thu, 22 Jul 93 11:53:44 PDT
>
> I'm using the function "ncvargetg" to read a two-dimensional array of
> variables from a netCDF file. Under certain circumstances, I'd like to
> invert th order of the columns and/or rows of that array. I assume that
> can be done by manipulating the "imap" argument
> to "ncvargetg", but I'm not sure how. Neither the netCDF manual's
> explanation of "imap" and "ncvargetg" nor the example of their
> use given there make any sense. If anyone knows how to use "ncvargetg"
> and "imap", I'd very much like to hear from him or her.
I also had trouble using ncvargetg & ncvarputg. There was a serious bug in
original release of version 2.3. This has now been fixed.
There were also errors in User's Guide. In examples on pages 87 & 101 the
final argument of final line (calling ncvarputg/ncvargetg) should be
(void *) &data[0][0][0].rh_val
rather than
(void *) data
The basic idea is that the address of element [ i[0], i[1], i[2], ... ]
is given by
value + imap[0] * i[0] + imap[1] * i[1] + imap[2] * i[2] + ...
Note that subscript i[d] takes the values
start[d]
start[d] + stride[d]
start[d] + 2 * stride[d]
...
start[d] + (count[d]-1) * stride[d]
I hope this is clear. If not I could provide an example showing how to
transpose a matrix. There is a need for such a simple example in the
User's Guide.
Harvey Davies,
CSIRO Division of Atmospheric Research, Voice: +61 3 586 7574
Private Bag No. 1, Mordialloc, Fax: +61 3 586 7600
Victoria 3195, Australia Internet: hld@xxxxxxxxxxxx