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.
Michael, >Date: Wed, 13 Aug 1997 07:51:43 -0700 (PDT) >From: Michael Watts <address@hidden> >Organization: NASA/ARC >To: Steve Emmerson <address@hidden> >Subject: Re: 970812: ncdump output order for fortran >Keywords: 199708121910.NAA09780 In the above message, you wrote: > Steve, > The -b option doesnt change the indice order in the ncdump. Odd. The "-b" option of ncdump(1) changes the indicial order here: $ ncdump -b c orig_ran_test.cdf netcdf orig_ran_test { dimensions: slowdim = 9 ; fastdim = 5 ; variables: float fastdim(fastdim) ; float slowdim(slowdim) ; float var(slowdim, fastdim) ; float var_err(slowdim, fastdim) ; float var_df(slowdim, fastdim) ; data: fastdim = 1, 3, 5, 7, 9 ; slowdim = 1, 2, 3, 4, 5, 6, 7, 8, 9 ; var = // var(0, 0-4) 0.158555, 0.03966331, -0.02857685, -0.03354263, -0.4338837, // var(1, 0-4) 0.1449776, -0.1225681, 0.2001286, -0.04925156, 0.1827717, // var(2, 0-4) -0.2215099, 0.1867104, 0.04201126, 0.03138351, 0.1927376, // var(3, 0-4) 0.07765579, 0.05680466, -0.271843, -0.06489563, -0.460289, // var(4, 0-4) 0.2102165, -0.322094, 0.3012428, 0.3301468, 0.2914734, // var(5, 0-4) 0.4745178, 0.3388901, -0.2899094, 0.1367798, -0.09538269, // var(6, 0-4) -0.3151398, -0.3511429, -0.1248245, 0.05485535, 0.3989182, // var(7, 0-4) 0.1310806, -0.1886063, 0.300766, 0.06666565, -0.2103958, // var(8, 0-4) -0.07046509, 0.04106903, -0.04706573, -0.0001678467, -0.09223938 ; ... } Note that the first line of the "var" data is indexed (0, 0-4). $ ncdump -b f orig_ran_test.cdf netcdf orig_ran_test { dimensions: slowdim = 9 ; fastdim = 5 ; variables: float fastdim(fastdim) ; float slowdim(slowdim) ; float var(slowdim, fastdim) ; float var_err(slowdim, fastdim) ; float var_df(slowdim, fastdim) ; data: fastdim = 1, 3, 5, 7, 9 ; slowdim = 1, 2, 3, 4, 5, 6, 7, 8, 9 ; var = // var(1-5 ,1) 0.158555, 0.03966331, -0.02857685, -0.03354263, -0.4338837, // var(1-5 ,2) 0.1449776, -0.1225681, 0.2001286, -0.04925156, 0.1827717, // var(1-5 ,3) -0.2215099, 0.1867104, 0.04201126, 0.03138351, 0.1927376, // var(1-5 ,4) 0.07765579, 0.05680466, -0.271843, -0.06489563, -0.460289, // var(1-5 ,5) 0.2102165, -0.322094, 0.3012428, 0.3301468, 0.2914734, // var(1-5 ,6) 0.4745178, 0.3388901, -0.2899094, 0.1367798, -0.09538269, // var(1-5 ,7) -0.3151398, -0.3511429, -0.1248245, 0.05485535, 0.3989182, // var(1-5 ,8) 0.1310806, -0.1886063, 0.300766, 0.06666565, -0.2103958, // var(1-5 ,9) -0.07046509, 0.04106903, -0.04706573, -0.0001678467, -0.09223938 ; ... } Note that the first line of the "var" data is indexed (1-5 ,1) and not (0, 0-4). > Thus the > confusion still reigns. If it was written in c and read in fortran but > ncdump doesnt indicate a change of order with the flags and you do not know > which language it was written in then how do you know the order of the > indeces to use using ncdump without doing the dim order from within the > program? Could you be confusing "indicial order" with the order in which the elements are stored? The storage order of the elements of an array is language-independent: the "inner" dimension is always the most rapidly varying one; the "outer" dimension is always the most slowly varying one. The C and Fortran languages have different representations for the "inner" and "outer" dimensions but the netCDF package always stores the data with the "inner" dimension varying most rapidly. -------- Steve Emmerson <http://www.unidata.ucar.edu>