/** * Sync the file * * @return true if needed to sync * @throws IOException problem synching the file */ public boolean sync() throws IOException { // printStack("***************************** sync ************************", 100); // System.out.printf("check sync on %s (%s) %n", raf.getLocation(), // Calendar.getInstance().getTime()); if (gemreader.getInitFileSize() < raf.length()) { long start = System.currentTimeMillis(); Trace.msg( "GEMPAKStationIOSP.sync: file " + raf.getLocation() + " is bigger: " + raf.length() + " > " + gemreader.getInitFileSize()); Trace.call1("GEMPAKStationIOSP.sync: reader.init"); gemreader.init(raf, true); Trace.call2("GEMPAKStationIOSP.sync: reader.init"); Trace.call1("GEMPAKStationIOSP.sync: buildNCFile"); // reconstruct the ncfile objects buildNCFile(); Trace.call2("GEMPAKSIOSP.sync: buildNCFile"); // System.out.printf("sync on %s took %d msecs%n", raf.getLocation(), // (System.currentTimeMillis()-start)); return true; } return false; }
/** * Build the netCDF file * * @throws IOException problem reading the file */ protected void buildNCFile() throws IOException { Trace.call1("GEMPAKSIOSP: buildNCFile"); ncfile.empty(); fillNCFile(); addGlobalAttributes(); ncfile.finish(); Trace.call2("GEMPAKSIOSP: buildNCFile"); // System.out.println(ncfile); }
/** * Open the service provider for reading. * * @param raf file to read from * @param ncfile netCDF file we are writing to (memory) * @param cancelTask task for cancelling * @throws IOException problem reading file */ public void open(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask) throws IOException { // System.out.printf("GempakSurfaceIOSP open %s (%s) %n", raf.getLocation(), // Calendar.getInstance().getTime()); this.raf = raf; this.ncfile = ncfile; long start = System.currentTimeMillis(); if (gemreader == null) { gemreader = makeStationReader(); } Trace.call1("GEMPAKStationIOSP.open: initTables"); initTables(); Trace.call2("GEMPAKStationIOSP.open: initTables"); Trace.call1("GEMPAKStationIOSP.open: reader.init"); gemreader.init(raf, true); Trace.call2("GEMPAKStationIOSP.open: reader.init"); buildNCFile(); }
/** * Is this a valid file? * * @param raf RandomAccessFile to check * @return true if a valid Gempak grid file * @throws IOException problem reading file */ public boolean isValidFile(RandomAccessFile raf) throws IOException { try { gemreader = makeStationReader(); Trace.call1("GEMPAKSIOSP.isValidFile: reader.init"); gemreader.init(raf, false); Trace.call2("GEMPAKSIOSP.isValidFile: reader.init"); } catch (Exception ioe) { return false; } return true; }