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.
>To: address@hidden >From: Roy Deal <address@hidden> >Subject: extracting multi-dimensional variables >Organization: TASC >Keywords: 199707241326.HAA01589 Hi Roy, > I recently received a netCDF file with a set of variables > dimensioned like this: var(time, level, lat, lon), and I'm > having trouble extracting them from the file. When I do > an ncdump on the file the values look like this: var = > 25, -30, 30, 15, etc. > > I'm using ncvarget with start[] = {0, 0, 0, 0} and count[] > = {4, 1, 1, 1} with the intention of extracting the 4 > values listed in the previous paragraph, but when I print > the values out, only the first number agrees with those > listed above. Any idea what might be happening? Yes, ncdump prints the values in the order they are stored: var[0][0][0][0] var[0][0][0][1] var[0][0][0][2] ... var[0][0][1][0] var[0][0][1][1] var[0][0][1][2] ... If you use the "-b C" option to ncdump, it provides brief annotations as comments identifying which values it is printing. The "-f C" option provides full annotations of every value. If you want to get the values in the same order as ncdump presents them, with the right-most dimension varying fastest, use count[] = {1, 1, 1, 4}. --Russ _____________________________________________________________________ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu