Skip to content

Commit

Permalink
Merge pull request #1523 from NetCDF-World-Domination-Council/ejh_udf
Browse files Browse the repository at this point in the history
User-defined formats must come first in NC_infermodel, plus test
  • Loading branch information
WardF authored Nov 15, 2019
2 parents e4003be + b9f57b2 commit af8f9ad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 5 additions & 2 deletions libdispatch/dinfermodel.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,11 @@ NC_omodeinfer(int useparallel, int cmode, NCmodel* model)
if(!fIsSet(cmode,NC_FORMAT_ALL))
set_default_mode(&cmode);

/* Process the cmode; may override some already set flags */

/* Process the cmode; may override some already set flags. The
* user-defined formats must be checked first. They may choose to
* use some of the other flags, like NC_NETCDF4, so we must fist
* check NC_UDF0 and NC_UDF1 before checking for any other
* flag. */
if(fIsSet(cmode,(NC_UDF0|NC_UDF1))) {
model->format = NC_FORMAT_NETCDF4;
if(fIsSet(cmode,NC_UDF0)) {
Expand Down
6 changes: 5 additions & 1 deletion nc_test4/tst_udf.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,11 @@ main(int argc, char **argv)
if (nc_open(FILE_NAME, mode[i], &ncid)) ERR;
if (nc_close(ncid)) ERR;

/* Open file again and abort, which is the same as closing it. */
/* Open file again and abort, which is the same as closing
* it. This also tests that the UDF flags are given
* priority. If NC_NETCDF4 flag were given priority, then
* nc_abort() will not return TEST_VAL_42, but instead will
* return 0. */
if (nc_open(FILE_NAME, mode[i]|NC_NETCDF4, &ncid)) ERR;
if (nc_inq_format(ncid, NULL) != TEST_VAL_42) ERR;
if (nc_inq_format_extended(ncid, NULL, NULL) != TEST_VAL_42) ERR;
Expand Down

0 comments on commit af8f9ad

Please sign in to comment.