Merge branch 'develop' into feature/modernisation-inheritance

This commit is contained in:
Eugen Betke 2024-05-02 12:38:21 +00:00
commit 41a7e62306
16 changed files with 236 additions and 28 deletions

View File

@ -209,7 +209,11 @@ static int init_oblate(grib_handle* h,
sinphi_ = sin(standardParallelInRadians); /* (P->phi0); */
Q__sinb1 = pj_qsfn(sinphi_, e, one_es) / Q__qp;
Q__cosb1 = sqrt(1.0 - Q__sinb1 * Q__sinb1);
Q__dd = cos(standardParallelInRadians) / (sqrt(1. - es * sinphi_ * sinphi_) * Q__rq * Q__cosb1);
if (Q__cosb1 == 0) {
Q__dd = 1.0;
} else {
Q__dd = cos(standardParallelInRadians) / (sqrt(1. - es * sinphi_ * sinphi_) * Q__rq * Q__cosb1);
}
Q__ymf = (Q__xmf = Q__rq) / Q__dd;
Q__xmf *= Q__dd;
@ -253,7 +257,12 @@ static int init_oblate(grib_handle* h,
xy_y *= Q__dd;
rho = hypot(xy_x, xy_y);
Assert(rho >= EPS10); /* TODO(masn): check */
sCe = 2. * asin(.5 * rho / Q__rq);
const double asin_arg = (0.5 * rho / Q__rq);
if (asin_arg < -1.0 || asin_arg > 1.0) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Invalid value: arcsin argument=%g", asin_arg);
return GRIB_GEOCALCULUS_PROBLEM;
}
sCe = 2. * asin(asin_arg);
cCe = cos(sCe);
sCe = sin(sCe);
xy_x *= sCe;

View File

@ -226,6 +226,13 @@ if( HAVE_BUILD_TOOLS )
grib_keys_iter
grib_keys_iter_skip
grib_geo_iter
grib_to_json
grib_to_ppm
grib_merge
big2gribex
grib_sub_area_check
grib_list_keys
grib_histogram
bufr_get_element
bufr_wmo_tables
bufr_extract_headers

23
tests/big2gribex.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/sh
# (C) Copyright 2005- ECMWF.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
#
# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
#
. ./include.ctest.sh
label="big2gribex_test"
tempGrib=temp.$label.grib
if [ ! -x ${tools_dir}/big2gribex ]; then
exit 0
fi
${tools_dir}/big2gribex $data_dir/test.grib1 $tempGrib
# Clean up
rm -f $tempGrib

View File

@ -43,6 +43,7 @@ tempGrib=temp.\$label.grib
tempBufr=temp.\$label.bufr
tempFilt=temp.\$label.filt
tempLog=temp.\$label.log
tempOut=temp.\$label.txt
tempRef=temp.\$label.ref
sample_grib2=\$ECCODES_SAMPLES_PATH/GRIB2.tmpl
@ -61,7 +62,8 @@ sample_bufr4=\$ECCODES_SAMPLES_PATH/BUFR4.tmpl
#\${tools_dir}/bufr_set
#...
rm -f \$tempGrib \$tempBufr \$tempFilt \$tempLog \$tempRef
# Clean up
rm -f \$tempGrib \$tempBufr \$tempFilt \$tempLog \$tempOut \$tempRef
EOF
echo >&2

21
tests/grib_histogram.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/sh
# (C) Copyright 2005- ECMWF.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
#
# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
#
. ./include.ctest.sh
label="grib_histogram_test"
REDIRECT=/dev/null
tempOut=temp.$label.txt
${tools_dir}/grib_histogram $ECCODES_SAMPLES_PATH/GRIB1.tmpl > $tempOut
${tools_dir}/grib_histogram $ECCODES_SAMPLES_PATH/GRIB2.tmpl > $tempOut
# Clean up
rm -f $tempOut

26
tests/grib_list_keys.sh Executable file
View File

@ -0,0 +1,26 @@
#!/bin/sh
# (C) Copyright 2005- ECMWF.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
#
# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
#
. ./include.ctest.sh
label="grib_list_keys_test"
tempOut=temp.$label.txt
if [ -d "$ECCODES_DEFINITION_PATH" ]; then
if [ -x "${tools_dir}/grib_list_keys" ]; then
${tools_dir}/grib_list_keys $ECCODES_DEFINITION_PATH/boot.def > $tempOut
${tools_dir}/grib_list_keys $ECCODES_DEFINITION_PATH/grib2/template.4.2000.def > $tempOut
${tools_dir}/grib_list_keys $ECCODES_DEFINITION_PATH/grib2/template.3.0.def > $tempOut
${tools_dir}/grib_list_keys $ECCODES_DEFINITION_PATH/grib2/template.3.120.def > $tempOut
fi
fi
# Clean up
rm -f $tempOut

22
tests/grib_merge.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/sh
# (C) Copyright 2005- ECMWF.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
#
# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
#
. ./include.ctest.sh
label="grib_merge_test"
tempGrib=temp.$label.grib
f1=$ECCODES_SAMPLES_PATH/regular_ll_pl_grib1.tmpl
f2=$ECCODES_SAMPLES_PATH/regular_ll_sfc_grib1.tmpl
${tools_dir}/grib_merge $f1 $f2 $tempGrib
# Clean up
rm -f $tempGrib

35
tests/grib_sub_area_check.sh Executable file
View File

@ -0,0 +1,35 @@
#!/bin/sh
# (C) Copyright 2005- ECMWF.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
#
# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
#
. ./include.ctest.sh
label="grib_sub_area_check_test"
tempOut=temp.$label.txt
if [ ! -x "${tools_dir}/gg_sub_area_check" ]; then
exit 0
fi
set +e
${tools_dir}/gg_sub_area_check
status=$?
set -e
[ $status -ne 0 ]
f1=$ECCODES_SAMPLES_PATH/GRIB1.tmpl
f2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
${tools_dir}/gg_sub_area_check $f1 $f2 > $tempOut
f1=$ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib1.tmpl
f2=$ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib2.tmpl
${tools_dir}/gg_sub_area_check $f1 $f2 > $tempOut
# Clean up
rm -f $tempOut

43
tests/grib_to_json.sh Executable file
View File

@ -0,0 +1,43 @@
#!/bin/sh
# (C) Copyright 2005- ECMWF.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
#
# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
#
. ./include.ctest.sh
label="grib_to_json_test"
REDIRECT=/dev/null
tempOut=temp.$label.txt
if [ ! -x "${tools_dir}/grib_to_json" ]; then
exit 0
fi
# Currently only works for GRIB edition 1 !!!
${tools_dir}/grib_to_json $ECCODES_SAMPLES_PATH/GRIB1.tmpl > $tempOut
# Decide if we have the JSON verifier commandline utility
JSON_VERIF="json_xs"
JSON_CHECK=""
if command -v $JSON_VERIF >/dev/null 2>&1; then
JSON_CHECK=$JSON_VERIF
fi
# Check the json_xs command actually works!
set +e
echo '[]' | json_xs > $REDIRECT 2>&1
if [ $? -ne 0 ]; then JSON_CHECK=""; fi
set -e
echo "Using $JSON_CHECK ..."
if test "x$JSON_CHECK" != "x"; then
json_xs < $tempOut >$REDIRECT 2> $REDIRECT
fi
# Clean up
rm -f $tempOut

27
tests/grib_to_ppm.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/sh
# (C) Copyright 2005- ECMWF.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
#
# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
#
. ./include.ctest.sh
label="grib_to_ppm_test"
tempOut=temp.$label.txt
if [ ! -x "${tools_dir}/grib2ppm" ]; then
exit 0
fi
# No options
${tools_dir}/grib2ppm
${tools_dir}/grib2ppm -l 6 -u 7 -c $data_dir/sample.grib2 > $tempOut
${tools_dir}/grib2ppm $data_dir/sample.grib2 > $tempOut
# Clean up
rm -f $tempOut

View File

@ -8,18 +8,16 @@
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
/*
* Implementation: big2gribex
*
* Description:
*
*/
#include <stdio.h>
#include <stdlib.h>
#include "grib_api.h"
void usage(char*);
static void usage(const char* progname)
{
printf("\nUsage: %s grib_in grib_out\n", progname);
exit(1);
}
int main(int argc, char* argv[])
{
@ -70,12 +68,5 @@ int main(int argc, char* argv[])
exit(1);
}
return 0;
}
void usage(char* progname)
{
printf("\nUsage: %s grib_in grib_out\n", progname);
exit(1);
}

