2018-12-07 05:56:42 +08:00
|
|
|
/* This is part of the netCDF package. Copyright 2018 University
|
2017-03-30 05:25:38 +08:00
|
|
|
Corporation for Atmospheric Research/Unidata See COPYRIGHT file for
|
|
|
|
conditions of use. See www.unidata.ucar.edu for more info.
|
|
|
|
|
|
|
|
Test proper elatefill return when fillvalue is assigned outside of
|
|
|
|
the initial define.
|
|
|
|
|
|
|
|
Contributed by wkliao, see the following for more information:
|
|
|
|
|
|
|
|
* https://github.com/Unidata/netcdf-c/issues/388
|
|
|
|
* https://github.com/Unidata/netcdf-c/pull/389
|
2017-11-13 23:09:15 +08:00
|
|
|
|
2017-12-21 03:20:08 +08:00
|
|
|
Modified by Ed Hartnett, Ward Fisher, see:
|
2017-11-13 23:09:15 +08:00
|
|
|
https://github.com/Unidata/netcdf-c/issues/392
|
|
|
|
*/
|
2017-03-30 05:25:38 +08:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include <nc_tests.h>
|
2023-11-25 02:20:52 +08:00
|
|
|
#include <stddef.h>
|
2017-11-13 23:09:15 +08:00
|
|
|
#include "err_macros.h"
|
2017-10-07 02:58:49 +08:00
|
|
|
|
2017-03-30 05:25:38 +08:00
|
|
|
#define FILE_NAME "tst_global_fillval.nc"
|
|
|
|
|
2017-12-21 03:20:08 +08:00
|
|
|
|
2017-03-30 05:25:38 +08:00
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
2017-12-12 05:30:05 +08:00
|
|
|
printf("*** testing proper elatefill return...");
|
2017-11-13 23:09:15 +08:00
|
|
|
{
|
2017-12-12 05:30:05 +08:00
|
|
|
|
2017-11-13 23:09:15 +08:00
|
|
|
int n = 0;
|
2023-11-25 02:20:52 +08:00
|
|
|
size_t i;
|
|
|
|
size_t num_formats = 2;
|
2017-12-21 03:00:48 +08:00
|
|
|
int *formats = NULL;
|
2017-11-13 23:09:15 +08:00
|
|
|
/* Determine how many formats are in use. */
|
2017-12-12 05:30:05 +08:00
|
|
|
|
2018-12-01 22:29:58 +08:00
|
|
|
#ifdef USE_HDF5
|
2017-12-21 05:26:22 +08:00
|
|
|
num_formats += 2;
|
2017-12-21 03:00:48 +08:00
|
|
|
#endif
|
|
|
|
|
2024-03-19 04:32:03 +08:00
|
|
|
#ifdef NETCDF_ENABLE_CDF5
|
2017-12-21 03:00:48 +08:00
|
|
|
num_formats++;
|
|
|
|
#endif
|
|
|
|
|
2017-12-21 03:58:56 +08:00
|
|
|
formats = malloc(sizeof(int)*num_formats);
|
2017-12-21 03:00:48 +08:00
|
|
|
|
|
|
|
|
2017-11-13 23:09:15 +08:00
|
|
|
formats[n++] = 0;
|
|
|
|
formats[n++] = NC_64BIT_OFFSET;
|
2024-03-19 04:32:03 +08:00
|
|
|
#ifdef NETCDF_ENABLE_CDF5
|
2017-11-13 23:09:15 +08:00
|
|
|
formats[n++] = NC_64BIT_DATA;
|
|
|
|
#endif
|
2018-12-01 22:29:58 +08:00
|
|
|
#ifdef USE_HDF5
|
2017-11-13 23:09:15 +08:00
|
|
|
formats[n++] = NC_NETCDF4;
|
|
|
|
formats[n++] = NC_CLASSIC_MODEL | NC_NETCDF4;
|
2017-10-07 02:58:49 +08:00
|
|
|
#endif
|
2017-03-30 05:25:38 +08:00
|
|
|
|
2017-12-05 05:11:06 +08:00
|
|
|
for (i = 0; i < num_formats; i++)
|
2017-11-13 23:09:15 +08:00
|
|
|
{
|
2017-12-12 05:30:05 +08:00
|
|
|
|
2017-12-21 03:00:48 +08:00
|
|
|
int ncid, cmode, fillv = 9;
|
|
|
|
cmode = NC_CLOBBER | formats[i];
|
|
|
|
if (nc_create(FILE_NAME, cmode, &ncid)) ERR;
|
|
|
|
if (nc_put_att_int(ncid, NC_GLOBAL, "_FillValue", NC_INT, 1, &fillv)) ERR;
|
|
|
|
if (nc_close(ncid)) ERR;
|
2017-03-30 05:43:45 +08:00
|
|
|
|
2017-11-13 23:09:15 +08:00
|
|
|
}
|
2017-12-21 03:00:48 +08:00
|
|
|
free(formats);
|
2017-03-30 05:25:38 +08:00
|
|
|
}
|
2017-12-21 03:00:48 +08:00
|
|
|
|
2017-11-13 23:09:15 +08:00
|
|
|
SUMMARIZE_ERR;
|
2017-12-12 05:30:05 +08:00
|
|
|
FINAL_RESULTS;
|
2017-03-30 05:25:38 +08:00
|
|
|
}
|