Parallel netcdf and multi-dimensioned fields

Koontz, Annette S Annette.Koontz at pnl.gov
Wed Aug 1 15:38:34 CDT 2007


Hello,

I'm experiencing some difficulty storing data in fields defined with 3
dimensions:

Here is a sample of how "ncdump" presents the definition of the file
structure in my example:

netcdf gatm_y000001.g3 {
dimensions:
        time = UNLIMITED ; // (0 currently)
        char_len = 10 ;
        grid_cells = 2562 ;
        grid_size = 2562 ;
        grid_corners = 6 ;
        grid_rank = 1 ;
        level = 21 ;
variables:
        double time(time) ;
                time:quantity = "time" ;
                time:units = "days since 1-1-1" ;
                time:calendar = "noleap" ;
        char char_time(time, char_len) ;
                char_time:format = "mm/dd/yyyy" ;
        double start_period(time) ;
                start_period:long_name = "start of averaged period" ;
                start_period:units = "days since 1-1-1" ;
        double end_period(time) ;
                end_period:long_name = "end of averaged period" ;
                end_period:units = "days since 1-1-1" ;
        double period_length(time) ;
                period_length:long_name = "length of averaged period" ;
                period_length:units = "days" ;
        double grid_center_lat(grid_cells) ;
                grid_center_lat:units = "radians" ;
        double grid_center_lon(grid_cells) ;
                grid_center_lon:units = "radians" ;
        double grid_area(grid_cells) ;
                grid_area:units = "square radians" ;
        int grid_dims(grid_rank) ;
        double grid_corner_lat(grid_cells, grid_corners) ;
                grid_corner_lat:units = "radians" ;
        double grid_corner_lon(grid_cells, grid_corners) ;
                grid_corner_lon:units = "radians" ;
        float level(level) ;
        float mask(time, level, grid_cells) ;
                mask:long_name = "fraction of time pressure surface is
above earths surface" ;
                mask:units = "-" ;
                mask:type = "dyn" ;
                mask:positions = "center" ;
                mask:missing_value = 1.e+36f ;


NOTE: I'm creating the file using Fortran 90.

In plain netcdf (Fortran) code, I seem to recall that you have to
specify the dimensions in reverse order. That is, when specifying the
dimension order to define the 3d field, one would specify "celldim,
leveldim, timedim", not the expected "timedim, leveldim, celldim". (This
has always annoyed about the netcdf Fortran interface.)

In a piece of test software provided with parallel netcdf, it looks like
this bit of confusion has been eliminated. That is, in pnf_test.F, the
logic to define the 3d field is:

        dim_id(1) = lon_id
        dim_id(2) = lat_id
        dim_id(3) = lev_id

!       ==================
        ierr = Nfmpi_Def_Var
!       ==================
     &    (ncid, "tt", NF_REAL, 3, dim_id, tt_id)

This order (lon_id, lat_id, lev_id) matches the structure of the file,
as shown in the ncdump output:

netcdf pnf_test {
dimensions:
        level = 256 ;
        latitude = 256 ;
        longitude = 256 ;
variables:
        float tt(longitude, latitude, level) ;
data:

I am just verifying that the fortran interface to define a
multi-dimensional field in parallel netcdf uses the C order, not the
Fortran order. I am having some difficulty either creating or putting
data into a 3d field, and I want to make sure I understand the Fortran
API.


Annette Koontz
PNNL


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/parallel-netcdf/attachments/20070801/56e0f3b6/attachment.htm>


More information about the parallel-netcdf mailing list