Re: [netcdf-java] How to create a structure in netcdf4

Hi Jose, what version of netcdf-java and netcdf C libraries are you using?
John

On Wed, Nov 4, 2015 at 12:54 AM, José Évora <jose.evora@xxxxxxxx> wrote:

> Hi everyone,
>
> I'm trying to create a structure (also know compounded type). In this
> email I attach two different ways I've tried to do it and their respective
> error message. This is the dependency I'm using
>
> <dependency>
>> <groupId>edu.ucar</groupId>
>> <artifactId>netcdf4</artifactId>
>> <version>LATEST</version>
>> </dependency>
>
>
> *1) NetCdfCreatorLite.java*
>
> The execution throws a NullPointerException at
>
> Structure otherVar = ncFile.addStructure(root, root.getParentStructure(),
>> "Other", singletonList(other));
>
>
> Exception in thread "main" java.lang.NullPointerException
>> at ucar.nc2.NetcdfFileWriter.addStructure(NetcdfFileWriter.java:584)
>> at org.mock.NetCdfCreatorLite.main(NetCdfCreatorLite.java:27)
>
>
> *2) NetCdfCreatorLite2.java*
>
> According to the java doc, the method addstructure shouldn't be used.
> Then, in this second version, I uses a addVariable method to create the
> structure:
>
> Structure otherVar = (Structure) ncFile.addVariable(root, "Other",
>> STRUCTURE, singletonList(other));
>
>
> The exeception given this time is:
>
> Exception in thread "main" java.io.IOException: nc_put_vars: -49: NetCDF:
>> Variable not found grpid=65536 objid=1
>> at ucar.nc2.jni.netcdf.Nc4Iosp.writeCompoundData(Nc4Iosp.java:2895)
>> at ucar.nc2.jni.netcdf.Nc4Iosp.writeData(Nc4Iosp.java:2839)
>> at ucar.nc2.jni.netcdf.Nc4Iosp.writeData(Nc4Iosp.java:2721)
>> at ucar.nc2.NetcdfFileWriter.write(NetcdfFileWriter.java:934)
>> at ucar.nc2.NetcdfFileWriter.write(NetcdfFileWriter.java:918)
>> at org.mock.NetCdfCreatorLite2.main(NetCdfCreatorLite2.java:46)
>
>
> At line:
>
> ncFile.write(otherVar, otherStructure);
>
>
> If I comment the creation of structures, the application executes
> perfectly. Even more, by only adding the addVariable of a structure line, I
> get this exception, even though I only write the cityVar at line 50.
>
> What is wrong? Can you please provide me with an example of use of the
> structures?.
>
> Best regards, thank you very much,
>
> José Évora Gómez
> Instituto Universitario SIANI
> Universidad de Las Palmas de GC
> @j_evora
>
> _______________________________________________
> netcdf-java mailing list
> netcdf-java@xxxxxxxxxxxxxxxx
> For list information or to unsubscribe, visit:
> http://www.unidata.ucar.edu/mailing_lists/
>
  • 2015 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: