udf must take priority in NC_infermodel

This commit is contained in:
edwardhartnett 2019-11-13 12:07:33 -07:00
parent 108e938b2f
commit 0bbe91e438
2 changed files with 11 additions and 11 deletions

View File

@ -395,6 +395,16 @@ NC_omodeinfer(int useparallel, int cmode, NCmodel* model)
/* Process the cmode; may override some already set flags */
if(fIsSet(cmode,(NC_UDF0|NC_UDF1))) {
model->format = NC_FORMAT_NETCDF4;
if(fIsSet(cmode,NC_UDF0)) {
model->impl = NC_FORMATX_UDF0;
} else {
model->impl = NC_FORMATX_UDF1;
}
goto done;
}
if(fIsSet(cmode,NC_64BIT_OFFSET)) {
model->impl = NC_FORMATX_NC3;
model->format = NC_FORMAT_64BIT_OFFSET;
@ -416,16 +426,6 @@ NC_omodeinfer(int useparallel, int cmode, NCmodel* model)
goto done;
}
if(fIsSet(cmode,(NC_UDF0|NC_UDF1))) {
model->format = NC_FORMAT_NETCDF4;
if(fIsSet(cmode,NC_UDF0)) {
model->impl = NC_FORMATX_UDF0;
} else {
model->impl = NC_FORMATX_UDF1;
}
goto done;
}
/* Default to classic model */
model->format = NC_FORMAT_CLASSIC;
model->impl = NC_FORMATX_NC3;

View File

@ -185,7 +185,7 @@ main(int argc, char **argv)
if (nc_close(ncid)) ERR;
/* Open file again and abort, which is the same as closing it. */
if (nc_open(FILE_NAME, mode[i], &ncid)) ERR;
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;
if (nc_abort(ncid) != TEST_VAL_42) ERR;