mirror of https://github.com/ecmwf/eccodes.git
Extend test on indexes
This commit is contained in:
parent
dd53304d69
commit
38f10e2417
|
@ -1851,12 +1851,15 @@ int is_index_file(const char* filename)
|
|||
char buf[8]={0,};
|
||||
const char* str="GRBIDX";
|
||||
int ret=0;
|
||||
size_t size = 0;
|
||||
|
||||
fh=fopen(filename,"r");
|
||||
if (!fh) return 0;
|
||||
|
||||
fread(buf,1,1,fh);
|
||||
fread(buf,6,1,fh);
|
||||
size=fread(buf,1,1,fh);
|
||||
if (size != 1) return 0;
|
||||
size=fread(buf,6,1,fh);
|
||||
if (size != 1) return 0;
|
||||
|
||||
ret=!strcmp(buf,str);
|
||||
|
||||
|
|
|
@ -13,12 +13,6 @@
|
|||
. ./include.sh
|
||||
infile=${data_dir}/index.grib
|
||||
|
||||
#if [ ! -f ${infile} ]
|
||||
#then
|
||||
# echo no data to test
|
||||
# exit 0
|
||||
#fi
|
||||
|
||||
$EXEC ${test_dir}/index ${infile} > index.out
|
||||
|
||||
diff index.out ${data_dir}/index.ok
|
||||
|
@ -32,9 +26,30 @@ rm -f index.out out.gribidx
|
|||
#-------------------------------
|
||||
# Test grib_index_build
|
||||
#-------------------------------
|
||||
tempIndex=temp.$$.ix
|
||||
tempIndex=temp.$$.idx
|
||||
tempOut=temp.$$.out
|
||||
tempRef=temp.$$.ref
|
||||
${tools_dir}/grib_index_build -o $tempIndex ${infile} >/dev/null
|
||||
${tools_dir}/grib_dump -D ${tempIndex} > /dev/null
|
||||
|
||||
# Must remove first two lines and the last (filename specifics)
|
||||
${tools_dir}/grib_dump -D ${tempIndex} | sed '1,2d' | sed '$d' > $tempOut
|
||||
cat $tempOut
|
||||
|
||||
cat > $tempRef <<EOF
|
||||
Index keys:
|
||||
key name = mars.step
|
||||
values = 12, 24, 48, 60
|
||||
key name = mars.param
|
||||
values = 130.128, 129.128
|
||||
key name = mars.levelist
|
||||
values = 10, 50, 100, 200, 250, 300, 400, 500, 700, 850, 925, 1000
|
||||
key name = mars.number
|
||||
values = 1, 2, 3, 4
|
||||
Index count = 384
|
||||
EOF
|
||||
|
||||
diff $tempRef $tempOut
|
||||
|
||||
|
||||
${tools_dir}/grib_index_build -k mars.levtype -o $tempIndex ${data_dir}/tigge_cf_ecmwf.grib2 |\
|
||||
grep -q "mars.levtype = { sfc, pl, pv, pt }"
|
||||
|
@ -42,4 +57,4 @@ ${tools_dir}/grib_index_build -k mars.levtype -o $tempIndex ${data_dir}/tigge_cf
|
|||
${tools_dir}/grib_index_build -k mars.levtype:i -o $tempIndex ${data_dir}/tigge_cf_ecmwf.grib2 |\
|
||||
grep -q "mars.levtype = { 103, 1, 106, 100, 101, 8, 109, 107 }"
|
||||
|
||||
rm -f $tempIndex
|
||||
rm -f $tempIndex $tempOut $tempRef
|
||||
|
|
Loading…
Reference in New Issue