mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-11-27 07:30:33 +08:00
fixed some confusion about create mode flag NC_CLASSIC_MODEL
This commit is contained in:
parent
bc5abe766e
commit
ff3abf1427
@ -130,7 +130,7 @@ NC_create(const char *path, int cmode, size_t initialsz,
|
||||
|
||||
/* Look to the incoming cmode for hints */
|
||||
if(model == 0) {
|
||||
if(cmode & NC_NETCDF4 || cmode & NC_CLASSIC_MODEL || cmode & NC_PNETCDF)
|
||||
if(cmode & NC_NETCDF4 || cmode & NC_PNETCDF)
|
||||
model = NC_DISPATCH_NC4;
|
||||
}
|
||||
|
||||
@ -158,13 +158,6 @@ NC_create(const char *path, int cmode, size_t initialsz,
|
||||
}
|
||||
}
|
||||
|
||||
/* Force flag consistentcy */
|
||||
/* if(model & NC_DISPATCH_NC4) */
|
||||
/* cmode |= NC_NETCDF4; */
|
||||
/* else if(model & NC_DISPATCH_NC3) { */
|
||||
/* cmode &= ~(NC_NETCDF4 | NC_CLASSIC_MODEL); /\* must be netcdf-3 *\/ */
|
||||
/* } */
|
||||
|
||||
/* Add inferred flags */
|
||||
cmode |= xcmode;
|
||||
|
||||
@ -283,7 +276,7 @@ NC_open(const char *path, int cmode,
|
||||
|
||||
/* Look to the incoming cmode for hints */
|
||||
if(model == 0) {
|
||||
if(cmode & NC_NETCDF4 || cmode & NC_CLASSIC_MODEL) model = NC_DISPATCH_NC4;
|
||||
if(cmode & NC_NETCDF4 || cmode & NC_PNETCDF) model = NC_DISPATCH_NC4;
|
||||
}
|
||||
|
||||
if(model == 0) model = NC_DISPATCH_NC3; /* final default */
|
||||
@ -292,7 +285,7 @@ NC_open(const char *path, int cmode,
|
||||
if(model & NC_DISPATCH_NC4)
|
||||
cmode |= NC_NETCDF4;
|
||||
else if(model & NC_DISPATCH_NC3) {
|
||||
cmode &= ~(NC_NETCDF4 | NC_CLASSIC_MODEL); /* must be netcdf-3 */
|
||||
cmode &= ~NC_NETCDF4; /* must be netcdf-3 */
|
||||
if(cdfversion == 2) cmode |= NC_64BIT_OFFSET;
|
||||
}
|
||||
|
||||
|
@ -392,7 +392,7 @@ NC4_create(const char* path, int cmode, size_t initialsz, int basepe,
|
||||
#endif /* USE_PNETCDF */
|
||||
else
|
||||
{
|
||||
assert(0);
|
||||
return NC_EINVAL;
|
||||
}
|
||||
|
||||
/* Delete this file list entry if there was a failure. */
|
||||
|
@ -285,13 +285,31 @@ main(int argc, char **argv)
|
||||
if (format != NC_FORMAT_64BIT) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
|
||||
/* Create a netcdf-3 file. */
|
||||
/* Create a netcdf-4 file. */
|
||||
if (nc_create(FILE_NAME, NC_NETCDF4|NC_CLOBBER, &ncid)) ERR;
|
||||
if (nc_inq_format(ncid, &format)) ERR;
|
||||
if (format != NC_FORMAT_NETCDF4) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
}
|
||||
SUMMARIZE_ERR;
|
||||
printf("*** testing CLASSIC_MODEL flag with classic formats...");
|
||||
{
|
||||
int ncid;
|
||||
int format;
|
||||
|
||||
/* Create a netcdf-3 file. */
|
||||
if (nc_create(FILE_NAME, NC_CLOBBER|NC_CLASSIC_MODEL, &ncid)) ERR;
|
||||
if (nc_inq_format(ncid, &format)) ERR;
|
||||
if (format != NC_FORMAT_CLASSIC) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
|
||||
/* Create a netcdf-3 64-bit offset file. */
|
||||
if (nc_create(FILE_NAME, NC_64BIT_OFFSET|NC_CLOBBER|NC_CLASSIC_MODEL, &ncid)) ERR;
|
||||
if (nc_inq_format(ncid, &format)) ERR;
|
||||
if (format != NC_FORMAT_64BIT) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
}
|
||||
SUMMARIZE_ERR;
|
||||
printf("*** testing multiple open files...");
|
||||
{
|
||||
#define VAR_NAME "Captain_Kirk"
|
||||
|
Loading…
Reference in New Issue
Block a user