GRIB-361 test added

This commit is contained in:
Shahram Najm 2013-04-30 13:51:23 +01:00
parent 44b92a8129
commit b23655acfa
3 changed files with 115 additions and 22 deletions

View File

@ -2,31 +2,33 @@
AM_CFLAGS = @WARN_PEDANTIC@ @WERROR@
TESTS = iterator.sh get.sh print_data.sh set.sh keys_iterator.sh multi.sh multi_write.sh \
precision.sh list.sh
precision.sh list.sh large_grib1.sh
noinst_PROGRAMS = nearest set_bitmap iterator get print_data set set_missing keys_iterator \
set_data mars_param values_check box multi multi2 multi_write precision set_pv list sections_copy
bin_PROGRAMS = points
noinst_PROGRAMS = nearest set_bitmap iterator get print_data set set_missing keys_iterator \
set_data mars_param values_check box multi multi2 multi_write precision \
set_pv list sections_copy large_grib1
bin_PROGRAMS = points
box_SOURCES = box.c
set_data_SOURCES = set_data.c
mars_param_SOURCES = mars_param.c
values_check_SOURCES = values_check.c
nearest_SOURCES = nearest.c
multi_write_SOURCES = multi_write.c
get_SOURCES = get.c
print_data_SOURCES = print_data.c
set_SOURCES = set.c
set_missing_SOURCES = set_missing.c
set_bitmap_SOURCES = set_bitmap.c
multi_SOURCES = multi.c
multi2_SOURCES = multi2.c
keys_iterator_SOURCES = keys_iterator.c
iterator_SOURCES = iterator.c
set_pv_SOURCES = set_pv.c
points_SOURCES = points.c
list_SOURCES = list.c
box_SOURCES = box.c
set_data_SOURCES = set_data.c
mars_param_SOURCES = mars_param.c
values_check_SOURCES = values_check.c
nearest_SOURCES = nearest.c
multi_write_SOURCES = multi_write.c
get_SOURCES = get.c
print_data_SOURCES = print_data.c
set_SOURCES = set.c
set_missing_SOURCES = set_missing.c
set_bitmap_SOURCES = set_bitmap.c
multi_SOURCES = multi.c
multi2_SOURCES = multi2.c
keys_iterator_SOURCES = keys_iterator.c
iterator_SOURCES = iterator.c
set_pv_SOURCES = set_pv.c
points_SOURCES = points.c
list_SOURCES = list.c
sections_copy_SOURCES = sections_copy.c
large_grib1_SOURCES = large_grib1.c
INCLUDES = -I$(top_builddir)/src

72
examples/C/large_grib1.c Normal file
View File

@ -0,0 +1,72 @@
/*
* Copyright 2005-2013 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 <stdio.h>
#include <stdlib.h>
#include "grib_api.h"
/* See JIRA issue GRIB-361 */
int main()
{
const int ni = 2880;
const int nj = 2880;
double *values;
int i = 0;
grib_handle *h = NULL;
char* filename = "bigfile.grib";
values = (double*) malloc(ni*nj*sizeof(double));
if (!values) {
printf ("Malloc failed\n");
exit(1);
}
for (i=0; i<ni*nj; i++) {
double rand = random();
values[i] = 10*rand;
}
h = grib_handle_new_from_samples(0, "GRIB1");
GRIB_CHECK(grib_set_long(h, "Ni", ni), 0);
GRIB_CHECK(grib_set_long(h, "Nj", nj), 0);
GRIB_CHECK(grib_set_long(h, "centre", 86), 0);
GRIB_CHECK(grib_set_long(h, "process", 100), 0);
GRIB_CHECK(grib_set_long(h, "indicatorOfTypeOfLevel", 105), 0);
GRIB_CHECK(grib_set_long(h, "level", 2), 0);
GRIB_CHECK(grib_set_long(h, "indicatorOfParameter", 1), 0);
GRIB_CHECK(grib_set_long(h, "table2Version", 1), 0);
GRIB_CHECK(grib_set_long(h, "dataDate", 20130424), 0);
GRIB_CHECK(grib_set_long(h, "dataTime", 0), 0);
GRIB_CHECK(grib_set_long(h, "startStep", 0), 0);
GRIB_CHECK(grib_set_long(h, "endStep", 0), 0);
GRIB_CHECK(grib_set_long(h, "bitmapPresent", 1), 0);
GRIB_CHECK(grib_set_double(h, "iDirectionIncrementInDegrees", 0.125), 0);
GRIB_CHECK(grib_set_double(h, "jDirectionIncrementInDegrees", 0.125), 0);
GRIB_CHECK(grib_set_long(h, "iScansNegatively", 0), 0);
GRIB_CHECK(grib_set_long(h, "jScansPositively", 1), 0);
GRIB_CHECK(grib_set_double(h, "latitudeOfFirstGridPointInDegrees", -90), 0);
GRIB_CHECK(grib_set_double(h, "latitudeOfLastGridPointInDegrees", 90), 0);
GRIB_CHECK(grib_set_double(h, "longitudeOfFirstGridPointInDegrees", -180), 0);
GRIB_CHECK(grib_set_double(h, "longitudeOfLastGridPointInDegrees", 180), 0);
GRIB_CHECK(grib_set_double_array(h, "values", values, ni*nj), 0);
grib_write_message(h, filename, "w");
/*printf("Wrote file %s\n", filename);*/
grib_handle_delete(h);
free (values);
return 0;
}

19
examples/C/large_grib1.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
# Copyright 2005-2013 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.sh
# The executable should produce a GRIB1 file
${examples_dir}large_grib1
# Make sure it can be listed OK
output=${examples_dir}bigfile.grib
${tools_dir}grib_ls $output > /dev/null
rm -f $output