5 fflush(stdout); /* Make sure our stdout is synced with stderr. */ \
6 fprintf(stderr, "Sorry! Unexpected result, %s, line: %d\n", \
12 #define FILE_NAME "nc4_test.nc"
19 float data
[X_LEN
* Y_LEN
* Z_LEN
];
20 int i
, ncmode
, ncid
, dimids
[NDIMS
], var
;
21 size_t start
[NDIMS
] = {0, 0, 0};
22 size_t count
[NDIMS
] = {X_LEN
, Y_LEN
, Z_LEN
};
23 ptrdiff_t stride
[NDIMS
] = {1, 1, 1};
25 /* Initialize data. */
26 for (i
= 0; i
< (X_LEN
* Y_LEN
* Z_LEN
); i
++)
29 printf("*** Testing netcdf-4 writes with compressed data...\n");
31 ncmode
= NC_CLOBBER
|NC_NETCDF4
;
33 if (nc_create(FILE_NAME
, NC_NETCDF4
, &ncid
)) ERR_RET
;
34 if (nc_def_dim(ncid
, "time", X_LEN
, &dimids
[0])) ERR_RET
;
35 if (nc_def_dim(ncid
, "lat", Y_LEN
, &dimids
[1])) ERR_RET
;
36 if (nc_def_dim(ncid
, "lon", Z_LEN
, &dimids
[2])) ERR_RET
;
37 if (nc_def_var(ncid
, "test", NC_FLOAT
, NDIMS
, dimids
, &var
)) ERR_RET
;
38 if (nc_def_var_deflate(ncid
, var
, 1, 1, 2)) ERR_RET
;
39 if (nc_enddef(ncid
)) ERR_RET
;
40 if (nc_put_vars_float(ncid
, var
, start
, count
, stride
, data
)) ERR_RET
;
41 if (nc_close(ncid
)) ERR_RET
;
43 printf("*** Tests successful!\n");