Skip to content

Commit

Permalink
fixed new index format
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardhartnett committed Feb 3, 2024
1 parent 6498359 commit 6014269
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/g2cindex.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ extern G2C_FILE_INFO_T g2c_file[G2C_MAX_FILES + 1];
/** Length of beginning of index record. */
#define G2C_INDEX_FIXED_LEN 44

/** Length of beginning of index record for large files. */
#define G2C_INDEX_FIXED_LEN_2 48

/** Length of date string in index record. */
#define G2C_INDEX_DATE_STR_LEN 10

Expand Down Expand Up @@ -505,8 +508,8 @@ g2c_write_index(int g2cid, int mode, const char *index_file)
break;

/* What will be the length of this index record? */
reclen = G2C_INDEX_FIXED_LEN + msg->sec1_len + sec3->sec_len + sec4->sec_len +
sec5->sec_len + G2C_INDEX_BITMAP_BYTES;
reclen = (index_version == 1 ? G2C_INDEX_FIXED_LEN : G2C_INDEX_FIXED_LEN_2) +
msg->sec1_len + sec3->sec_len + sec4->sec_len + sec5->sec_len + G2C_INDEX_BITMAP_BYTES;
total_index_size += reclen;
LOG((4, "fieldnum %d reclen %d total_index_size %d", fieldnum, reclen, total_index_size));
} /* next product */
Expand Down Expand Up @@ -554,8 +557,8 @@ g2c_write_index(int g2cid, int mode, const char *index_file)
bs7 = (int)sec7->bytes_to_sec;

/* What will be the length of this index record? */
reclen = G2C_INDEX_FIXED_LEN + msg->sec1_len + sec3->sec_len + sec4->sec_len +
sec5->sec_len + G2C_INDEX_BITMAP_BYTES;
reclen = (index_version == 1 ? G2C_INDEX_FIXED_LEN : G2C_INDEX_FIXED_LEN_2)
+ msg->sec1_len + sec3->sec_len + sec4->sec_len + sec5->sec_len + G2C_INDEX_BITMAP_BYTES;
LOG((4, "fieldnum %d reclen %d", fieldnum, reclen));

/* Write the beginning of the index record. */
Expand Down
2 changes: 1 addition & 1 deletion tests/run_index_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ echo ""
echo "*** Running g2c_index test"

# 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
../utils/g2c_index -v -o gdaswave.t00z.wcoast.0p16.f000.grib2.idx data/gdaswave.t00z.wcoast.0p16.f000.grib2

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

0 comments on commit 6014269

Please sign in to comment.