View File

@ -26,7 +26,7 @@ grib_option grib_options[] = {
{ "A:", 0, 0, 0, 1, 0 },
{ "t:", "factor", "Compare data values using factor multiplied by the tolerance specified in options -R -A.\n", 0, 1, 0 },
{ "w:", 0, 0, 0, 1, 0 },
{ "f", 0, 0, 0, 1, 0 },
{ "f", 0, "Forcefully compare, do not stop after first difference.\n", 0, 1, 0 },
{ "F", 0, 0, 1, 0, 0 },
{ "q", 0, 0, 1, 0, 0 },
{ "M", 0, 0, 1, 0, 0 },

View File

@ -122,7 +122,7 @@ int main(int argc, char* argv[])
continue;
}
f = fopen(argv[i], "r");
f = fopen(argv[i], "rb");
if (!f) {
perror(argv[i]);
exit(1);
@ -226,7 +226,9 @@ int main(int argc, char* argv[])
if (v > ucap) {
v = ucap;
}
c = (v - min) * 65535 / (max - min);
double denom = 1;
if (max != min) denom = max - min;
c = (v - min) * 65535 / denom;
hh = c >> 8;
l = c & 0xff;
printf("%c", hh);

View File

@ -27,7 +27,7 @@ grib_option grib_options[] = {
{ "P", 0, "Compare data values using the packing error as tolerance.\n", 0, 1, 0 },
{ "T:", "factor", "Compare data values using factor multiplied by the tolerance specified in options -P -R -A.\n", 0, 1, 0 },
{ "w:", 0, 0, 0, 1, 0 },
{ "f", 0, 0, 0, 1, 0 },
{ "f", 0, "Forcefully compare, do not stop after first difference.\n", 0, 1, 0 },
{ "F", 0, 0, 1, 0, 0 },
{ "q", 0, 0, 1, 0, 0 },
{ "M", 0, 0, 1, 0, 0 },

View File

@ -23,7 +23,7 @@ grib_option grib_options[] = {
/*{"R:",0,0,0,1,0},*/
/*{"A:",0,0,0,1,0},*/
{ "w:", 0, 0, 0, 1, 0 },
{ "f", 0, 0, 0, 1, 0 },
{ "f", 0, "Forcefully compare, do not stop after first difference.\n", 0, 1, 0 },
{ "F", 0, 0, 1, 0, 0 },
{ "q", 0, 0, 1, 0, 0 },
{ "I", 0, 0, 1, 0, 0 },
@ -559,7 +559,7 @@ static int compare_values(const grib_runtime_options* options, grib_handle* h1,
return GRIB_SUCCESS;
}
static int compare_all_dump_keys(grib_handle* h1, grib_handle* h2, grib_runtime_options* options, int* err)
static int compare_all_dump_keys(grib_handle* h1, grib_handle* h2, grib_runtime_options* options, int* pErr)
{
int ret = 0;
const char* name = NULL;
@ -580,7 +580,7 @@ static int compare_all_dump_keys(grib_handle* h1, grib_handle* h2, grib_runtime_
if (xa == NULL || (xa->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0)
continue;
if (compare_values(options, h1, h2, name, GRIB_TYPE_UNDEFINED)) {
(*err)++;
(*pErr)++;
write_messages(h1, h2);
ret = 1;
}

View File

@ -20,7 +20,7 @@ grib_option grib_options[] = {
{ "R:", 0, 0, 0, 1, 0 },
{ "A:", 0, 0, 0, 1, 0 },
{ "w:", 0, 0, 0, 1, 0 },
{ "f", 0, 0, 0, 1, 0 },
{ "f", 0, "Forcefully compare, do not stop after first difference.\n", 0, 1, 0 },
{ "F", 0, 0, 1, 0, 0 },
{ "q", 0, 0, 1, 0, 0 },
{ "I", 0, 0, 1, 0, 0 },
@ -713,7 +713,7 @@ static int compare_values(const grib_runtime_options* options, grib_handle* h1,
return GRIB_SUCCESS;
}
static int compare_all_dump_keys(grib_handle* h1, grib_handle* h2, grib_runtime_options* options, int* err)
static int compare_all_dump_keys(grib_handle* h1, grib_handle* h2, grib_runtime_options* options, int* pErr)
{
int ret = 0;
const char* name = NULL;
@ -733,7 +733,7 @@ static int compare_all_dump_keys(grib_handle* h1, grib_handle* h2, grib_runtime_
if (xa == NULL || (xa->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0)
continue;
if (compare_values(options, h1, h2, name, GRIB_TYPE_UNDEFINED)) {
(*err)++;
(*pErr)++;
write_messages(h1, h2);
ret = 1;
}