This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Sue, For 1- to 5-dimensional arrays, you can use the get method with the appropriate number of edge-length arguments to match the dimensionality of the netCDF variable. But for any shape of array, you can also use the more general get() method that has an array of edge-lengths instead of one for each dimension. So instead of var->get(vals, dim1, dim2 ) for a 2-dimensional array and var->get(vals, dim1, dim2, dim3 ) for a 3-dimensional array, you can use the more general var->get(vals, dims) for an n-dimensional array, where dims is an array of the dimension edge-lengths desired. > I want to confirm that var->get(vals, 0, 0, dim1 , dim2) will fail to > get the data properly. If you try to specify more dimensions than the variable has, such as using the above call for a 2-dimensional netCDF variable, you should get an error from the library. Are you checking the return value from the get() method call? If it's returning true in this case, that's a bug we should fix. > This means if you are a client parsing possibly 2D,3D, 4D etc data, > you need to create a different get call for each case instead of > having one get call with the various edge lengths equal to zero in > the case of data with fewer dimensions. This is what I am seeing. No, you can use the overloaded n-dimensional version of the call for all cases instead of the calls that assume a specific number of dimensions. --Russ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: OAZ-263489 Department: Support netCDF Priority: Normal Status: Closed