function [nc_info] = read_nc_info(fileName,dataDir);
%Look at contents of an netCDF file and create a structure with some basic information
 
nc_info=[];

fName = [dataDir fileName];
if(~exist(fName));
   fName=[fName '.nc'];
   if(~exist(fName));
      error(['read_nc_info ERROR: file not found in ' dataDir]);
   end;
end;

ncid = netcdf.open(fName);
[ndims,nvars,ngatts,unlimdimid] = netcdf.inq(ncid);

%Dimensions
for ii=1:ndims;
   [dimname, dimlen] = netcdf.inqDim(ncid,ii-1);
   dimi(ii) = ii-1;
   dimn{ii}=dimname;
   dims(ii)=dimlen;
end

%Variables
for ii=1:nvars;
   [varname,xtype,dimids,natts] = netcdf.inqVar(ncid,ii-1);
   vari(ii) = ii-1;
   varn{ii}=varname;
   vard{ii}=dims(dimids+1);
end

for ii=1:nvars;
   attname = netcdf.inqAttName(ncid,ii-1,0); longName{ii} = netcdf.getAtt(ncid,ii-1,attname); 
   attname = netcdf.inqAttName(ncid,ii-1,1); units{ii} = netcdf.getAtt(ncid,ii-1,attname); 
end;

%Global attributes
for ii=1:ngatts
   gattname{ii} = netcdf.inqAttName(ncid,netcdf.getConstant('NC_GLOBAL'),ii-1);
   gattval{ii}  = netcdf.getAtt(ncid,netcdf.getConstant('NC_GLOBAL'),gattname{ii});
end;

%Close file
netcdf.close(ncid);
nc_info.file  = fName;
nc_info.ndims = ndims;
nc_info.dimName  = dimn;
nc_info.dimID  = dimi;
nc_info.dimSize  = dims;
nc_info.nvars = nvars;
nc_info.varName  = varn;
nc_info.varID  = vari;
nc_info.varSize  = vard;
nc_info.ngatts = ngatts;
nc_info.gattsName = gattname;
nc_info.unlimdimid = unlimdimid;





