Merge branch 'develop' into feature/Performance_nearest

This commit is contained in:
Shahram Najm 2022-06-10 21:27:29 +01:00
commit e0188ee4e7
18 changed files with 181 additions and 29 deletions

View File

@ -2682,7 +2682,7 @@
parameterNumber = 0 ;
}
#Precipitation type (most severe) in the last 1 hour
'sev_ptype1h' = {
'ptype_sev1h' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 19 ;
@ -2691,7 +2691,7 @@
lengthOfTimeRange = 1 ;
}
#Precipitation type (most severe) in the last 3 hours
'sev_ptype3h' = {
'ptype_sev3h' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 19 ;
@ -2700,7 +2700,7 @@
lengthOfTimeRange = 3 ;
}
#Precipitation type (most frequent) in the last 1 hour
'freq_ptype1h' = {
'ptype_freq1h' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 19 ;
@ -2709,7 +2709,7 @@
lengthOfTimeRange = 1 ;
}
#Precipitation type (most frequent) in the last 3 hours
'freq_ptype3h' = {
'ptype_freq3h' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 19 ;
@ -2717,6 +2717,24 @@
typeOfStatisticalProcessing = 101 ;
lengthOfTimeRange = 3 ;
}
#Precipitation type (most severe) in the last 6 hours
'ptype_sev6h' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 19 ;
indicatorOfUnitForTimeRange = 1 ;
typeOfStatisticalProcessing = 100 ;
lengthOfTimeRange = 6 ;
}
#Precipitation type (most frequent) in the last 6 hours
'ptype_freq6h' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 19 ;
indicatorOfUnitForTimeRange = 1 ;
typeOfStatisticalProcessing = 101 ;
lengthOfTimeRange = 6 ;
}
#Soil temperature
'sot' = {
discipline = 2 ;

View File

@ -2717,6 +2717,24 @@
typeOfStatisticalProcessing = 101 ;
lengthOfTimeRange = 3 ;
}
#Precipitation type (most severe) in the last 6 hours
'Precipitation type (most severe) in the last 6 hours' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 19 ;
indicatorOfUnitForTimeRange = 1 ;
typeOfStatisticalProcessing = 100 ;
lengthOfTimeRange = 6 ;
}
#Precipitation type (most frequent) in the last 6 hours
'Precipitation type (most frequent) in the last 6 hours' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 19 ;
indicatorOfUnitForTimeRange = 1 ;
typeOfStatisticalProcessing = 101 ;
lengthOfTimeRange = 6 ;
}
#Soil temperature
'Soil temperature' = {
discipline = 2 ;

View File

@ -2717,6 +2717,24 @@
typeOfStatisticalProcessing = 101 ;
lengthOfTimeRange = 3 ;
}
#Precipitation type (most severe) in the last 6 hours
'260338' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 19 ;
indicatorOfUnitForTimeRange = 1 ;
typeOfStatisticalProcessing = 100 ;
lengthOfTimeRange = 6 ;
}
#Precipitation type (most frequent) in the last 6 hours
'260339' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 19 ;
indicatorOfUnitForTimeRange = 1 ;
typeOfStatisticalProcessing = 101 ;
lengthOfTimeRange = 6 ;
}
#Soil temperature
'260360' = {
discipline = 2 ;

View File

@ -2682,7 +2682,7 @@
parameterNumber = 0 ;
}
#Precipitation type (most severe) in the last 1 hour
'sev_ptype1h' = {
'ptype_sev1h' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 19 ;
@ -2691,7 +2691,7 @@
lengthOfTimeRange = 1 ;
}
#Precipitation type (most severe) in the last 3 hours
'sev_ptype3h' = {
'ptype_sev3h' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 19 ;
@ -2700,7 +2700,7 @@
lengthOfTimeRange = 3 ;
}
#Precipitation type (most frequent) in the last 1 hour
'freq_ptype1h' = {
'ptype_freq1h' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 19 ;
@ -2709,7 +2709,7 @@
lengthOfTimeRange = 1 ;
}
#Precipitation type (most frequent) in the last 3 hours
'freq_ptype3h' = {
'ptype_freq3h' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 19 ;
@ -2717,6 +2717,24 @@
typeOfStatisticalProcessing = 101 ;
lengthOfTimeRange = 3 ;
}
#Precipitation type (most severe) in the last 6 hours
'ptype_sev6h' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 19 ;
indicatorOfUnitForTimeRange = 1 ;
typeOfStatisticalProcessing = 100 ;
lengthOfTimeRange = 6 ;
}
#Precipitation type (most frequent) in the last 6 hours
'ptype_freq6h' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 19 ;
indicatorOfUnitForTimeRange = 1 ;
typeOfStatisticalProcessing = 101 ;
lengthOfTimeRange = 6 ;
}
#Soil temperature
'sot' = {
discipline = 2 ;

View File

@ -2717,6 +2717,24 @@
typeOfStatisticalProcessing = 101 ;
lengthOfTimeRange = 3 ;
}
#Precipitation type (most severe) in the last 6 hours
'code table (4.201)' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 19 ;
indicatorOfUnitForTimeRange = 1 ;
typeOfStatisticalProcessing = 100 ;
lengthOfTimeRange = 6 ;
}
#Precipitation type (most frequent) in the last 6 hours
'code table (4.201)' = {
discipline = 0 ;
parameterCategory = 1 ;
parameterNumber = 19 ;
indicatorOfUnitForTimeRange = 1 ;
typeOfStatisticalProcessing = 101 ;
lengthOfTimeRange = 6 ;
}
#Soil temperature
'K' = {
discipline = 2 ;

View File

@ -1047,7 +1047,7 @@ int grib_f_open_file_(int* fid, char* name , char* op, int lname, int lop) {
while (*p != '\0') { *p=tolower(*p);p++;}
trimmed = cast_char_no_cut(fname,name,lname); /* ECC-1392 */
rtrim( trimmed );
string_rtrim( trimmed );
f = fopen(trimmed, oper);
if(!f) {
ioerr=errno;
@ -2891,7 +2891,7 @@ int grib_f_index_select_string_(int* gid, char* key, char* val, int len, int val
/* ECC-1316 */
cast_char_no_cut(bufval,val,vallen);
rtrim( bufval );
string_rtrim( bufval );
return grib_index_select_string(h, cast_char(buf,key,len), bufval);
}
@ -3257,7 +3257,7 @@ int grib_f_set_string_array_(int* gid, char* key, char* val,int* nvals,int* slen
for (i=0;i<lsize;i++) {
cval[i]=(char*)grib_context_malloc_clear(c,sizeof(char)* (*slen+1));
cast_char_no_cut(cval[i],p,*slen);
rtrim( cval[i] ); /* trim spaces at end of string */
string_rtrim( cval[i] ); /* trim spaces at end of string */
p+= *slen;
}
err = grib_set_string_array(h, cast_char(buf,key,len), (const char **)cval, lsize);
@ -3327,7 +3327,7 @@ int grib_f_set_string_(int* gid, char* key, char* val, int len, int len2){
/* So do not use cast_char. cast_char_no_cut does not stop at first space */
val_str = cast_char_no_cut(buf2,val,len2);
if (val_str && !is_all_spaces(val_str)) {
rtrim( val_str ); /* trim spaces at end of string */
string_rtrim( val_str ); /* trim spaces at end of string */
}
return grib_set_string(h, cast_char(buf,key,len), val_str, &lsize);

View File

@ -282,7 +282,7 @@ static int bufr_decode_extra_rdb_keys(const void* message, long offset_section2,
}
temp[i] = '\0';
pTemp = temp;
lrtrim(&pTemp, 1, 1); /* Trim left and right */
string_lrtrim(&pTemp, 1, 1); /* Trim left and right */
strncpy(hdr->ident, pTemp, IDENT_LEN - 1);
}

View File

@ -1457,16 +1457,17 @@ int codes_bufr_key_is_header(const grib_handle* h, const char* key, int* err);
/* string_util.c */
int strcmp_nocase(const char* s1, const char* s2);
void rtrim(char* s);
void lrtrim(char** x, int do_left, int do_right);
void string_rtrim(char* s);
void string_lrtrim(char** x, int do_left, int do_right);
const char* extract_filename(const char* filepath);
char** string_split(char* inputString, const char* delimiter);
int string_to_long(const char* input, long* output);
int string_ends_with(const char* str1, const char* str2);
int count_char_in_string(const char* str, char c);
int string_count_char(const char* str, char c);
const char* codes_get_product_name(ProductKind product);
const char* grib_get_type_name(int type);
char* string_replace_char(char *str, char oldc, char newc);
void string_remove_char(char * str, char c);
/* functions.c */
long grib_op_eq(long a, long b);

View File

@ -506,7 +506,7 @@ static int grib_load_codetable(grib_context* c, const char* filename,
Assert(*abbreviation);
Assert(*title);
rtrim(title); /* ECC-1315 */
string_rtrim(title); /* ECC-1315 */
if (t->entries[code].abbreviation != NULL) {
grib_context_log(c, GRIB_LOG_WARNING, "code_table_entry: duplicate code in %s: %d (table size=%ld)", filename, code, size);

View File

@ -161,7 +161,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
err = grib_get_string(h, self->input, input, &size);
if (err) return err;
lrtrim(&pInput, self->trim_left, self->trim_right);
string_lrtrim(&pInput, self->trim_left, self->trim_right);
sprintf(val, "%s", pInput);
size = strlen(val);
*len = size + 1;
@ -189,7 +189,7 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len)
sprintf(buf, "%s", val);
pBuf = buf;
lrtrim(&pBuf, self->trim_left, self->trim_right);
string_lrtrim(&pBuf, self->trim_left, self->trim_right);
return grib_pack_string(inputAccesstor, pBuf, len);
}

View File

@ -707,6 +707,8 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
while (*p) {
if (!isprint(*p))
*p = '.';
if (*p == '"')
*p = '\''; /* ECC-1401 */
p++;
}

View File

@ -646,6 +646,8 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
while (*p) {
if (!isprint(*p))
*p = '.';
if (*p == '"')
*p = '\''; /* ECC-1401 */
p++;
}

View File

@ -660,6 +660,8 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
while (*p) {
if (!isprint(*p))
*p = '.';
if (*p == '"')
*p = '\''; /* ECC-1401 */
p++;
}

View File

@ -498,6 +498,8 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment)
while (*p) {
if (!isprint(*p))
*p = '.';
if (*p == '"')
*p = '\''; /* ECC-1401 */
p++;
}

View File

@ -27,7 +27,7 @@ int strcmp_nocase(const char* s1, const char* s2)
}
/* Strip whitespace from the end of a string */
void rtrim(char* s)
void string_rtrim(char* s)
{
size_t len = 0;
if (!s)
@ -38,7 +38,7 @@ void rtrim(char* s)
s[len] = '\0';
}
void lrtrim(char** x, int do_left, int do_right)
void string_lrtrim(char** x, int do_left, int do_right)
{
DebugAssert(do_left || do_right);
if (do_left) {
@ -161,7 +161,7 @@ int string_ends_with(const char* s, const char* suffix)
return 0;
}
int count_char_in_string(const char* str, char c)
int string_count_char(const char* str, char c)
{
int i = 0, count = 0;
DebugAssert(str);
@ -208,3 +208,30 @@ const char* grib_get_type_name(int type)
}
return "unknown";
}
/* Replace all occurrences of character in string.
* Returns pointer to the NUL byte at the end of 's'
*/
char *string_replace_char(char *s, char oldc, char newc)
{
for (; *s; ++s)
if (*s == oldc)
*s = newc;
return s;
}
/* Remove all instances of character 'c' from 'str' */
void string_remove_char(char * str, char c)
{
size_t i, j;
size_t len = strlen(str);
for(i=0; i<len; i++) {
if(str[i] == c) {
for(j=i; j<len; j++) {
str[j] = str[j+1];
}
len--;
i--;
}
}
}

View File

@ -10,6 +10,12 @@
. ./include.ctest.sh
label="bufr_json_data_test"
tempRules=temp.${label}.filter
tempOut=temp.${label}.txt
tempBufr=temp.${label}.bufr
REDIRECT=/dev/null
cd ${data_dir}/bufr
@ -49,6 +55,7 @@ for file in ${bufr_files}; do
done
# ECC-233: Test JSON dump when selecting messages with '-w' switch
# -----------------------------------------------------------------
file=tropical_cyclone.bufr
for c in 1 3 1/3; do
${tools_dir}/bufr_dump -w count=$c $file 2> $REDIRECT > ${file}.json
@ -60,5 +67,24 @@ done
# ECC-272
# ------------
file=aaen_55.bufr
${tools_dir}/bufr_dump -jf $file | grep -q -w channelRadiance
# ECC-1401: BUFR: bufr_dump generates invalid JSON
# -------------------------------------------------
cat > $tempRules <<EOF
set unexpandedDescriptors = { 1015 };
set stationOrSiteName = 'Contains "bad" chars';
set pack = 1;
write;
EOF
${tools_dir}/codes_bufr_filter -o $tempBufr $tempRules $samp_dir/BUFR4.tmpl
${tools_dir}/bufr_dump $tempBufr > $tempOut
if test "x$JSON_CHECK" != "x"; then
json_xs -t none < $tempOut
fi
rm -f $tempRules $tempOut $tempBufr

View File

@ -1511,19 +1511,19 @@ static void test_trimming()
printf("Testing: test_trimming...\n");
lrtrim(&pA, 0, 1); /*right only*/
string_lrtrim(&pA, 0, 1); /*right only*/
assert( strcmp(pA, " Standing")==0 );
lrtrim(&pB, 1, 0); /*left only*/
string_lrtrim(&pB, 1, 0); /*left only*/
assert( strcmp(pB, "Weeping ")==0 );
lrtrim(&pC, 1, 1); /*both ends*/
string_lrtrim(&pC, 1, 1); /*both ends*/
assert( strcmp(pC, "Silhouette")==0 );
lrtrim(&pD, 1, 1); /*make sure other spaces are not removed*/
string_lrtrim(&pD, 1, 1); /*make sure other spaces are not removed*/
assert( strcmp(pD, "The Forest Of October")==0 );
lrtrim(&pE, 1, 1); /* Other chars */
string_lrtrim(&pE, 1, 1); /* Other chars */
assert( strcmp(pE, "Apostle In Triumph")==0 );
}

View File

@ -135,7 +135,7 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
if (grib_options_on("L:")) {
/* Do a very basic sanity check */
const char* str = grib_options_get_option("L:");
if (count_char_in_string(str, '%') != 2) {
if (string_count_char(str, '%') != 2) {
fprintf(stderr, "ERROR: Invalid lats/lons format option \"%s\".\nThe default is: \"%s\"\n",
str, default_format_latlons);
exit(1);