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

19981214: Re: Simple NETCDF question: order of dimensions



Hi Kevin!

>Date: Mon, 14 Dec 1998 16:22:58 -0500
>From: address@hidden
>Organization: Nova University
>To: address@hidden
>Subject: Simple NETCDF question
>Keywords: 199812142123.OAA00938

In the above message, you wrote:

> I have a very simple question regarding the dimension
> order of netcdf variables.
> 
> Suppose I have a netcdf dataset with the following
> attributes:
> 
> netcdf togaVelocity {
> dimensions:
>         time = 12846 ;
>         depth = 25 ;
>         lat = 1 ;
>         lon = 1 ;
> variables:
>         float lon(lon) ;
>                 lon:units = "degrees" ;
>                 lon:epic_code = 501 ;
>         float lat(lat) ;
>                 lat:units = "degrees" ;
>                 lat:epic_code = 500 ;
>         float depth(depth) ;
>                 depth:units = "meters" ;
>                 depth:epic_code = 3 ;
>         int time(time) ;
>                 time:units = "days" ;
>                 time:epic_code = 624 ;
>                 time:reset_yr = 1992 ;
>                 time:reset_mo = 10 ;
>                 time:reset_da = 21 ;
>                 time:reset_hr = 4s ;
>                 time:reset_mn = 31s ;
>                 time:reset_sc = 53s ;
>                 time:rec_period = 900.f ;
>         int time2(time) ;
>                 time2:units = "milliseconds" ;
>                 time2:epic_code = 624 ;
>         float u(time, depth, lat, lon) ;
>                 u:long_name = "east current" ;
>                 u:units = "cm/s" ;
>         float v(time, depth, lat, lon) ;
>                 v:long_name = "north current" ;
>                 v:units = "cm/s" ;
> 
> // global attributes:
>                 :comments = "TOGA COARE WHOI mooring - 
> velocity" ;
>                 :compliance = "EPIC" ;
>                 :experiment = "TOGA/COARE" ;
>                 :platform = "Mooring 933" ;
>                 :instrument_type = "VMCM to 54.79m, ADCP 
> from 70.79 to 340.5" ;
> data:
> 
>  lon = 155.9945 ;
> 
>  lat = -1.75554 ;
> 
>  depth = 7.44, 11.19, 15.26, 19.3, 33.79, 41.79, 54.79, 
> 70.79, 86.79, 102.79,
>     118.79, 134.79, 150.79, 166.79, 182.79, 198.79, 
> 214.79, 230.79, 246.79,
>     262.79, 278.79, 294.79, 310.79, 326.79, 340.5 ;
> 
> <rest of output snipped>
> 
> My question is since no dimension is specified 
> as unlimited, are the arrays u and v stored such that
> their dimensions vary as they would normally in 
> Fortran, i.e. time varies most quickly? That is, 
> would I write a reading program specifying 
> u(time,depth,lat,lon)?

No.  The specifiers of the netCDF API were/are C programmers;
consequently, the leftmost dimension of a variable in the CDL file is the
grossest dimension and the rightmost dimension in the CDL file is the
finest.

> 
> The motivation for my question is found on page 18 of
> the NETCDF User's Guide for Fortran, which gives an
> example of an array temp(time,level,lat,lon), where
> time is specified as unlimited. It then states that
> the Fortran dimension specifications are reversed from
> the CDL declaration, and that a Fortran reading 
> program would have temp(lons,lats,levels,times). Are
> the dimensions reversed only because time is 
> specified as unlimited?

The "shape" of a netCDF variable is specified in the netCDF API by a
vector of dimension indexes.  In C, the first element of the vector
specifies the grossest dimension.  In Fortran, the first element of the
vector specifies the finest dimension.  In either case, the order of the
shape vector matches the left-to-right order of the dimensions as they
are commonly understood by the Language.

The CDL convention follows the C ordering rather than the Fortran.

If this doesn't clarify the issue, please feel free to ask more questions.

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