}
}
}
// generate it and save it
GridDataset gds = null;
try {
if (ncml == null) {
gds = GridDataset.open( mfile.getPath());
} else {
NetcdfFile nc = NetcdfDataset.acquireFile(mfile.getPath(), null);
NetcdfDataset ncd = NcMLReader.mergeNcML(nc, ncml); // create new dataset
ncd.enhance(); // now that the ncml is added, enhance "in place", ie modify the NetcdfDataset
gds = new GridDataset(ncd);
}
// System.out.println("gds dataset= "+ gds.getNetcdfDataset());
GridDatasetInv inv = new GridDatasetInv(gds, cm.extractRunDate(mfile));
String xmlString = inv.writeXML( new Date(mfile.getLastModified()));
cm.putMetadata(mfile, "fmrInv.xml", xmlString.getBytes("UTF-8"));
if (log.isDebugEnabled()) log.debug(" added xmlFile "+ mfile.getPath()+".fmrInv.xml to cache");
if (debug) System.out.printf(" added xmlFile %s.fmrInv.xml to cache%n", mfile.getPath());
// System.out.println("new xmlBytes= "+ xmlString);
return inv;
} finally {
if (gds != null) gds.close();
}
}