function netcdf_mpas_report ( filename )

%*****************************************************************************80
%
%% NETCDF_MPAS_REPORT reads an MPAS NETCDF grid file and reports.
%
%  Discussion:
%
%    In this example, we want to extract all the information from a file
%    of unknown type.
%
%    Here, we are pretending we have no idea what's in the file, so we
%    have to go step by step, making inquiries to NETCDF.
%
%    As we go, we print out what we have discovered.  We don't attempt
%    to return any of the data.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    30 December 2010
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Russ Rew, Glenn Davis, Steve Emmerson, Harvey Davies, Ed Hartne,
%    The NETCDF User's Guide,
%    Unidata Program Center, March 2009.
%
%  Parameters:
%
%    Input, string FILENAME, the name of the NETCDF file to examine.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'NETCDF_MPAS_REPORT:\n' );
  fprintf ( 1, '  Report the information stored in a NETCDF\n' );
  fprintf ( 1, '  file.  Although we wish to examine a file containing\n' );
  fprintf ( 1, '  grid data generated by MPAS, we will assume we do not\n' );
  fprintf ( 1, '  have any idea of what is in the file.  So we just read,\n' );
  fprintf ( 1, '  inquire, and print out.\n' );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  The name of the file is "%s"\n', filename );
%
%  Open the file.
%
  ncid = netcdf.open ( filename, 'NOWRITE' );
%
%  Return information about the NETCDF file.
%
  [ ndims, nvars, ngatts, unlimdimid ] = netcdf.inq ( ncid );

  fprintf ( 1, '\n' );
  fprintf ( 1, 'PRIMARY PARAMETERS:\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  The number of dimensions         NDIMS      = %d\n', ndims );
  fprintf ( 1, '  The number of variables          NVARS      = %d\n', nvars );
  fprintf ( 1, '  The number of global attributes  NGATTS     = %d\n', ngatts );
  fprintf ( 1, '  The unlimited dimension (if any) UNLIMDIMID = %d\n', unlimdimid );
%
%  Retrieve global attributes.
%  First, we must evaluate the constant "NC_GLOBAL".
%
  nc_global = netcdf.getConstant ( 'NC_GLOBAL' );

  fprintf ( 1, '\n' );
  fprintf ( 1, 'GLOBAL ATTRIBUTES:\n' );
  fprintf ( 1, ' Att  --------Name--------  Type   Len\n' );
  fprintf ( 1, '\n' );
  for att = 0 : ngatts - 1
    name = netcdf.inqAttName ( ncid, nc_global, att );
    global_attname{att+1} = name;
    [ xtype, leng ] = netcdf.inqAtt ( ncid, nc_global, name );
    global_atttype(att+1) = xtype;
    global_attlen(att+1) = leng;
    fprintf ( 1, '  %2d  "%18s"    %2d    %2d\n', att, ...
      global_attname{att+1}, global_atttype(att+1), global_attlen(att+1) );
  end
%
%  Determine names and extents of dimensions.
%  Since each NAME is a char array, we make a cell array to hold them.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'DIMENSIONS:\n' );
  fprintf ( 1, ' Dim  --------Name--------  Extent\n' );
  fprintf ( 1, '\n' );

  dimname = cell ( ndims, 1 );
  dimlen = zeros ( ndims, 1 );

  for dim = 0 : ndims - 1
    [ name, len ] = netcdf.inqdim ( ncid, dim );
    dimname{dim+1} = name;
    dimlen(dim+1) = len;
    if ( dim ~= unlimdimid )
      fprintf ( 1, '  %2d  "%18s"  %6d            \n', dim, dimname{dim+1}, dimlen(dim+1) );
    else
      fprintf ( 1, '  %2d  "%18s"  %6d (unlimited)\n', dim, dimname{dim+1}, dimlen(dim+1) );
    end
  end
%
%  Get variable names, types, dimensions, number of attributes.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'VARIABLES:\n' );
  fprintf ( 1, ' Var  --------Name--------  Type Natts NdimsDim1Dim2Dim3Dim4\n' );
  fprintf ( 1, '\n' );

  for var = 0 : nvars - 1
    [ name, xtype, dimids, natts ] = netcdf.inqVar ( ncid, var );
    varname{var+1} = name;
    vartype(var+1) = xtype;
    vardimids{var+1} = dimids;
    varnatts(var+1) = natts;
    k = length ( dimids );
    fprintf ( 1, '  %2d  "%18s"  %4d  %4d  %4d', ...
      var, varname{var+1}, vartype(var+1), varnatts(var+1), k );
    for i = 1 : k
      fprintf ( 1, '  %2d', vardimids{var+1}(i) );
    end
    for i = k + 1 : 4
      fprintf ( 1, '    ' );
    end
    fprintf ( 1, '\n' );
  end
%
%  Close the file.
%
  netcdf.close ( ncid );

  return
end
