/* * Copyright 2005-2019 ECMWF. * * This software is licensed under the terms of the Apache Licence Version 2.0 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. * * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ #include "grib_api.h" static void usage(char* prog) { printf("usage: %s infile\n",prog); exit(1); } int main(int argc,char* argv[]) { grib_index* index=NULL; grib_handle* h=NULL; long *step,*level,*number; char** shortName=NULL; int i,j,k,l; size_t stepSize,levelSize,shortNameSize,numberSize; long ostep,olevel,onumber; char oshortName[200]; size_t lenshortName=200; int ret=0,count=0; if (argc != 2) usage(argv[0]); printf("indexing...\n"); index=grib_index_read(0,"out.gribidx",&ret); GRIB_CHECK(ret,0); 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