assertTrue( "Couldn't open file <" + testDataFileOut + ">: " + e.getMessage(),
false );
return;
}
Dimension timeDim = ncf.getRootGroup().findDimension( "time");
int timeDimSize = timeDim.getLength();
Variable timeVar = ncf.getRootGroup().findVariable( "time");
Variable latVar = ncf.getRootGroup().findVariable( "latitude");
Variable lonVar = ncf.getRootGroup().findVariable( "longitude");
Variable altVar = ncf.getRootGroup().findVariable( "altitude");
Attribute timeUnits = timeVar.findAttribute( "units");
String newUnits = "test unit string";
System.out.println( "Switching time units from \"" + timeUnits.toString() + " \" to \"" + newUnits + "\"" );
timeVar.addAttribute( new Attribute( "units", newUnits) );
Array latArray;
try
{
latArray = latVar.read();
}
catch ( IOException e )
{
assertTrue( "Couldn't read latitude data: " + e.getMessage(),
false );
return;
}
try { Thread.sleep( 5000);
}
catch ( InterruptedException e ) {
}
boolean extended;
try
{
extended = ncf.syncExtend();
}
catch ( IOException e )
{
assertTrue( "Couldn't syncExtend() file <" + testDataFileOut + ">: " + e.getMessage(),
false );
return;
}
if ( ! extended )
{
System.out.println( "Did not extend file <" + testDataFileOut + ">." );
}
Dimension timeDim2 = ncf.getRootGroup().findDimension( "time");
if ( timeDim == timeDim2 )
System.out.println( "Time dimension the same." );
else
System.out.println( "Time dimension not the same." );
System.out.println( "Initial time dim size = " + timeDimSize );
System.out.println( "New time dim size = " + timeDim2.getLength() );
System.out.println( "New time dim size (1) = " + timeDim.getLength() );
System.out.println( "Time var units string: " + timeVar.findAttribute( "units").toString() );
if ( latVar == ncf.getRootGroup().findVariable( "latitude"))