[netcdf-java] Writing a netcdf4 nc file

Hello,

I try to use the Netcdf-java to create a netcdf4 file.
I tried the example 
https://www.unidata.ucar.edu/software/netcdf/examples/programs/Sfc_pres_temp_wr.java
 and It's well running.
But I need to generate a netcdf4 and the example is in netcdf3. So, I change 
the line
                "dataFile = 
NetcdfFileWriter.createNew(NetcdfFileWriter.Version.netcdf3, filename);"
By
"dataFile = NetcdfFileWriter.createNew(NetcdfFileWriter.Version.netcdf4, 
filename);"

But when I execute the test, I got the following error:

Exception in thread "main" java.lang.NullPointerException
                at ucar.nc2.jni.netcdf.Nc4Iosp.flush(Nc4Iosp.java:3270)
                at ucar.nc2.NetcdfFileWriter.rewrite(NetcdfFileWriter.java:842)
                at 
ucar.nc2.NetcdfFileWriter.setRedefineMode(NetcdfFileWriter.java:832)
                at ucar.nc2.NetcdfFileWriter.close(NetcdfFileWriter.java:1019)
                at com.tests.Sfc_pres_temp_wr.main(Sfc_pres_temp_wr.java:131)

Could you tell me how can I solve this problem?

Thank for your help,

Pierre
________________________________

Ce message et toutes les pi?ces jointes (ci-apr?s le "message") sont ?tablis ? 
l'intention exclusive de ses destinataires et sont confidentiels. Si vous 
recevez ce message par erreur ou s'il ne vous est pas destin?, merci de le 
d?truire ainsi que toute copie de votre syst?me et d'en avertir imm?diatement 
l'exp?diteur. Toute lecture non autoris?e, toute utilisation de ce message qui 
n'est pas conforme ? sa destination, toute diffusion ou toute publication, 
totale ou partielle, est interdite. L'Internet ne permettant pas d'assurer 
l'int?grit? de ce message ?lectronique susceptible d'alt?ration, l'exp?diteur 
(et ses filiales) d?cline(nt) toute responsabilit? au titre de ce message dans 
l'hypoth?se o? il aurait ?t? modifi? ou falsifi?.

This message and any attachments (the "message") is intended solely for the 
intended recipient(s) and is confidential. If you receive this message in 
error, or are not the intended recipient(s), please delete it and any copies 
from your systems and immediately notify the sender. Any unauthorized view, use 
that does not comply with its purpose, dissemination or disclosure, either 
whole or partial, is prohibited. Since the internet cannot guarantee the 
integrity of this message which may not be reliable, the sender (and its 
subsidiaries) shall not be liable for the message if modified or falsified.
  • 2016 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: