From 97243f0e30c13beae372bc737365d9fd332bfb20 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 2 Mar 2015 17:22:07 +0000 Subject: [PATCH] Clean up C example --- tests/index.c | 162 +++++++++++++++++++++++++------------------------- 1 file changed, 80 insertions(+), 82 deletions(-) diff --git a/tests/index.c b/tests/index.c index 5bf696019..2aa6c421a 100644 --- a/tests/index.c +++ b/tests/index.c @@ -20,9 +20,9 @@ int main(int argc,char* argv[]) grib_handle* h=NULL; char* infile=NULL; char* outfile=NULL; - long *step,*level,*number; + long *steps,*levels,*numbers; /* arrays */ char** shortName=NULL; - int i,j,k,l,iii; + int i,j,k,l; size_t stepSize,levelSize,shortNameSize,numberSize; long ostep,olevel,onumber; char oshortName[200]; @@ -35,104 +35,102 @@ int main(int argc,char* argv[]) printf("indexing...\n"); - for (iii=0;iii<1;iii++) { - /* Create an index given set of keys*/ - index=grib_index_new(0,"shortName,level,number,step",&ret); - if (ret) {printf("error: %s\n",grib_get_error_message(ret)); exit(ret);} + /* Create an index given set of keys*/ + index=grib_index_new(0,"shortName,level,number,step",&ret); + if (ret) {printf("error: %s\n",grib_get_error_message(ret)); exit(ret);} - /* Indexes a file */ - ret=grib_index_add_file(index,infile); - if (ret) {printf("error: %s\n",grib_get_error_message(ret)); exit(ret);} - printf("end indexing...\n"); + /* Indexes a file */ + ret=grib_index_add_file(index,infile); + if (ret) {printf("error: %s\n",grib_get_error_message(ret)); exit(ret);} + printf("end indexing...\n"); - /* get the number of distinct values of "step" in the index */ - GRIB_CHECK(grib_index_get_size(index,"step",&stepSize),0); - step=(long*)malloc(sizeof(long)*stepSize); - if (!step) exit(1); - /* get the list of distinct steps from the index */ - /* the list is in ascending order */ - GRIB_CHECK(grib_index_get_long(index,"step",step,&stepSize),0); - printf("stepSize=%ld\n",(long)stepSize); - for (i=0;i