diff --git a/examples/C/CMakeLists.txt b/examples/C/CMakeLists.txt index 30b8a5bf9..a50dc8d0a 100644 --- a/examples/C/CMakeLists.txt +++ b/examples/C/CMakeLists.txt @@ -77,6 +77,7 @@ if( HAVE_BUILD_TOOLS ) grib_clone grib_copy_message grib_ensemble_index + grib_index grib_set_pv grib_set_bitmap grib_list diff --git a/examples/C/grib_index.c b/examples/C/grib_index.c index 64a131dcd..2e37baead 100644 --- a/examples/C/grib_index.c +++ b/examples/C/grib_index.c @@ -19,7 +19,7 @@ static void usage(const char* prog) { - printf("usage: %s infile\n", prog); + printf("usage: %s gribfile indexfile\n", prog); exit(1); } @@ -27,7 +27,8 @@ int main(int argc, char* argv[]) { codes_index* index = NULL; codes_handle* h = NULL; - char* infile = NULL; + char* inputfile = NULL; + char* indexfile = NULL; long *steps, *levels, *numbers; /* arrays */ char** shortName = NULL; int i, j, k, l; @@ -37,8 +38,9 @@ int main(int argc, char* argv[]) size_t lenshortName = sizeof(oshortName); int ret = 0, count = 0; - if (argc != 2) usage(argv[0]); - infile = argv[1]; + if (argc != 3) usage(argv[0]); + inputfile = argv[1]; + indexfile = argv[2]; printf("indexing...\n"); @@ -50,7 +52,7 @@ int main(int argc, char* argv[]) } /* indexes a file */ - ret = codes_index_add_file(index, infile); + ret = codes_index_add_file(index, inputfile); if (ret) { fprintf(stderr, "Error: %s\n", codes_get_error_message(ret)); exit(ret); @@ -152,7 +154,7 @@ int main(int argc, char* argv[]) } printf(" %d messages selected\n", count); - codes_index_write(index, "out.gribidx"); + codes_index_write(index, indexfile); codes_index_delete(index); return 0; diff --git a/examples/C/grib_index.sh b/examples/C/grib_index.sh index fe4ea5698..06244169e 100755 --- a/examples/C/grib_index.sh +++ b/examples/C/grib_index.sh @@ -11,8 +11,13 @@ label="grib_index_c" tempIndex=temp.$label.idx +tempText=temp.$label.txt input=$data_dir/tigge_cf_ecmwf.grib2 -${examples_dir}/c_grib_index $input $tempIndex +${examples_dir}/c_grib_index $input $tempIndex > $tempText -rm -f $tempIndex +grep -q "43 messages selected" $tempText + +${tools_dir}/grib_dump $tempIndex + +rm -f $tempIndex $tempText diff --git a/tests/grib_filter.sh b/tests/grib_filter.sh index 50c2a5105..57bc4cb8f 100755 --- a/tests/grib_filter.sh +++ b/tests/grib_filter.sh @@ -445,6 +445,17 @@ status=$? set -e [ $status -ne 0 ] +# Setting step +# ------------- +input=$ECCODES_SAMPLES_PATH/GRIB2.tmpl +echo 'set step = 12; write;' | ${tools_dir}/grib_filter -o $tempGrib - $input +${tools_dir}/grib_compare -b forecastTime $input $tempGrib +grib_check_key_equals $tempGrib step 12 +grib_check_key_equals $tempGrib forecastTime 12 +echo 'set endStep = 12; write;' | ${tools_dir}/grib_filter -o $tempGrib - $input +grib_check_key_equals $tempGrib step 12 +grib_check_key_equals $tempGrib forecastTime 12 + # Bad filter # ----------------