[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDFJava #SXF-400193]: NetcdfFileWriter's global Attributes

Hi Jin,

I'm a little bit mystified. Looks like sometimes the code you posted doesn't 
really match the errors you report.
I tried to reproduce your error and from the notes you sent and wrote a really 
simple program that works just fine:

        NetcdfFileWriter writer = NetcdfFileWriter.createNew(Version.netcdf4, 
        Dimension time = writer.addDimension(null, "time", 5);          
        Dimension lat = writer.addDimension(null, "latitude", 64);
        Dimension lon = writer.addDimension(null, "longitude", 64);
        List<Dimension> dims = new ArrayList<>();
        Variable vTime = writer.addVariable(null,"time", DataType.DOUBLE, 
        Variable vlat = writer.addVariable(null, "latitude", DataType.DOUBLE, 
        Variable vlon = writer.addVariable(null, "longitude", DataType.DOUBLE, 
        Variable bar = writer.addVariable(null, "bar", DataType.INT, dims);
        bar.addAttribute(new Attribute("_FillValue", 0));               
        Array tar = Array.factory(DataType.DOUBLE , new int[] { 5 } );          
        Array ar = Array.factory(DataType.INT , new int[] { 5, 64, 64} );
        writer.write(writer.findVariable("time"), new int[] {0}, tar );
        writer.write(writer.findVariable("bar"), new int[]  {0, 0, 0 }, ar );

So probably I need some more accuracy in your description and it'd be great if 
you could do some more debugging work checking that when you create the 
variables using the NetcdfFileWriter.addVariable method, the variable object 
you get does not have the spiObject initialized (that's a private property in 
the Variable class that you should be able to see from your debugger) then, 
after calling the NetcdfFileWriter.create() method all the variables that were 
added to the file should have the spiObject initialized.
From this point watch closely those spiObjects to see if somehow they are set 
to null and finally when you write the variables, the variable you get from the 
method NetcdfFileWriter.findVariable is the exactly same object you got when 
you added the variable using the NetcdfFileWriter.addVariable method. 
Also, make sure all the variables were added to the file using the 
NetcdfFileWriter.addVariable method before calling the NetcdfFileWriter.create 

Ticket Details
Ticket ID: SXF-400193
Department: Support netCDF Java
Priority: Normal
Status: Open