Skip to content

Commit

Permalink
Sub hourly: Extra tests for native type of step keys
Browse files Browse the repository at this point in the history
  • Loading branch information
shahramn committed Jan 18, 2024
1 parent 305f636 commit afc918b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
1 change: 1 addition & 0 deletions examples/C/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 8 additions & 6 deletions examples/C/grib_index.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@

static void usage(const char* prog)
{
printf("usage: %s infile\n", prog);
printf("usage: %s gribfile indexfile\n", prog);
exit(1);
}

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;
Expand All @@ -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");

Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 7 additions & 2 deletions examples/C/grib_index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 11 additions & 0 deletions tests/grib_filter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
# ----------------
Expand Down

0 comments on commit afc918b

Please sign in to comment.