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

970813: ncdump output order for fortran

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.


  • Subject: 970813: ncdump output order for fortran
  • Date: Wed, 13 Aug 97 11:07:50 -0600

Michael,

>Date: Wed, 13 Aug 1997 09:51:00 -0700 (PDT) 
>From: Michael Watts <address@hidden>
>Organization: NASA/ARC
>To: Steve Emmerson <address@hidden>
>Subject: Re: 970813: ncdump output order for fortran 
>Keywords: 199708121910.NAA09780

In the above message, you wrote:

> Steve,
> I miss typed I know that fortran is 1 and c is 0 and I meant to say
> (corrected Text)
> > If I use nc_get_var1 to get index (1,2,3) for a file written in c
> > I will get a different number than using nf_get_var1 with index(2,3,4).
> > I will get the value at index (4,3,2) [index in fortran].  This seems
> >counter to the concept
> > that netcdf if language dependent.  I should get the value at index slot
> >(2,3,4)
> > no mater which language I use to write or read. This is of course given
> >the correct index starts.

If the netCDF Fortran interface worked the way you described above,
then a Fortran user who read an entire netCDF array into memory would
find that array element (2,3,4) didn't map to netCDF variable element
(2,3,4).  This would require that the user manage two distinct sets of
indices and would, in our opinion, cause much unnecessary confusion.

> >A better way would say (offset 2 from start,
> >offset 3 from start, offset 4 from start)

Possibly, but Fortran doesn't do that, so neither does the netCDF
Fortran interface.

A netCDF dataset is language-independent: the same data will be seen
regardlesss of which language is used to access it.  The netCDF API for
a given language, however, is necessarily language-dependent, to do
otherwise would not be supporting that language.

--------
Steve Emmerson   <http://www.unidata.ucar.edu>