Testing: hour/min set to 255

This commit is contained in:
Shahram Najm 2023-10-15 15:28:46 +01:00
parent 66e68d63f4
commit ade4cc1554
2 changed files with 19 additions and 11 deletions

View File

@ -143,7 +143,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
/* We ignore the 'seconds' in our time calculation! */
if (second != 0) {
grib_context_log(a->context, GRIB_LOG_ERROR,
"Key %s (unpack_long): Truncating time: non-zero seconds(%ld) ignored", a->name, second);
"Key %s (%s): Truncating time: non-zero seconds(%ld) ignored", a->name, __func__, second);
}
if (*len < 1)
@ -151,12 +151,12 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
*val = hour * 100 + minute;
if (hour == 255)
if (hour == 255) {
*val = 12 * 100;
if (hour != 255 && minute == 255)
}
if (hour != 255 && minute == 255) {
*val = hour * 100;
}
return GRIB_SUCCESS;
}

View File

@ -85,7 +85,7 @@ hourEnd=$1; dayEnd=$2
# ECC-134 case-sensitivity
# --------------------------
# ------------------------
temp=temp.step.$$.grib
# M is for Month (code 3)
${tools_dir}/grib_set -s indicatorOfUnitOfTimeRange=M $grib1_sample $temp
@ -96,7 +96,7 @@ unit=`${tools_dir}/grib_get -p indicatorOfUnitOfTimeRange $temp`
[ "$unit" = "3" ]
# m is for Minute (code 0)
# -------------------------
# ------------------------
${tools_dir}/grib_set -s indicatorOfUnitOfTimeRange=m $grib1_sample $temp
unit=`${tools_dir}/grib_get -p unitOfTimeRange $temp`
[ "$unit" = "0" ]
@ -142,14 +142,14 @@ ${tools_dir}/grib_set -s stepRange:d=14.56 $grib2_sample $temp
grib_check_key_equals $temp "stepRange,startStep,endStep" "14 14 14"
# Key validityDateTime
# -----------------------------------------------
# --------------------
input=${data_dir}/constant_field.grib2
grib_check_key_equals $input "dataDate,dataTime,step" "20061205 1200 6"
grib_check_key_equals $input "validityDate,validityTime" "20061205 1800"
grib_check_key_equals $input "validityDateTime:s" "20061205 001800"
# ECC-1704: Key validityTime as string
# -----------------------------------------------
# -------------------------------------
result=$( ${tools_dir}/grib_get -p validityTime:s -s dataTime=0000 $grib2_sample )
[ "$result" = "0000" ]
input=$data_dir/simple.grib
@ -157,7 +157,7 @@ grib_check_key_equals $input "validityTime:s" "0600"
# Key julianDay
# -----------------------------------------------
# -------------
input=${data_dir}/sample.grib2
grib_check_key_equals $input 'julianDay:i' '2454503'
${tools_dir}/grib_set -s julianDay=2454504 $input $temp
@ -165,12 +165,20 @@ grib_check_key_equals $input day 6
grib_check_key_equals $temp day 7
# Seconds (ignored)
# -----------------------------------------------
# -----------------
${tools_dir}/grib_ls -s second=9 -n time $grib2_sample 2>$templog
# Something should have been written to stderr
[ -s $templog ]
grep -q "Truncating time: non-zero seconds.* ignored" $templog
# Hour or minute set to 255
# ---------------------------
input=${data_dir}/simple.grib
result=$( ${tools_dir}/grib_get -p dataTime -s hour=255 $input )
[ "$result" = "1200" ]
result=$( ${tools_dir}/grib_get -p dataTime -s hour=2,minute=255 $input )
[ "$result" = "200" ]
# Clean up
rm -f $temp $templog
rm -f $grib2File.p8tmp ${grib2File}.tmp x.grib