public void writeRecord(String stnName, Date obsDate, StructureData sdata) throws IOException { StationTracker stnTracker = stationMap.get(stnName); ProfileTracker proTracker = stnTracker.profileMap.get(obsDate); if (proTracker == null) { proTracker = new ProfileTracker(profileIndex); stnTracker.profileMap.put(obsDate, proTracker); stnTracker.link.add(profileIndex); stnTracker.lastChild = profileIndex; stnTracker.numChildren++; try { originTime[0] = profileIndex; // 2d index timeArray.set(0, dateFormatter.toDateTimeStringISO(obsDate)); parentArray.set(0, stnTracker.parent_index); ncfile.writeStringData(timeName, originTime, timeArray); ncfile.write(parentStationIndex, originTime, parentArray); } catch (InvalidRangeException e) { e.printStackTrace(); throw new IllegalStateException(e); } profileIndex++; } // needs to be wrapped as an ArrayStructure, even though we are only writing one at a time. ArrayStructureW sArray = new ArrayStructureW(sdata.getStructureMembers(), new int[] {1}); sArray.setStructureData(sdata, 0); // track the min and max date if ((minDate == null) || minDate.after(obsDate)) minDate = obsDate; if ((maxDate == null) || maxDate.before(obsDate)) maxDate = obsDate; timeArray.set(0, dateFormatter.toDateTimeStringISO(obsDate)); parentArray.set(0, proTracker.parent_index); proTracker.link.add(recno); proTracker.lastChild = recno; // not currently used proTracker.numChildren++; // write the recno record origin[0] = recno; // 1d index originTime[0] = recno; // 2d index try { ncfile.write("record", origin, sArray); ncfile.write(parentProfileIndex, originTime, parentArray); } catch (InvalidRangeException e) { e.printStackTrace(); throw new IllegalStateException(e); } recno++; }