/* * (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. */ /* * C Implementation: bufr_read_tempf * * Description: read and print radiosonde data from TEMP BUFR messages. * If available this version also lists the position information from the WMO list * (now OSCAR/Surface) appended to the reports by ECMWF * * Author: Bruce Ingleby */ /* * Please note that TEMP reports can be encoded in various ways in BUFR. Therefore the code * below might not work directly for other types of TEMP messages than the one used in the * example. It is advised to use bufr_dump to understand the structure of the messages. */ #include "eccodes.h" /* Returns 1 if the bit at 'pos' in 'var' is set. The counting starts at 0 */ #define BTEST(var, pos) ((var) & (1 << (pos))) /* Helper function to fill a double array with values of 'key'. Client must free memory */ static int get_double_array(codes_handle* h, const char* key, double** arr, size_t* size) { CODES_CHECK(codes_get_size(h, key, size), 0); *arr = (double*)malloc(*size * sizeof(double)); return codes_get_double_array(h, key, *arr, size); } /* Helper function to fill an integer (=long) array with values of 'key'. Client must free memory */ static int get_long_array(codes_handle* h, const char* key, long** arr, size_t* size) { CODES_CHECK(codes_get_size(h, key, size), 0); *arr = (long*)malloc(*size * sizeof(long)); return codes_get_long_array(h, key, *arr, size); } /* Reset dimension of input array to 'newsize' and fill with 'fillValue' */ static void realloc_and_fill(double** arr, size_t newsize, double fillValue) { size_t i; free(*arr); *arr = (double*)malloc(newsize * sizeof(double)); for(i=0; i 1) { printf("WMO list lat, lon, ht: %s %g %g %g\n", statid, lat[1], lon[1], htec); } printf("level dtime dlat dlon pressure geopotH airTemp dewPtT windDir windSp signif\n"); for (i = 0; i < sizews; ++i) { long iflag = vssVal[i]; if (!llstdonly || BTEST(iflag, 16)) { printf("%5zu %6ld %7.3f %7.3f %9.1f %8.1f %8.2f %8.2f %8.2f %8.2f %8ld\n", i + 1, timeVal[i], dlatVal[i], dlonVal[i], presVal[i], zVal[i], tVal[i], tdVal[i], wdirVal[i], wspVal[i], vssVal[i]); } } } /* Release memory */ free(lat); free(lon); free(timeVal); free(dlatVal); free(dlonVal); free(presVal); free(zVal); free(tVal); free(tdVal); free(wdirVal); free(wspVal); free(vssVal); codes_handle_delete(h); } fclose(in); printf("Finishing normally. Number of BUFR records read: %d\n", count); return 0; }