/* * 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 #include #include "grib_api.h" int main(int argc, char *argv[]) { grib_handle* h = NULL; FILE* f = NULL; int i = 0; int err = 0; char *mode = "file"; for(i = 1; i < argc; i++) { if(argv[i][0] == '-') { mode = argv[i]+1; continue; } f = fopen(argv[i],"r"); if(!f) { perror(argv[i]); exit(1); } while((h = grib_handle_new_from_file(0,f,&err)) != NULL) { long width; long height; double max, min; double *values = NULL; size_t count; int i; GRIB_CHECK(grib_get_size(h,"values",&count),0); values = (double *)malloc(sizeof(double)*count); GRIB_CHECK(grib_get_long(h,"Ni",&width),0); GRIB_CHECK(grib_get_long(h,"Nj",&height),0); GRIB_CHECK(grib_get_double_array(h,"values",values,&count),0); max=values[0]; min=values[0]; for (i=1; imax) max = values[i]; if(values[i]