mirror of https://github.com/ecmwf/eccodes.git
Testing: Encoding in parallel from samples
This commit is contained in:
parent
e5f63fc3cc
commit
90c393a0c2
|
@ -42,12 +42,12 @@
|
||||||
141 141 Layer between two isobaric surfaces (mixed precision) pressure of top, in kPa 1100hPa minus pressure of bottom, in hPa
|
141 141 Layer between two isobaric surfaces (mixed precision) pressure of top, in kPa 1100hPa minus pressure of bottom, in hPa
|
||||||
# 142-159 Reserved
|
# 142-159 Reserved
|
||||||
160 dp Depth below sea level meters (2 octets)
|
160 dp Depth below sea level meters (2 octets)
|
||||||
# 161-199Reserved
|
# 161-199 Reserved
|
||||||
200 sfc Entire atmosphere considered as a single layer 0 (2 octets)
|
200 sfc Entire atmosphere considered as a single layer 0 (2 octets)
|
||||||
201 201 Entire ocean considered as a single layer 0 (2 octets)
|
201 201 Entire ocean considered as a single layer 0 (2 octets)
|
||||||
202 al Abstract Single Level
|
202 al Abstract Single Level
|
||||||
203 al Abstract Multiple Level
|
203 al Abstract Multiple Level
|
||||||
# 202-209 Reserved
|
# 204-209 Reserved
|
||||||
210 pl Isobaric surface (Pa) (ECMWF extension)
|
210 pl Isobaric surface (Pa) (ECMWF extension)
|
||||||
# 211-254 Reserved for local use
|
# 211-254 Reserved for local use
|
||||||
211 wv Ocean wave level (ECMWF extension)
|
211 wv Ocean wave level (ECMWF extension)
|
||||||
|
|
|
@ -26,19 +26,24 @@ int opt_write = 0; /* If 1 write handle to file */
|
||||||
|
|
||||||
static int encode_values(grib_handle* h, char* output_file)
|
static int encode_values(grib_handle* h, char* output_file)
|
||||||
{
|
{
|
||||||
double* values;
|
double* values = NULL;
|
||||||
const size_t DIM = 1000;
|
long numberOfDataPoints = 0;
|
||||||
size_t size = DIM * DIM;
|
GRIB_CHECK(grib_get_long(h, "numberOfDataPoints", &numberOfDataPoints), 0);
|
||||||
size_t i = 0;
|
size_t size = numberOfDataPoints;
|
||||||
values = (double*)malloc(size * sizeof(double));
|
|
||||||
for (i = 0; i < size; ++i) {
|
values = (double*)malloc(size * sizeof(double));
|
||||||
|
for (size_t i = 0; i < size; ++i) {
|
||||||
double v = i;
|
double v = i;
|
||||||
if (i % DIM == 0) v = 0;
|
if (i % size == 0) v = 0;
|
||||||
values[i] = v;
|
values[i] = v;
|
||||||
}
|
}
|
||||||
GRIB_CHECK(grib_set_long(h, "bitsPerValue", 16), 0);
|
GRIB_CHECK(grib_set_long(h, "bitsPerValue", 16), 0);
|
||||||
GRIB_CHECK(grib_set_double_array(h, "values", values, size), 0);
|
GRIB_CHECK(grib_set_double_array(h, "values", values, size), 0);
|
||||||
free(values);
|
free(values);
|
||||||
|
if (opt_dump) {
|
||||||
|
FILE* devnull = fopen("/dev/null", "w");
|
||||||
|
grib_dump_content(h, devnull, "wmo", 0, NULL);
|
||||||
|
}
|
||||||
return GRIB_SUCCESS;
|
return GRIB_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,6 +67,7 @@ int main(int argc, char** argv)
|
||||||
char* mode;
|
char* mode;
|
||||||
if (argc < 5 || argc > 7) {
|
if (argc < 5 || argc > 7) {
|
||||||
fprintf(stderr, "Usage:\n\t%s [options] seq sample numRuns numIter\nOr\n\t%s [options] par sample numThreads numIter\n", prog, prog);
|
fprintf(stderr, "Usage:\n\t%s [options] seq sample numRuns numIter\nOr\n\t%s [options] par sample numThreads numIter\n", prog, prog);
|
||||||
|
fprintf(stderr, "Options:\n\t-d: do a dump\n\t-c: clone\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +150,12 @@ void do_encode(void* ptr)
|
||||||
hs = grib_handle_new_from_samples(0, INPUT_FILE);
|
hs = grib_handle_new_from_samples(0, INPUT_FILE);
|
||||||
|
|
||||||
for (i = 0; i < FILES_PER_ITERATION; i++) {
|
for (i = 0; i < FILES_PER_ITERATION; i++) {
|
||||||
grib_handle* h = grib_handle_clone(hs);
|
grib_handle* h = NULL;
|
||||||
|
if (opt_clone) {
|
||||||
|
h = grib_handle_clone(hs);
|
||||||
|
} else {
|
||||||
|
h = hs;
|
||||||
|
}
|
||||||
if (opt_write) {
|
if (opt_write) {
|
||||||
snprintf(output_file, 50, "output/output_file_%zu-%zu.grib", data->number, i);
|
snprintf(output_file, 50, "output/output_file_%zu-%zu.grib", data->number, i);
|
||||||
encode_values(h, output_file);
|
encode_values(h, output_file);
|
||||||
|
@ -152,7 +163,8 @@ void do_encode(void* ptr)
|
||||||
else {
|
else {
|
||||||
encode_values(h, NULL);
|
encode_values(h, NULL);
|
||||||
}
|
}
|
||||||
grib_handle_delete(h);
|
if (opt_clone)
|
||||||
|
grib_handle_delete(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
ltime = time(NULL);
|
ltime = time(NULL);
|
||||||
|
|
Loading…
Reference in New Issue