2010-09-01 06:41:00 +08:00
|
|
|
/* This is part of the netCDF package. Copyright 2010 University
|
|
|
|
Corporation for Atmospheric Research/Unidata. See COPYRIGHT file for
|
|
|
|
conditions of use. See www.unidata.ucar.edu for more info.
|
|
|
|
|
|
|
|
Create a compressible test file for nccopy to compress.
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
*/
|
|
|
|
|
2010-09-03 06:22:51 +08:00
|
|
|
#include <config.h>
|
2010-09-01 06:41:00 +08:00
|
|
|
#include <nc_tests.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <netcdf.h>
|
|
|
|
|
|
|
|
#define FILENAME "tst_inflated.nc"
|
2011-06-21 23:10:17 +08:00
|
|
|
#define FILENAME2 "tst_inflated4.nc"
|
2010-09-01 06:41:00 +08:00
|
|
|
#define DIM_NAME "dim1"
|
|
|
|
#define DIM1_LEN 10000
|
|
|
|
#define VAR1_RANK 1
|
|
|
|
#define VAR_NAME "var"
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char **argv) { /* create a compressible file, for testing */
|
|
|
|
|
|
|
|
int ncid;
|
|
|
|
int dimid, varid;
|
|
|
|
int var1_dims[VAR1_RANK]; /* variable shapes */
|
|
|
|
int var1_data[DIM1_LEN]; /* data to write */
|
|
|
|
int i;
|
|
|
|
|
2011-06-24 01:15:01 +08:00
|
|
|
printf("*** Creating compressible test files %s, %s...", FILENAME, FILENAME2);
|
2010-09-01 06:41:00 +08:00
|
|
|
if (nc_create(FILENAME, NC_CLOBBER, &ncid)) ERR;
|
|
|
|
if (nc_def_dim(ncid, "dim1", DIM1_LEN, &dimid)) ERR;
|
|
|
|
var1_dims[0] = dimid;
|
|
|
|
if (nc_def_var(ncid, "var1", NC_INT, VAR1_RANK, var1_dims, &varid)) ERR;
|
|
|
|
if (nc_enddef (ncid)) ERR;
|
|
|
|
for(i=0; i < DIM1_LEN; i++) {
|
2010-09-02 02:40:17 +08:00
|
|
|
var1_data[i] = i;
|
2010-09-01 06:41:00 +08:00
|
|
|
}
|
|
|
|
if (nc_put_var(ncid, varid, var1_data)) ERR;
|
|
|
|
if (nc_close(ncid)) ERR;
|
2011-06-21 23:10:17 +08:00
|
|
|
|
|
|
|
if (nc_create(FILENAME2, NC_CLOBBER|NC_NETCDF4, &ncid)) ERR;
|
|
|
|
if (nc_def_dim(ncid, "dim1", DIM1_LEN, &dimid)) ERR;
|
|
|
|
var1_dims[0] = dimid;
|
|
|
|
if (nc_def_var(ncid, "var1", NC_INT, VAR1_RANK, var1_dims, &varid)) ERR;
|
|
|
|
if (nc_enddef (ncid)) ERR;
|
|
|
|
for(i=0; i < DIM1_LEN; i++) {
|
|
|
|
var1_data[i] = i;
|
|
|
|
}
|
|
|
|
if (nc_put_var(ncid, varid, var1_data)) ERR;
|
|
|
|
if (nc_close(ncid)) ERR;
|
|
|
|
|
2010-09-01 06:41:00 +08:00
|
|
|
SUMMARIZE_ERR;
|
|
|
|
FINAL_RESULTS;
|
|
|
|
}
|