Question about ncmpi_begin_indep() and ncmpi_end_indep() symmetry

Sjaardema, Gregory D gdsjaar at sandia.gov
Mon Nov 13 10:13:20 CST 2017


In  `ncmpi_begin_indep_data`, if the file is already in `indep` data mode, there is no error and the routine just returns early:
int
ncmpi_begin_indep_data(int ncid)
{
     int err;
     NC *ncp;
     err = ncmpii_NC_check_id(ncid, &ncp);
     if (err != NC_NOERR) DEBUG_RETURN_ERROR(err)
     if (NC_indef(ncp))  /* must not be in define mode */
         DEBUG_RETURN_ERROR(NC_EINDEFINE)
     if (NC_indep(ncp))  /* already in indep data mode */
         return NC_NOERR;
… deleted…
}

However, in `ncmpi_end_indep_data`, if the file is *not* in indep mode, an error is returned:

int
ncmpi_end_indep_data(int ncid) {
     int err;
     NC *ncp;
     err = ncmpii_NC_check_id(ncid, &ncp);
     if (err != NC_NOERR) DEBUG_RETURN_ERROR(err)
     if (!NC_indep(ncp)) /* must be in independent data mode */
         DEBUG_RETURN_ERROR(NC_ENOTINDEP)
     return ncmpii_end_indep_data(ncp);
}

This may be the correct behavior and there may be some reason for the asymmetry, but at first glance it seems like either both routines should return an error, or both should return NC_NOERR if the file data mode is already the same as the routine is attempting to set.

Thanks,
..Greg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/parallel-netcdf/attachments/20171113/b3516d86/attachment.html>


More information about the parallel-netcdf mailing list