<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7652.24">
<TITLE>Parallel netcdf and multi-dimensioned fields</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P><FONT FACE="Arial">Hello,</FONT>
</P>
<P><FONT FACE="Arial">I'm experiencing some difficulty storing data in fields defined with 3 dimensions:</FONT>
</P>
<P><FONT FACE="Arial">Here is a sample of how "ncdump" presents the definition of the file structure in my example:</FONT>
</P>
<P><FONT FACE="Arial">netcdf gatm_y000001.g3 {</FONT>
<BR><FONT FACE="Arial">dimensions:</FONT>
<BR><FONT FACE="Arial"> time = UNLIMITED ; // (0 currently)</FONT>
<BR><FONT FACE="Arial"> char_len = 10 ;</FONT>
<BR><FONT FACE="Arial"> grid_cells = 2562 ;</FONT>
<BR><FONT FACE="Arial"> grid_size = 2562 ;</FONT>
<BR><FONT FACE="Arial"> grid_corners = 6 ;</FONT>
<BR><FONT FACE="Arial"> grid_rank = 1 ;</FONT>
<BR><FONT FACE="Arial"> level = 21 ;</FONT>
<BR><FONT FACE="Arial">variables:</FONT>
<BR><FONT FACE="Arial"> double time(time) ;</FONT>
<BR><FONT FACE="Arial"> time:quantity = "time" ;</FONT>
<BR><FONT FACE="Arial"> time:units = "days since 1-1-1" ;</FONT>
<BR><FONT FACE="Arial"> time:calendar = "noleap" ;</FONT>
<BR><FONT FACE="Arial"> char char_time(time, char_len) ;</FONT>
<BR><FONT FACE="Arial"> char_time:format = "mm/dd/yyyy" ;</FONT>
<BR><FONT FACE="Arial"> double start_period(time) ;</FONT>
<BR><FONT FACE="Arial"> start_period:long_name = "start of averaged period" ;</FONT>
<BR><FONT FACE="Arial"> start_period:units = "days since 1-1-1" ;</FONT>
<BR><FONT FACE="Arial"> double end_period(time) ;</FONT>
<BR><FONT FACE="Arial"> end_period:long_name = "end of averaged period" ;</FONT>
<BR><FONT FACE="Arial"> end_period:units = "days since 1-1-1" ;</FONT>
<BR><FONT FACE="Arial"> double period_length(time) ;</FONT>
<BR><FONT FACE="Arial"> period_length:long_name = "length of averaged period" ;</FONT>
<BR><FONT FACE="Arial"> period_length:units = "days" ;</FONT>
<BR><FONT FACE="Arial"> double grid_center_lat(grid_cells) ;</FONT>
<BR><FONT FACE="Arial"> grid_center_lat:units = "radians" ;</FONT>
<BR><FONT FACE="Arial"> double grid_center_lon(grid_cells) ;</FONT>
<BR><FONT FACE="Arial"> grid_center_lon:units = "radians" ;</FONT>
<BR><FONT FACE="Arial"> double grid_area(grid_cells) ;</FONT>
<BR><FONT FACE="Arial"> grid_area:units = "square radians" ;</FONT>
<BR><FONT FACE="Arial"> int grid_dims(grid_rank) ;</FONT>
<BR><FONT FACE="Arial"> double grid_corner_lat(grid_cells, grid_corners) ;</FONT>
<BR><FONT FACE="Arial"> grid_corner_lat:units = "radians" ;</FONT>
<BR><FONT FACE="Arial"> double grid_corner_lon(grid_cells, grid_corners) ;</FONT>
<BR><FONT FACE="Arial"> grid_corner_lon:units = "radians" ;</FONT>
<BR><FONT FACE="Arial"> float level(level) ;</FONT>
<BR><FONT FACE="Arial"> float mask(time, level, grid_cells) ;</FONT>
<BR><FONT FACE="Arial"> mask:long_name = "fraction of time pressure surface is above earths surface" ;</FONT>
<BR><FONT FACE="Arial"> mask:units = "-" ;</FONT>
<BR><FONT FACE="Arial"> mask:type = "dyn" ;</FONT>
<BR><FONT FACE="Arial"> mask:positions = "center" ;</FONT>
<BR><FONT FACE="Arial"> mask:missing_value = 1.e+36f ;</FONT>
</P>
<BR>
<P><FONT FACE="Arial">NOTE: I'm creating the file using Fortran 90.</FONT>
</P>
<P><FONT FACE="Arial">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.)</FONT></P>
<P><FONT FACE="Arial">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:</FONT></P>
<P><FONT FACE="Arial"> dim_id(1) = lon_id</FONT>
<BR><FONT FACE="Arial"> dim_id(2) = lat_id</FONT>
<BR><FONT FACE="Arial"> dim_id(3) = lev_id</FONT>
</P>
<P><FONT FACE="Arial">! ==================</FONT>
<BR><FONT FACE="Arial"> ierr = Nfmpi_Def_Var</FONT>
<BR><FONT FACE="Arial">! ==================</FONT>
<BR><FONT FACE="Arial"> & (ncid, "tt", NF_REAL, 3, dim_id, tt_id)</FONT>
</P>
<P><FONT FACE="Arial">This order (lon_id, lat_id, lev_id) matches the structure of the file, as shown in the ncdump output:</FONT>
</P>
<P><FONT FACE="Arial">netcdf pnf_test {</FONT>
<BR><FONT FACE="Arial">dimensions:</FONT>
<BR><FONT FACE="Arial"> level = 256 ;</FONT>
<BR><FONT FACE="Arial"> latitude = 256 ;</FONT>
<BR><FONT FACE="Arial"> longitude = 256 ;</FONT>
<BR><FONT FACE="Arial">variables:</FONT>
<BR><FONT FACE="Arial"> float tt(longitude, latitude, level) ;</FONT>
<BR><FONT FACE="Arial">data:</FONT>
</P>
<P><FONT FACE="Arial">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.</FONT></P>
<BR>
<P><FONT FACE="Arial">Annette Koontz</FONT>
<BR><FONT FACE="Arial">PNNL</FONT>
</P>
<BR>
</BODY>
</HTML>