mirror of https://github.com/ecmwf/eccodes.git
Testing: Cleanup
This commit is contained in:
parent
6f10faac1c
commit
0514d24a72
|
@ -25,12 +25,6 @@ static double compare_double_absolute(double a, double b, double tolerance)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void usage(const char* prog)
|
||||
{
|
||||
fprintf(stderr, "usage: %s input\n", prog);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static int check_error_code(int err)
|
||||
{
|
||||
if (err == GRIB_INVALID_BPV || err == GRIB_DECODING_ERROR)
|
||||
|
@ -49,7 +43,7 @@ int main(int argc, char** argv)
|
|||
grib_handle* h;
|
||||
char* filename;
|
||||
|
||||
if (argc < 2) usage(argv[0]);
|
||||
Assert(argc == 2);
|
||||
filename = argv[1];
|
||||
|
||||
for (i = 0; i < 255; i++) {
|
||||
|
|
|
@ -26,21 +26,14 @@ int main(int argc, char** argv)
|
|||
double dmin, dmax, dval;
|
||||
float fval;
|
||||
|
||||
FILE* in = NULL;
|
||||
const char* filename = 0;
|
||||
codes_handle* h = NULL;
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "usage: %s file\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
filename = argv[1];
|
||||
Assert(argc == 2);
|
||||
const char* filename = argv[1];
|
||||
|
||||
printf("Opening %s\n", filename);
|
||||
in = fopen(filename, "rb");
|
||||
FILE* in = fopen(filename, "rb");
|
||||
Assert(in);
|
||||
|
||||
h = codes_handle_new_from_file(0, in, PRODUCT_GRIB, &err);
|
||||
codes_handle* h = codes_handle_new_from_file(0, in, PRODUCT_GRIB, &err);
|
||||
Assert(h);
|
||||
|
||||
CODES_CHECK(codes_get_float(h, "referenceValue", &fval), 0);
|
||||
|
|
|
@ -9,18 +9,11 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Description: Reads a GRIB message from file, measures read time.
|
||||
*
|
||||
* Description: Reads a GRIB message from file, measures time taken
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "grib_api_internal.h"
|
||||
|
||||
static void usage(const char* prog)
|
||||
{
|
||||
printf("usage: %s filename\n", prog);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
grib_timer* tes = grib_get_timer(0, "decoding", 0, 0);
|
||||
|
@ -33,21 +26,15 @@ int main(int argc, char** argv)
|
|||
const double duration_max = 3.6; /* seconds */
|
||||
const int num_repetitions = 100;
|
||||
|
||||
if (argc < 2) usage(argv[0]);
|
||||
if (argc < 2) return 1;
|
||||
|
||||
in = fopen(argv[1], "rb");
|
||||
if (!in) {
|
||||
printf("ERROR: unable to open file %s\n", argv[1]);
|
||||
return 1;
|
||||
}
|
||||
Assert(in);
|
||||
|
||||
/* create new handle */
|
||||
err = 0;
|
||||
h = grib_handle_new_from_file(0, in, &err);
|
||||
if (h == NULL) {
|
||||
printf("Error: unable to create handle from file.\n");
|
||||
return 1;
|
||||
}
|
||||
Assert(h);
|
||||
|
||||
/* get the size of the values array*/
|
||||
GRIB_CHECK(grib_get_size(h, "values", &values_len), 0);
|
||||
|
@ -72,9 +59,3 @@ int main(int argc, char** argv)
|
|||
fclose(in);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// int main(int argc, char** argv)
|
||||
// {
|
||||
// return 0;
|
||||
// }
|
||||
// #endif
|
||||
|
|
|
@ -8,25 +8,14 @@
|
|||
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
*/
|
||||
|
||||
/*
|
||||
* test: reading GRIB2 multi fields messages from memory
|
||||
*/
|
||||
/* Test: reading GRIB2 multi fields messages from memory */
|
||||
|
||||
#include "grib_api_internal.h"
|
||||
|
||||
|
||||
static void usage(const char* prog)
|
||||
{
|
||||
fprintf(stderr, "usage: %s [-m] file.grib\n", prog);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
struct stat finfo;
|
||||
char shortName[20] = {
|
||||
0,
|
||||
};
|
||||
char shortName[20] = {0,};
|
||||
size_t len;
|
||||
grib_handle* h = NULL;
|
||||
size_t fsize;
|
||||
|
@ -49,25 +38,18 @@ int main(int argc, char* argv[])
|
|||
else if (argc == 2)
|
||||
filename = argv[1];
|
||||
else
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
|
||||
Assert(filename);
|
||||
f = fopen(filename, "rb");
|
||||
if (!f) {
|
||||
perror(filename);
|
||||
exit(1);
|
||||
}
|
||||
Assert(f);
|
||||
|
||||
stat(filename, &finfo);
|
||||
fsize = finfo.st_size;
|
||||
|
||||
data = (unsigned char*)malloc(fsize);
|
||||
p = data;
|
||||
|
||||
if (!data) {
|
||||
fprintf(stderr, "unable to allocate %ld bytes\n", (long)fsize);
|
||||
exit(1);
|
||||
}
|
||||
Assert(data);
|
||||
|
||||
if (fread(data, 1, fsize, f) != fsize) {
|
||||
perror(filename);
|
||||
|
|
Loading…
Reference in New Issue