Re: [netcdfgroup] Missing data in netcdf4 using pnetcdf

Many thanks to Wei-keng Liao for finding the cause of the missing data. There 
is a bug in dfile.c where netcdf does not recognize NC_PNETCDF in the cmode 
when opening a file for writing. (In 4.3.1.1, it is at line 1675 in dfile.c) 
The test code with netcdf-fortran works because it writes data after the 
enddef, but before closing the file.

- Ted

Begin forwarded message:

> I think I found the cause !
> 
> One question first. Does your code first creates a new nc file, defines
> dimensions, variables, put attributes, close the file without calling
> any put_var? And then reopen the file and call many get_var and put_var?
> 

Yes, it does.

> If this is the case, then the cause is due to a bug in netCDF I reported
> to netCDF team recently. See 
> https://bugtracking.unidata.ucar.edu/browse/NCF-319
> 
> A simple fix is to add the 3 lines (1712-1715 below) after line 1711 of file 
> libdispatch/dfile.c.
> 1710        else if(cmode & NC_NETCDF4) model |= NC_DISPATCH_NC4; 
> 1711     } 
> 1712     else if (model == NC_DISPATCH_NC3) { 
> 1713        /* if file is a CDF-1 or CDF-2, and PnetCDF method is selected */ 
> 1714        if (cmode & NC_PNETCDF) model = NC_DISPATCH_NC5; 
> 1715     }
> 
> Without this fix, netCDF will fail to call PnetCDF APIs even if NF90_PNETCDF
> open mode is used. It will use POSIX read/write instead. Please re-build your
> netCDF and let me know if it works.
> 
> Wei-keng
> 

It works!!!



  • 2014 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: