Last modified 10 years ago Last modified on 04/16/12 15:49:35

Current MOAB NetCDF reader, annotated version


Where all the magic happens

ErrorCode ReadNC::load_file(const char *file_name,
                            const EntityHandle* file_set,
                            const FileOptions& opts,
                            const ReaderIface::SubsetList* /*subset_list*/,
                            const Tag* file_id_tag)

Inside that routine:

Determine how many and which variables and time steps to read FOR THIS CALL (options set by MOAB user) NOTE: A generic NetCDF file may not have any timesteps.

 rval = parse_options(opts, var_names, tstep_nums, tstep_vals, nomesh, novars, partition_tag_name);

Open the file

 success = NCFUNC(open)(file_name, 0, &fileId);

Read the header.

   // Read the header (num dimensions, dimensions, num variables, global attribs)
  rval = read_header();

After this call, MOAB will know:

  1. The number of global attributes
  2. The names and values of all global attributes
  3. The number of dimensions
  4. The names and lengths of all dimensions (e.g. lon =128, lat = 64)
  5. The number of variables
  6. For each variable: how many dimensions it has, the dim_id of each, the number of attributes, the name and value of each attribute

NOTE: It also checks for the "time" variable. Need to remove that from "read_variables" to make it more generic.

Figure out how big the ijkt space is for this file.

    // Get bounds on ijk space
  rval = init_ijkt_vals(opts, scdi);

Inside init_ijkt_vals:

Get the size of the lat,lon,lev box.  Set gDims
search for dimension names:  lat, lon, x, x1, y, y1, lev,z,time,t   error if you don't find a lat,lon or time coor.  No z is ok.
(Only searches for one x, one y, and one z.  Doesn't allow for staggered grids or interface and midpoint levels)
Compute the partition.  Set values of lDims
Override lDims is use provides partition.
call read_coordinate to load in actual lat, lon and lev and time coordinate values.

If init_ijkt_vals failed, call the unstructured version init_ucd_mesh (current not a working code)

If one of the above worked and nomesh is set, call check_verts_hexes which checks the current lDims against the ones already defined in a mesh.

If nomesh is NOT set, define a mesh with create_ucd_vert_hexes for unstructures or create_verts_hexes for structured.

read_variables on to the grid


close file