From e93d6379c769b69632ac490c891d015b0f8d3c48 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 17 Jul 2024 10:24:51 +0000 Subject: [PATCH 1/2] Fix broken grib_dump output for flag tables --- src/accessor/grib_accessor_class_codeflag.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/accessor/grib_accessor_class_codeflag.cc b/src/accessor/grib_accessor_class_codeflag.cc index 8b08ac5a2..79d6647e1 100644 --- a/src/accessor/grib_accessor_class_codeflag.cc +++ b/src/accessor/grib_accessor_class_codeflag.cc @@ -94,9 +94,9 @@ static int grib_get_codeflag(grib_accessor* a, long code, char* codename) j--; codename[j] = 0; - strcat(codename, " ("); + strcat(codename, ":"); strcat(codename, fname); - strcat(codename, ")"); + //strcat(codename, ")"); fclose(f); return GRIB_SUCCESS; From 4f78b500f7779f99079a1307b5c338d8ebfe798b Mon Sep 17 00:00:00 2001 From: shahramn Date: Wed, 17 Jul 2024 13:26:38 +0100 Subject: [PATCH 2/2] Testing: grib_dump with code/flag tables --- src/accessor/grib_accessor_class_codeflag.cc | 3 --- tests/grib_dump.sh | 7 +++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/accessor/grib_accessor_class_codeflag.cc b/src/accessor/grib_accessor_class_codeflag.cc index 79d6647e1..49f291d77 100644 --- a/src/accessor/grib_accessor_class_codeflag.cc +++ b/src/accessor/grib_accessor_class_codeflag.cc @@ -78,8 +78,6 @@ static int grib_get_codeflag(grib_accessor* a, long code, char* codename) codename[j++] = bval[0]; codename[j++] = ')'; codename[j++] = ' '; - //if (j) - // codename[j++] = ' '; for (i = (strlen(num) + strlen(bval) + 2); i < linelen - 1; i++) codename[j++] = line[i]; @@ -96,7 +94,6 @@ static int grib_get_codeflag(grib_accessor* a, long code, char* codename) strcat(codename, ":"); strcat(codename, fname); - //strcat(codename, ")"); fclose(f); return GRIB_SUCCESS; diff --git a/tests/grib_dump.sh b/tests/grib_dump.sh index 00a6412c0..dca701ff2 100755 --- a/tests/grib_dump.sh +++ b/tests/grib_dump.sh @@ -155,6 +155,13 @@ file=$data_dir/sst_globus0083.grib ${tools_dir}/grib_dump -O $file > $temp 2>&1 grep -q "12-10227752 codedValues" $temp +# Code tables and code flags +#----------------------------------------------------------- +file=$data_dir/sample.grib2 +${tools_dir}/grib_dump -Ot $file > $temp 2>&1 +fgrep -q "codetable (int) typeOfFirstFixedSurface = 103 [Specified height level above ground (m) (grib2/tables/4/4.5.table) ]" $temp +fgrep -q "codeflag (int) resolutionAndComponentFlags = 48 [00110000 (grib2/tables/4/3.3.table) ]" $temp +fgrep -q "codeflag (int) scanningMode = 0 [00000000 (grib2/tables/4/3.4.table) ]" $temp # Error conditions #-----------------------------------------------------------