Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More testing of index code #475

Merged
merged 3 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/g2cfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1116,8 +1116,8 @@ read_metadata(int g2cid)
LOG((6, "file_pos %ld", file_pos));
}

/* If we run out of messages, that's success. */
if (ret == G2C_ENOMSG)
/* If we read some messages, then run out, that's success. */
if (ret == G2C_ENOMSG && msg_num)
ret = G2C_NOERROR;

#ifdef LOGGING
Expand Down
7 changes: 5 additions & 2 deletions tests/run_index_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ set -e
echo ""
echo "*** Running g2c_index test"

# Read GRIB1 index.
../utils/g2c_index -v data/ref_gdaswave_2.grib1.idx g2c_index_gdaswave_2.grib1.idx.txt
# Create an index for a GRIB2 file.
../utils/g2c_index -v data/gdaswave.t00z.wcoast.0p16.f000.grib2 gdaswave.t00z.wcoast.0p16.f000.grib2.idx

# Summarize the index data.
../utils/g2c_degrib2 -v gdaswave.t00z.wcoast.0p16.f000.grib2.idx gdaswave.t00z.wcoast.0p16.f000.grib2.idx.degrib2

# Check against expected output.
#diff -w g2c_degrib2_gdaswave.t00z.wcoast.0p16.f000.grib2.degrib2 data/ref_gdaswave.degrib2.txt
Expand Down
7 changes: 7 additions & 0 deletions utils/g2c_degrib2.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ main(int argc, char **argv)
break;
}

/* If we didn't get 2 files, error. */
if (p != 2)
{
printf("Two filenames must be provided, for input and output.\n");
return G2C_ERROR;
}

/* Yammer on and on. */
if (verbose)
printf("g2c_degrib2 %s summarizing %s into %s.\n", G2C_VERSION, path[0], path[1]);
Expand Down
20 changes: 10 additions & 10 deletions utils/g2c_index.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ main(int argc, char **argv)
int index;
int c;
int p = 0;
/* int g2cid; */
/* int ret; */
int g2cid;
int ret;

opterr = 0;

Expand Down Expand Up @@ -69,16 +69,16 @@ main(int argc, char **argv)
printf("g2c_index %s reading index file %s summarizing into %s.\n", G2C_VERSION, path[0], path[1]);

/* Open the GRIB2 file. */
/* if ((ret = g2c_open(path[0], G2C_NOWRITE, &g2cid))) */
/* return ret; */
if ((ret = g2c_open(path[0], G2C_NOWRITE, &g2cid)))
return ret;

/* /\* Write the degrib2 summary. *\/ */
/* if ((ret = g2c_degrib2(g2cid, path[1]))) */
/* return ret; */
/* Write the index file. */
if ((ret = g2c_write_index(g2cid, G2C_CLOBBER, path[1])))
return ret;

/* /\* Close the file. *\/ */
/* if ((ret = g2c_close(g2cid))) */
/* return ret; */
/* Close the file. */
if ((ret = g2c_close(g2cid)))
return ret;

/* Free memory. */
if (path[0])
Expand Down
Loading