This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Heiko Klein wrote:
192050 I just found the problem, and it was in my own source: My copy function did the following: List<Variable> variables = ncIn.getRootGroup().getVariables(); for (Variable var : variables) { // copy dims and attributes ncOut.addVariable(ncOut.getRootGroup(), var); } ncOut.create(); for (Variable var : variables) { try { ncOut.write(var.getName(), var.read()); } catch (InvalidRangeException ire) { throw new IOException(ire.toString()); } } ncOut.flush(); The line 'ncOut.addVariable(ncOut.getRootGroup(), var)' modified the variable which got read afterwards. Modifying this line to Variable outVar = new Variable(var); ncOut.getRootGroup().addVariable(outVar); solved the problem. Sorry for bothering you with a self-generated error. Best regards
No problem. You may want to look at or use ucar.nc2.FileWriter.java for these purposes. John