|
| 1 | +/* This is part of the netCDF package. Copyright 2005 University |
| 2 | + Corporation for Atmospheric Research/Unidata See COPYRIGHT file for |
| 3 | + conditions of use. |
| 4 | +
|
| 5 | + This program excersizes HDF5 variable length array code. |
| 6 | +
|
| 7 | + $Id: tst_h_vl2.c,v 1.5 2010/06/01 15:34:52 ed Exp $ |
| 8 | +*/ |
| 9 | +#include <nc_tests.h> |
| 10 | +#include <hdf5.h> |
| 11 | +#include <nc_logging.h> |
| 12 | + |
| 13 | +#define FILE_NAME "tst_gh221.nc" |
| 14 | +#define DIM_LEN 3; |
| 15 | +#define DIM_NAME "x" |
| 16 | +#define VLNE_NAME "vltest" |
| 17 | +#define VAR_NAME1 "v" |
| 18 | +#define VAR_NAME2 "w" |
| 19 | + |
| 20 | +int main() { |
| 21 | + |
| 22 | + printf("Testing access to unset entrines in VLEN variable\n"); |
| 23 | + { |
| 24 | + int ncid, typeid, dimid; |
| 25 | + nc_vlen_t data[DIM_LEN], data_in[DIM_LEN]; |
| 26 | + |
| 27 | + size_t size_in; |
| 28 | + nc_type base_nc_type_in; |
| 29 | + int *phony, class_in; |
| 30 | + size_t len_in; |
| 31 | + int i, j; |
| 32 | + |
| 33 | + /* Create phony data. */ |
| 34 | + for (i=0; i<DIM_LEN; i++) { |
| 35 | + if (!(phony = malloc(sizeof(int) * (i+1)))) |
| 36 | + return NC_ENOMEM; |
| 37 | + for (j = 0; j < i + 1; j++) |
| 38 | + phony[j] = PHONY_VAL; |
| 39 | + data[i].p = phony; |
| 40 | + data[i].len = i+1; |
| 41 | + } |
| 42 | + |
| 43 | + /* Create File */ |
| 44 | + if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR; |
| 45 | + |
| 46 | + /* Create Dimension */ |
| 47 | + if (nc_def_dim(ncid, DIM_NAME, DIM_LEN, &dimid)) ERR; |
| 48 | + |
| 49 | + /* Create ragged array type. */ |
| 50 | + if (nc_def_vlen(ncid, VLEN_NAME, NC_FLOAT, &typeid)) ERR; |
| 51 | + |
| 52 | + /* Create a variable of typeid. */ |
| 53 | + if (nc_def_var(ncid, VAR_NAME1, typeid, 1, &dimid, &varid); |
| 54 | + |
| 55 | + /* Close File. */ |
| 56 | + if (nc_close(ncid)) ERR; |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | +} |
0 commit comments