From 3bcb5a8cc92eddf15450c9ad39cfe2dd36ca378a Mon Sep 17 00:00:00 2001 From: Eugen Betke Date: Wed, 29 Nov 2023 09:37:38 +0000 Subject: [PATCH] ECC-1620: New format for special units, e.g., 8x15m --- src/step.cc | 13 ++++++++++--- tests/grib_ecc-1620.sh | 8 ++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/step.cc b/src/step.cc index a5baacd88..c2ff472b9 100644 --- a/src/step.cc +++ b/src/step.cc @@ -183,9 +183,16 @@ std::string Step::value(const std::string& format) const { if (unit_ != Unit::Value::HOUR) u = unit_.value(); - if (unit_ == Unit::Value::MINUTES15 || unit_ == Unit::Value::MINUTES30) - err = snprintf(output, MAX_SIZE, (format + "(%s)").c_str(), value(), u.c_str()); - else + if (unit_ == Unit::Value::MINUTES15 || + unit_ == Unit::Value::MINUTES30 || + unit_ == Unit::Value::HOURS3 || + unit_ == Unit::Value::HOURS6 || + unit_ == Unit::Value::HOURS12 || + unit_ == Unit::Value::YEARS10 || + unit_ == Unit::Value::YEARS30 + ) + err = snprintf(output, MAX_SIZE, (format + "x%s").c_str(), value(), u.c_str()); + else err = snprintf(output, MAX_SIZE, (format + "%s").c_str(), value(), u.c_str()); if (err < 0 || err >= MAX_SIZE) { diff --git a/tests/grib_ecc-1620.sh b/tests/grib_ecc-1620.sh index a5e1bb009..a08cde285 100755 --- a/tests/grib_ecc-1620.sh +++ b/tests/grib_ecc-1620.sh @@ -63,11 +63,11 @@ grib_check_key_equals $temp " -w count=1 -s stepUnits=D -p step:i,stepUnits:s" " grib_check_key_equals $temp " -w count=1 -s stepUnits=s -p step,stepUnits:s" "345600s s" grib_check_key_equals $temp " -w count=1 -s stepUnits=m -p step,stepUnits:s" "5760m m" -grib_check_key_equals $temp " -w count=1 -s stepUnits=15m -p step,stepUnits:s" "384(15m) 15m" -grib_check_key_equals $temp " -w count=1 -s stepUnits=30m -p step,stepUnits:s" "192(30m) 30m" +grib_check_key_equals $temp " -w count=1 -s stepUnits=15m -p step,stepUnits:s" "384x15m 15m" +grib_check_key_equals $temp " -w count=1 -s stepUnits=30m -p step,stepUnits:s" "192x30m 30m" grib_check_key_equals $temp " -w count=1 -s stepUnits=h -p step,stepUnits:s" "96 h" -grib_check_key_equals $temp " -w count=1 -s stepUnits=6h -p step,stepUnits:s" "166h 6h" # FIXME(maee) (16(6h) 6h) is correct -grib_check_key_equals $temp " -w count=1 -s stepUnits=12h -p step,stepUnits:s" "812h 12h" # FIXME(maee) (8(12h) 12h) is correct +grib_check_key_equals $temp " -w count=1 -s stepUnits=6h -p step,stepUnits:s" "16x6h 6h" +grib_check_key_equals $temp " -w count=1 -s stepUnits=12h -p step,stepUnits:s" "8x12h 12h" grib_check_key_equals $temp " -w count=1 -s stepUnits=D -p step,stepUnits:s" "4D D" ${tools_dir}/grib_set -s stepUnits=s,startStep=0,endStep=345600 $fn $temp