Merge branch 'develop' of ssh://git.ecmwf.int/eccodes/eccodes into develop

This commit is contained in:
Marijana Crepulja 2019-11-14 14:45:41 +00:00
commit 617d5a9147
24 changed files with 7916 additions and 7887 deletions

View File

@ -13,7 +13,7 @@ transient setToMissingIfOutOfRange=0 : hidden;
# This gets updated twice a year by WMO. # This gets updated twice a year by WMO.
# See http://www.wmo.int/pages/prog/www/WMOCodes/WMO306_vI2/LatestVERSION/LatestVERSION.html # See http://www.wmo.int/pages/prog/www/WMOCodes/WMO306_vI2/LatestVERSION/LatestVERSION.html
constant masterTablesVersionNumberLatest = 32; constant masterTablesVersionNumberLatest = 33;
#negative value=not used #negative value=not used
transient inputDelayedDescriptorReplicationFactor={-1} : hidden; transient inputDelayedDescriptorReplicationFactor={-1} : hidden;

View File

@ -20,7 +20,7 @@ unsigned[1] localTablesVersionNumber : dump;
transient typicalCentury=21; transient typicalCentury=21;
unsigned[1] typicalYearOfCentury : dump; unsigned[1] typicalYearOfCentury : dump;
transient typicalYear = (typicalCentury - 1 ) *100 + typicalYearOfCentury : no_copy; transient typicalYear = (typicalCentury - 1) * 100 + typicalYearOfCentury : no_copy;
unsigned[1] typicalMonth : dump; unsigned[1] typicalMonth : dump;
unsigned[1] typicalDay : dump; unsigned[1] typicalDay : dump;

View File

@ -1,13 +1,13 @@
# Copyright 2005-2019 ECMWF. # Copyright 2005-2019 ECMWF.
section_length[3] section2Length ; section_length[3] section2Length;
unsigned[1] reservedSection2 = 0; unsigned[1] reservedSection2 = 0;
if(bufrHeaderCentre == 98) { if(bufrHeaderCentre == 98) {
if (section2Length==52 or new() ) { if (section2Length==52 or new() ) {
template rdb_key "bufr/rdb_key.def"; template rdb_key "bufr/rdb_key.def";
} }
if (section2Length==28) { if (section2Length==28) {
template rdb_key "bufr/rdb_key_28.def"; template rdb_key "bufr/rdb_key_28.def";
} }
} }
section_padding section2Padding; section_padding section2Padding;

View File

@ -872,7 +872,7 @@
015051|meteorologicalOpticalRange|long|METEOROLOGICAL OPTICAL RANGE|m|0|0|18|m|0|6 015051|meteorologicalOpticalRange|long|METEOROLOGICAL OPTICAL RANGE|m|0|0|18|m|0|6
015052|log10OfNumberDensityOfAerosolParticlesWithDiameterGreaterThan5Nm|double|LOG10 OF NUMBER DENSITY OF AEROSOL PARTICLES WITH DIAMETER GREATER THAN 5 NM|log (m-3)|1|60|6|log (m-3)|1|3 015052|log10OfNumberDensityOfAerosolParticlesWithDiameterGreaterThan5Nm|double|LOG10 OF NUMBER DENSITY OF AEROSOL PARTICLES WITH DIAMETER GREATER THAN 5 NM|log (m-3)|1|60|6|log (m-3)|1|3
015053|log10OfNumberDensityOfAerosolParticlesWithDiameterGreaterThan14Nm|double|LOG10 OF NUMBER DENSITY OF AEROSOL PARTICLES WITH DIAMETER GREATER THAN 14 NM|log (m-3)|2|600|9|log (m-3)|2|4 015053|log10OfNumberDensityOfAerosolParticlesWithDiameterGreaterThan14Nm|double|LOG10 OF NUMBER DENSITY OF AEROSOL PARTICLES WITH DIAMETER GREATER THAN 14 NM|log (m-3)|2|600|9|log (m-3)|2|4
015054|log10OfNumberDensityOfAerosolParticlesWithDiameterBetween0p25And2p5|double|LOG10 OF NUMBER DENSITY OF AEROSOL PARTICLES WITH DIAMETER BETWEEN 0.25 AND 2.5 µM|log (m-3)|2|550|9|log (m-3)|2|4 015054|log10OfNumberDensityOfAerosolParticlesWithDiameterBetween0p25And2p5|double|LOG10 OF NUMBER DENSITY OF AEROSOL PARTICLES WITH DIAMETER BETWEEN 0.25 AND 2.5 uM|log (m-3)|2|550|9|log (m-3)|2|4
015055|nonVolatileAerosolRatio|long|NON VOLATILE AEROSOL RATIO|Numeric|2|0|7|Numeric|2|3 015055|nonVolatileAerosolRatio|long|NON VOLATILE AEROSOL RATIO|Numeric|2|0|7|Numeric|2|3
015062|aerosolOpticalThickness|long|AEROSOL OPTICAL THICKNESS|Numeric|3|-1000|14|Numeric|3|5 015062|aerosolOpticalThickness|long|AEROSOL OPTICAL THICKNESS|Numeric|3|-1000|14|Numeric|3|5
015063|attenuatedBackscatter|double|ATTENUATED BACKSCATTER|m-1 sr-1|8|0|20|m-1 sr-1|8|7 015063|attenuatedBackscatter|double|ATTENUATED BACKSCATTER|m-1 sr-1|8|0|20|m-1 sr-1|8|7

View File

@ -0,0 +1,65 @@
# Copyright 2005-2019 ECMWF.
# Seasonal forecast monthly mean data for lagged systems
constant GRIBEXSection1Problem = 120 - section1Length ;
# used in local definition 13
transient localFlag=1 : hidden;
template mars_labeling "grib1/mars_labeling.def";
unsigned[2] perturbationNumber : dump ;
unsigned[2] systemNumber : dump ;
unsigned[2] methodNumber : dump ;
unsigned[4] verifyingMonth : dump ;
meta endOfInterval g1end_of_interval_monthly(verifyingMonth);
meta yearOfEndOfOverallTimeInterval vector(endOfInterval,0);
meta monthOfEndOfOverallTimeInterval vector(endOfInterval,1);
meta dayOfEndOfOverallTimeInterval vector(endOfInterval,2);
meta hourOfEndOfOverallTimeInterval vector(endOfInterval,3);
meta minuteOfEndOfOverallTimeInterval vector(endOfInterval,4);
meta secondOfEndOfOverallTimeInterval vector(endOfInterval,5);
transient hourOfEndOfOverallTimeInterval=23 : no_copy;
transient minuteOfEndOfOverallTimeInterval=59 : no_copy;
transient secondOfEndOfOverallTimeInterval=59 : no_copy;
transient indicatorOfUnitForTimeRange=3;
transient lengthOfTimeRange=1;
unsigned[1] averagingPeriod : dump ;
transient typeOfStatisticalProcessing=0;
transient indicatorOfUnitForTimeIncrement = 1;
transient timeIncrement=averagingPeriod;
unsigned[2] forecastMonth : dump ;
remove forecastTime;
transient forecastTime=forecastMonth - 1;
#remove typeOfTimeIncrement;
transient typeOfTimeIncrement = 3;
# Old GRIBS do not have forecast forecastMonth set. It is computed from verifyingMonth
meta marsForecastMonth g1forecastmonth(verifyingMonth,dataDate,day,hour,forecastMonth) : read_only;
alias origin = centre;
alias number = perturbationNumber;
alias system = systemNumber;
alias method = methodNumber;
# ECC-679
unsigned[2] numberOfForecastsInEnsemble : dump ;
alias totalNumber=numberOfForecastsInEnsemble;
unsigned[4] indexingDate: dump; # MARS archiving date (YYYYMMDD)
unsigned[2] indexingTime: dump; # MARS archiving time (HHMM)
alias mars.date = indexingDate;
alias mars.time = indexingTime;
# spareSetToZero
pad padding_loc12_1(50);

View File

@ -9,6 +9,7 @@
9 9 Singular vectors and ensemble perturbations 9 9 Singular vectors and ensemble perturbations
10 10 EPS tubes 10 10 EPS tubes
11 11 Supplementary data used by the analysis 11 11 Supplementary data used by the analysis
12 12 Seasonal forecast monthly mean data for lagged systems
13 13 Wave 2D spectra direction and frequency 13 13 Wave 2D spectra direction and frequency
14 14 Brightness temperature 14 14 Brightness temperature
15 15 Seasonal forecast data 15 15 Seasonal forecast data

View File

@ -1,6 +1,5 @@
# START grib1::section # GRIB1 SECTION 4, Binary data section
# SECTION 4, Binary data section # Length of section
# Length of section
position offsetSection4; position offsetSection4;
# Due to a trick done by GRIBEX to support large GRIBs, we need a special treatment # Due to a trick done by GRIBEX to support large GRIBs, we need a special treatment
@ -125,9 +124,8 @@ alias ls.packingType=packingType;
alias typeOfPacking=packingType; alias typeOfPacking=packingType;
if( binaryScaleFactor == -32767) { if( binaryScaleFactor == -32767) {
unsigned[1] bitsPerValue : dump ;
unsigned[1] bitsPerValue : dump ; alias numberOfBitsContainingEachPackedValue = bitsPerValue;
alias numberOfBitsContainingEachPackedValue = bitsPerValue;
constant dataRepresentationTemplateNumber = 0; constant dataRepresentationTemplateNumber = 0;
constant bitMapIndicator = 0; constant bitMapIndicator = 0;
@ -148,8 +146,8 @@ alias numberOfBitsContainingEachPackedValue = bitsPerValue;
decimalScaleFactor, decimalScaleFactor,
optimizeScaleFactor, optimizeScaleFactor,
halfByte, halfByte,
packingType, packingType,
grid_ieee,precision, grid_ieee,precision,
missingValue, missingValue,
numberOfPoints, numberOfPoints,
bitmap bitmap
@ -169,7 +167,7 @@ if (bitmapPresent==1) {
} }
_if (sphericalHarmonics) { _if (sphericalHarmonics) {
alias numberOfEffectiveValues=numberOfValues; alias numberOfEffectiveValues=numberOfValues;
} }
meta changeDecimalPrecision decimal_precision(bitsPerValue,decimalScaleFactor,changingPrecision,values) : edition_specific; meta changeDecimalPrecision decimal_precision(bitsPerValue,decimalScaleFactor,changingPrecision,values) : edition_specific;
@ -220,7 +218,6 @@ concept gridType {
"regular_stretched_gg" = { dataRepresentationType = 24; sphericalHarmonics = 0; PLPresent=0; } # = stretched_gg "regular_stretched_gg" = { dataRepresentationType = 24; sphericalHarmonics = 0; PLPresent=0; } # = stretched_gg
"regular_stretched_rotated_gg" = { dataRepresentationType = 34; sphericalHarmonics = 0; PLPresent=0; } # = stretched_rotated_gg "regular_stretched_rotated_gg" = { dataRepresentationType = 34; sphericalHarmonics = 0; PLPresent=0; } # = stretched_rotated_gg
"sh" = {dataRepresentationType = 50; sphericalHarmonics = 1; PLPresent=0; } "sh" = {dataRepresentationType = 50; sphericalHarmonics = 1; PLPresent=0; }
"rotated_sh" = {dataRepresentationType = 60; sphericalHarmonics = 1; PLPresent=0; } "rotated_sh" = {dataRepresentationType = 60; sphericalHarmonics = 1; PLPresent=0; }
"stretched_sh" = {dataRepresentationType = 70; sphericalHarmonics = 1; PLPresent=0; } "stretched_sh" = {dataRepresentationType = 70; sphericalHarmonics = 1; PLPresent=0; }
@ -237,7 +234,7 @@ alias typeOfGrid=gridType;
meta getNumberOfValues size(values) : edition_specific,dump ; meta getNumberOfValues size(values) : edition_specific,dump ;
if (complexPacking==0 || sphericalHarmonics==1) { if (complexPacking==0 || sphericalHarmonics==1) {
padtoeven padding_sec4_1(offsetSection4,section4Length) ; padtoeven padding_sec4_1(offsetSection4,section4Length) ;
} }
meta md5Section4 md5(offsetSection4,section4Length); meta md5Section4 md5(offsetSection4,section4Length);

View File

@ -1,7 +1,7 @@
# CARRA/CERRA suite names # CARRA/CERRA suite names
0 unknown Unknown 0 unknown Unknown
1 enmi-haro-cae HARMONIE-AROME reanalysis by MetNorway on CARRA-East domain (CARRA project) 1 no-ar-ce HARMONIE-AROME reanalysis by MetNorway on CARRA-East domain (CARRA project)
2 enmi-haro-caw HARMONIE-AROME reanalysis by MetNorway on CARRA-West domain (CARRA project) 2 no-ar-cw HARMONIE-AROME reanalysis by MetNorway on CARRA-West domain (CARRA project)
3 enmi-haro-par HARMONIE-AROME reanalysis by MetNorway on Pan-Arctic domain (CARRA project) 3 no-ar-pa HARMONIE-AROME reanalysis by MetNorway on Pan-Arctic domain (CARRA project)
4 eswi-hald-ecx HARMONIE-ALADIN reanalysis by SMHI on EURO-CORDEX domain (CERRA project) 4 se-al-ec HARMONIE-ALADIN reanalysis by SMHI on EURO-CORDEX domain (CERRA project)
5 lfpw-mesu-ecx MESCAN-SURFEX surface reanalysis by Meteo-France on EURO-CORDEX domain (CERRA project) 5 fr-ms-ec MESCAN-SURFEX surface reanalysis by Meteo-France on EURO-CORDEX domain (CERRA project)

View File

@ -4,6 +4,7 @@
7 7 Sensitivity data 7 7 Sensitivity data
9 9 Singular vectors and ensemble perturbations 9 9 Singular vectors and ensemble perturbations
11 11 Supplementary data used by the analysis 11 11 Supplementary data used by the analysis
12 12 Seasonal forecast monthly mean data for lagged systems
14 14 Brightness temperature 14 14 Brightness temperature
15 15 Seasonal forecast data 15 15 Seasonal forecast data
16 16 Seasonal forecast monthly mean data 16 16 Seasonal forecast monthly mean data

View File

@ -0,0 +1,14 @@
# Seasonal forecast monthly mean data for lagged systems
unsigned[2] systemNumber : dump;
unsigned[2] methodNumber : dump;
alias local.systemNumber=systemNumber;
alias local.methodNumber=methodNumber;
unsigned[4] indexingDate: dump; # MARS archiving date (YYYYMMDD)
unsigned[2] indexingTime: dump; # MARS archiving time (HHMM)
alias mars.date = indexingDate;
alias mars.time = indexingTime;
pad padding_loc12_1(50);

View File

@ -39,13 +39,11 @@ alias mars.param = paramId;
alias mars.origin = centre; alias mars.origin = centre;
if (section2Used == 1) { if (section2Used == 1) {
constant marsLamModel = 'lam'; alias mars.origin = crraSuiteID; # origin is the suiteName
alias mars.model = marsLamModel; # model redefined. It is not 'glob' unalias mars.domain;
alias mars.origin = crraSuiteID; # origin is the suiteName unalias mars.model;
unalias mars.domain; # No mars domain needed
} }
# See GRIB-911 re typeOfProcessedData values in UERRA # See GRIB-911 re typeOfProcessedData values in UERRA
concept marsType { concept marsType {

View File

@ -8,24 +8,12 @@
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/ */
/*
* C Implementation: grib_keys_iterator
*
* Description:
* Example on how to use keys_iterator functions and the
* codes_keys_iterator structure to get all the available
* keys in a GRIB message.
*
*/
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h>
#include <string.h> #include <string.h>
#include "eccodes.h" #include "eccodes.h"
#define MAX_KEY_LEN 255
#define MAX_VAL_LEN 1024 #define MAX_VAL_LEN 1024
static void usage(char* progname); static void usage(char* progname);
@ -39,7 +27,7 @@ int main(int argc, char *argv[])
unsigned long key_iterator_filter_flags=CODES_KEYS_ITERATOR_ALL_KEYS; unsigned long key_iterator_filter_flags=CODES_KEYS_ITERATOR_ALL_KEYS;
/* Choose a namespace. E.g. "ls", "time", "parameter", "geography", "statistics" */ /* Choose a namespace. E.g. "ls", "time", "parameter", "geography", "statistics" */
char* name_space="ls"; const char* name_space="ls";
/* name_space=NULL to get all the keys */ /* name_space=NULL to get all the keys */
/* char* name_space=0; */ /* char* name_space=0; */
@ -55,13 +43,13 @@ int main(int argc, char *argv[])
if (argc != 2) usage(argv[0]); if (argc != 2) usage(argv[0]);
f = fopen(argv[1],"r"); f = fopen(argv[1],"rb");
if(!f) { if(!f) {
perror(argv[1]); perror(argv[1]);
exit(1); exit(1);
} }
while((h = grib_handle_new_from_file(0,f,&err)) != NULL) while((h = codes_handle_new_from_file(0,f,PRODUCT_GRIB,&err)) != NULL)
{ {
codes_keys_iterator* kiter=NULL; codes_keys_iterator* kiter=NULL;
msg_count++; msg_count++;

View File

@ -313,6 +313,8 @@ static int bufr_decode_edition3(const void* message, codes_bufr_header* hdr)
long nbits_localTablesVersionNumber = 1*8; long nbits_localTablesVersionNumber = 1*8;
long pos_localTablesVersionNumber = 19*8; long pos_localTablesVersionNumber = 19*8;
const long typicalCentury = 21; /* This century */
long typicalYearOfCentury = 0;
long nbits_typicalYearOfCentury = 1*8; long nbits_typicalYearOfCentury = 1*8;
long pos_typicalYearOfCentury = 20*8; long pos_typicalYearOfCentury = 20*8;
@ -353,11 +355,15 @@ static int bufr_decode_edition3(const void* message, codes_bufr_header* hdr)
hdr->masterTablesVersionNumber = (long)grib_decode_unsigned_long( hdr->masterTablesVersionNumber = (long)grib_decode_unsigned_long(
message, &pos_masterTablesVersionNumber, nbits_masterTablesVersionNumber); message, &pos_masterTablesVersionNumber, nbits_masterTablesVersionNumber);
hdr->localTablesVersionNumber = (long)grib_decode_unsigned_long(message, &pos_localTablesVersionNumber, nbits_localTablesVersionNumber); hdr->localTablesVersionNumber = (long)grib_decode_unsigned_long(message, &pos_localTablesVersionNumber, nbits_localTablesVersionNumber);
hdr->typicalYearOfCentury = (long)grib_decode_unsigned_long(message, &pos_typicalYearOfCentury, nbits_typicalYearOfCentury); typicalYearOfCentury = (long)grib_decode_unsigned_long(message, &pos_typicalYearOfCentury, nbits_typicalYearOfCentury);
hdr->typicalYear = (typicalCentury - 1) * 100 + typicalYearOfCentury;
hdr->typicalMonth = (long)grib_decode_unsigned_long(message, &pos_typicalMonth, nbits_typicalMonth); hdr->typicalMonth = (long)grib_decode_unsigned_long(message, &pos_typicalMonth, nbits_typicalMonth);
hdr->typicalDay = (long)grib_decode_unsigned_long(message, &pos_typicalDay, nbits_typicalDay); hdr->typicalDay = (long)grib_decode_unsigned_long(message, &pos_typicalDay, nbits_typicalDay);
hdr->typicalHour = (long)grib_decode_unsigned_long(message, &pos_typicalHour, nbits_typicalHour); hdr->typicalHour = (long)grib_decode_unsigned_long(message, &pos_typicalHour, nbits_typicalHour);
hdr->typicalMinute = (long)grib_decode_unsigned_long(message, &pos_typicalMinute, nbits_typicalMinute); hdr->typicalMinute = (long)grib_decode_unsigned_long(message, &pos_typicalMinute, nbits_typicalMinute);
hdr->typicalSecond = 0;
hdr->typicalDate = hdr->typicalYear * 10000 + hdr->typicalMonth * 100 + hdr->typicalDay;
hdr->typicalTime = hdr->typicalHour * 10000 + hdr->typicalMinute * 100 + hdr->typicalSecond;
offset_section2 = BUFR_SECTION0_LEN + section1Length; /*bytes*/ offset_section2 = BUFR_SECTION0_LEN + section1Length; /*bytes*/
section2Length = 0; section2Length = 0;
@ -434,6 +440,7 @@ static int bufr_decode_edition4(const void* message, codes_bufr_header* hdr)
long nbits_localTablesVersionNumber = 1*8; long nbits_localTablesVersionNumber = 1*8;
long pos_localTablesVersionNumber = 22*8; long pos_localTablesVersionNumber = 22*8;
long typicalYear2 = 0; /* corrected */
long nbits_typicalYear = 2*8; long nbits_typicalYear = 2*8;
long pos_typicalYear = 23*8; long pos_typicalYear = 23*8;
@ -477,12 +484,16 @@ static int bufr_decode_edition4(const void* message, codes_bufr_header* hdr)
hdr->dataSubCategory = (long)grib_decode_unsigned_long(message, &pos_dataSubCategory, nbits_dataSubCategory); hdr->dataSubCategory = (long)grib_decode_unsigned_long(message, &pos_dataSubCategory, nbits_dataSubCategory);
hdr->masterTablesVersionNumber = (long)grib_decode_unsigned_long(message, &pos_masterTablesVersionNumber, nbits_masterTablesVersionNumber); hdr->masterTablesVersionNumber = (long)grib_decode_unsigned_long(message, &pos_masterTablesVersionNumber, nbits_masterTablesVersionNumber);
hdr->localTablesVersionNumber = (long)grib_decode_unsigned_long(message, &pos_localTablesVersionNumber, nbits_localTablesVersionNumber); hdr->localTablesVersionNumber = (long)grib_decode_unsigned_long(message, &pos_localTablesVersionNumber, nbits_localTablesVersionNumber);
hdr->typicalYear = (long)grib_decode_unsigned_long(message, &pos_typicalYear, nbits_typicalYear); hdr->typicalYear = (long)grib_decode_unsigned_long(message, &pos_typicalYear, nbits_typicalYear);
typicalYear2 = hdr->typicalYear < 100 ? 2000 + hdr->typicalYear : hdr->typicalYear; /*ECC-556*/
hdr->typicalMonth = (long)grib_decode_unsigned_long(message, &pos_typicalMonth, nbits_typicalMonth); hdr->typicalMonth = (long)grib_decode_unsigned_long(message, &pos_typicalMonth, nbits_typicalMonth);
hdr->typicalDay = (long)grib_decode_unsigned_long(message, &pos_typicalDay, nbits_typicalDay); hdr->typicalDay = (long)grib_decode_unsigned_long(message, &pos_typicalDay, nbits_typicalDay);
hdr->typicalHour = (long)grib_decode_unsigned_long(message, &pos_typicalHour, nbits_typicalHour); hdr->typicalHour = (long)grib_decode_unsigned_long(message, &pos_typicalHour, nbits_typicalHour);
hdr->typicalMinute = (long)grib_decode_unsigned_long(message, &pos_typicalMinute, nbits_typicalMinute); hdr->typicalMinute = (long)grib_decode_unsigned_long(message, &pos_typicalMinute, nbits_typicalMinute);
hdr->typicalSecond = (long)grib_decode_unsigned_long(message, &pos_typicalSecond, nbits_typicalSecond); hdr->typicalSecond = (long)grib_decode_unsigned_long(message, &pos_typicalSecond, nbits_typicalSecond);
hdr->typicalDate = typicalYear2 * 10000 + hdr->typicalMonth * 100 + hdr->typicalDay;
hdr->typicalTime = hdr->typicalHour * 10000 + hdr->typicalMinute * 100 + hdr->typicalSecond;
offset_section2 = BUFR_SECTION0_LEN + section1Length; /*bytes*/ offset_section2 = BUFR_SECTION0_LEN + section1Length; /*bytes*/
section2Length = 0; section2Length = 0;
@ -537,6 +548,35 @@ static int bufr_decode_header(grib_context* c, const void* message, off_t offset
return err; return err;
} }
static int count_bufr_messages(grib_context* c, FILE* f, int* n)
{
int err=0;
void* mesg=NULL;
size_t size=0;
off_t offset=0;
int done = 0;
*n = 0;
if (!c) c=grib_context_get_default();
while(!done) {
mesg = wmo_read_bufr_from_file_malloc(f, 0, &size, &offset, &err);
/*printf("Count so far=%ld, mesg=%x, err=%d (%s)\n", *count, mesg, err, grib_get_error_message(err));*/
if (!mesg) {
if (err == GRIB_END_OF_FILE || err == GRIB_PREMATURE_END_OF_FILE) {
done = 1; /* reached the end */
}
}
if (mesg && !err) {
grib_context_free(c,mesg);
(*n)++;
}
}
rewind(f);
if (err==GRIB_END_OF_FILE) err=GRIB_SUCCESS;
return err;
}
int codes_bufr_extract_headers_malloc(grib_context* c, const char* filename, codes_bufr_header** result, int* num_messages) int codes_bufr_extract_headers_malloc(grib_context* c, const char* filename, codes_bufr_header** result, int* num_messages)
{ {
int err = 0, i = 0; int err = 0, i = 0;
@ -552,13 +592,18 @@ int codes_bufr_extract_headers_malloc(grib_context* c, const char* filename, cod
perror(filename); perror(filename);
return GRIB_IO_PROBLEM; return GRIB_IO_PROBLEM;
} }
err = grib_count_in_file(c, fp, num_messages); err = count_bufr_messages(c, fp, num_messages);
if (err) { if (err) {
grib_context_log(c, GRIB_LOG_ERROR, "codes_bufr_extract_headers_malloc: Unable to count BUFR messages in file \"%s\"", filename);
fclose(fp); fclose(fp);
return err; return err;
} }
size = *num_messages; size = *num_messages;
if (size == 0) {
grib_context_log(c, GRIB_LOG_ERROR, "codes_bufr_extract_headers_malloc: No BUFR messages in file \"%s\"", filename);
return GRIB_INVALID_MESSAGE;
}
*result = (codes_bufr_header*)calloc(size, sizeof(codes_bufr_header)); *result = (codes_bufr_header*)calloc(size, sizeof(codes_bufr_header));
if (!*result) { if (!*result) {
fclose(fp); fclose(fp);
@ -575,6 +620,12 @@ int codes_bufr_extract_headers_malloc(grib_context* c, const char* filename, cod
} }
grib_context_free(c, mesg); grib_context_free(c, mesg);
} }
if (!mesg) {
if (err != GRIB_END_OF_FILE && err != GRIB_PREMATURE_END_OF_FILE) {
/* An error occurred */
grib_context_log(c, GRIB_LOG_ERROR, "codes_bufr_extract_headers_malloc: Unable to read BUFR message");
}
}
} }
fclose(fp); fclose(fp);

View File

@ -142,9 +142,8 @@ static void dump(grib_accessor* a, grib_dumper* dumper)
grib_dump_long(dumper,a,NULL); grib_dump_long(dumper,a,NULL);
} }
static int unpack_long (grib_accessor* a, long* val, size_t *len) static int unpack_long(grib_accessor* a, long* val, size_t *len)
{ {
unsigned char dat = 0; unsigned char dat = 0;
if(*len < 1) if(*len < 1)
{ {
@ -154,13 +153,12 @@ static int unpack_long (grib_accessor* a, long* val, size_t *len)
} }
dat = grib_handle_of_accessor(a)->buffer->data[a->offset] & 0x0f; dat = grib_handle_of_accessor(a)->buffer->data[a->offset] & 0x0f;
*val = dat; *val = dat;
*len = 1; *len = 1;
return GRIB_SUCCESS; return GRIB_SUCCESS;
} }
static int pack_long (grib_accessor* a, const long *val, size_t *len) static int pack_long(grib_accessor* a, const long *val, size_t *len)
{ {
int ret = 0; int ret = 0;
if(*len < 1) if(*len < 1)
@ -207,4 +205,3 @@ static int compare(grib_accessor* a,grib_accessor* b) {
if (bval != aval) return GRIB_VALUE_MISMATCH; if (bval != aval) return GRIB_VALUE_MISMATCH;
return GRIB_SUCCESS; return GRIB_SUCCESS;
} }

View File

@ -199,9 +199,13 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
fcmonth++; fcmonth++;
if(gribForecastMonth != 0 && gribForecastMonth!=fcmonth) { if(gribForecastMonth != 0 && gribForecastMonth!=fcmonth) {
*val = gribForecastMonth;
return GRIB_SUCCESS;
/*
grib_context_log(a->context,GRIB_LOG_FATAL,"%s=%ld (%s-%s)=%ld",self->fcmonth, grib_context_log(a->context,GRIB_LOG_FATAL,"%s=%ld (%s-%s)=%ld",self->fcmonth,
gribForecastMonth,self->base_date,self->verification_yearmonth,fcmonth); gribForecastMonth,self->base_date,self->verification_yearmonth,fcmonth);
Assert(gribForecastMonth == fcmonth); Assert(gribForecastMonth == fcmonth);
*/
} }
*val = fcmonth; *val = fcmonth;

View File

@ -284,6 +284,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t *len)
case 15: /* Seasonal forecast data */ case 15: /* Seasonal forecast data */
case 16: /* Seasonal forecast monthly mean data */ case 16: /* Seasonal forecast monthly mean data */
case 12: /* Seasonal forecast monthly mean data for lagged systems */
case 18: /* Multianalysis ensemble data */ case 18: /* Multianalysis ensemble data */
case 26: /* MARS labelling or ensemble forecast data */ case 26: /* MARS labelling or ensemble forecast data */
case 30: /* Forecasting Systems with Variable Resolution */ case 30: /* Forecasting Systems with Variable Resolution */

View File

@ -1577,16 +1577,17 @@ typedef struct codes_bufr_header {
long dataSubCategory; long dataSubCategory;
long masterTablesVersionNumber; long masterTablesVersionNumber;
long localTablesVersionNumber; long localTablesVersionNumber;
long typicalYearOfCentury;
long typicalYear;
long typicalMonth; long typicalMonth;
long typicalDay; long typicalDay;
long typicalHour; long typicalHour;
long typicalMinute; long typicalMinute;
/* Section 1 keys: BUFR4-specific */
long internationalDataSubCategory;
long typicalYear;
long typicalSecond; long typicalSecond;
long typicalDate; // computed key
long typicalTime; // computed key
long internationalDataSubCategory; /*BUFR4-specific*/
long ecmwfLocalSectionPresent; long ecmwfLocalSectionPresent;

File diff suppressed because it is too large Load Diff

View File

@ -46,7 +46,10 @@ int main(int argc, char* argv[])
filename = argv[2]; filename = argv[2];
err = codes_bufr_extract_headers_malloc(c, filename, &header_array, &num_messages); err = codes_bufr_extract_headers_malloc(c, filename, &header_array, &num_messages);
if (err) return 1; if (err) {
printf("ERROR: %s\n",grib_get_error_message(err));
return 1;
}
for (i=0; i < num_messages; ++i) { for (i=0; i < num_messages; ++i) {
codes_bufr_header bh = header_array[i]; codes_bufr_header bh = header_array[i];
@ -67,13 +70,16 @@ int main(int argc, char* argv[])
if (strstr(keys, "dataSubCategory")) printf("%ld ", bh.dataSubCategory); if (strstr(keys, "dataSubCategory")) printf("%ld ", bh.dataSubCategory);
if (strstr(keys, "masterTablesVersionNumber")) printf("%ld ", bh.masterTablesVersionNumber); if (strstr(keys, "masterTablesVersionNumber")) printf("%ld ", bh.masterTablesVersionNumber);
if (strstr(keys, "localTablesVersionNumber")) printf("%ld ", bh.localTablesVersionNumber); if (strstr(keys, "localTablesVersionNumber")) printf("%ld ", bh.localTablesVersionNumber);
if (strstr(keys, "typicalYearOfCentury")) printf("%ld ", bh.typicalYearOfCentury); if (strstr(keys, "typicalYear")) printf("%ld ", bh.typicalYear);
if (strstr(keys, "typicalMonth")) printf("%ld ", bh.typicalMonth); if (strstr(keys, "typicalMonth")) printf("%ld ", bh.typicalMonth);
if (strstr(keys, "typicalDay")) printf("%ld ", bh.typicalDay); if (strstr(keys, "typicalDay")) printf("%ld ", bh.typicalDay);
if (strstr(keys, "typicalHour")) printf("%ld ", bh.typicalHour); if (strstr(keys, "typicalHour")) printf("%ld ", bh.typicalHour);
if (strstr(keys, "typicalMinute")) printf("%ld ", bh.typicalMinute); if (strstr(keys, "typicalMinute")) printf("%ld ", bh.typicalMinute);
if (strstr(keys, "typicalDate")) printf("%ld ", bh.typicalDate);
if (strstr(keys, "typicalTime")) printf("%ld ", bh.typicalTime);
if (strstr(keys, "internationalDataSubCategory")) printf("%ld ", bh.internationalDataSubCategory); if (strstr(keys, "internationalDataSubCategory")) printf("%ld ", bh.internationalDataSubCategory);
if (strstr(keys, "typicalYear")) printf("%ld ", bh.typicalYear);
if (strstr(keys, "typicalSecond")) printf("%ld ", bh.typicalSecond); if (strstr(keys, "typicalSecond")) printf("%ld ", bh.typicalSecond);
if (strstr(keys, "localSectionPresent")) printf("%ld ", bh.ecmwfLocalSectionPresent); if (strstr(keys, "localSectionPresent")) printf("%ld ", bh.ecmwfLocalSectionPresent);

View File

@ -17,7 +17,7 @@ label="bufr_wmo_tables_test"
fTmp=${label}".tmp.bufr" fTmp=${label}".tmp.bufr"
#============================================== #==============================================
# Testing latest WMO tables # Testing latest WMO tables
#============================================== #==============================================
bufr_files=`cat ${data_dir}/bufr/bufr_data_files.txt` bufr_files=`cat ${data_dir}/bufr/bufr_data_files.txt`
REDIRECT=/dev/null REDIRECT=/dev/null
@ -37,7 +37,7 @@ blacklist=$blacklist",centre,subCentre,generatingApplication"
for file in ${bufr_files} for file in ${bufr_files}
do do
input=${data_dir}/bufr/$file input=${data_dir}/bufr/$file
mtv=`${tools_dir}/bufr_get -p masterTablesVersionNumber $input` mtv=`${tools_dir}/bufr_get -wcount=1 -p masterTablesVersionNumber $input`
# Must exclude old versions (before 14): # Must exclude old versions (before 14):
# 1. Sequence 312060 changed content from v15 to v16: # 1. Sequence 312060 changed content from v15 to v16:
# 021062 backscatter became 021088 wetBackscatter! # 021062 backscatter became 021088 wetBackscatter!

View File

@ -28,6 +28,7 @@ localDefinitions=`find ${def_dir}/grib1/ -name 'local.98.*def' | sed -e 's:.*/::
awk 'BEGIN {FS=".";} {print $3;}' |\ awk 'BEGIN {FS=".";} {print $3;}' |\
grep -v def |\ grep -v def |\
sed '/245/d' |\ sed '/245/d' |\
sed '/12/d' |\
sed '/244/d' |\ sed '/244/d' |\
sed '/192/d' |\ sed '/192/d' |\
xargs` xargs`

3482
tests/keys

File diff suppressed because it is too large Load Diff

View File

@ -687,13 +687,14 @@ s2s/ammc: warning: s2s.mx2t6_20151224_26.grib2, field 47 [surface_air_maximum_te
s2s/enfo/ammc: warning: s2s.ssr_20160807_25.grib2, field 62 [time_integrated_surface_net_solar_radiation_sfc]: time_integrated_surface_net_solar_radiation_sfc minimum value 10280.6 is not in [-0.1,10000] s2s/enfo/ammc: warning: s2s.ssr_20160807_25.grib2, field 62 [time_integrated_surface_net_solar_radiation_sfc]: time_integrated_surface_net_solar_radiation_sfc minimum value 10280.6 is not in [-0.1,10000]
*/ */
{ {
"time_integrated_surface_net_solar_radiation_sfc", "time_integrated_surface_net_solar_radiation_sfc.glob",
-10, -10,
1e+05, 1e+05,
1e+05, 1e+05,
1e+07, 1e+07,
{ {
{"model", GRIB_TYPE_STRING, 0, "glob"}, {"model", GRIB_TYPE_STRING, 0, "glob"},
{"paramId", GRIB_TYPE_LONG, 176},
{"discipline", GRIB_TYPE_LONG, 0}, {"discipline", GRIB_TYPE_LONG, 0},
{"parameterCategory", GRIB_TYPE_LONG, 4}, {"parameterCategory", GRIB_TYPE_LONG, 4},
{"parameterNumber", GRIB_TYPE_LONG, 9}, {"parameterNumber", GRIB_TYPE_LONG, 9},
@ -711,7 +712,7 @@ s2s/ammc: warning: s2s.mx2t6_20151224_26.grib2, field 47 [surface_air_maximum_te
1e+05, 1e+05,
1e+09, 1e+09,
{ {
{"model", GRIB_TYPE_STRING, 0, "glob"}, {"paramId", GRIB_TYPE_LONG, 169},
{"discipline", GRIB_TYPE_LONG, 0}, {"discipline", GRIB_TYPE_LONG, 0},
{"parameterCategory", GRIB_TYPE_LONG, 4}, {"parameterCategory", GRIB_TYPE_LONG, 4},
{"parameterNumber", GRIB_TYPE_LONG, 7}, {"parameterNumber", GRIB_TYPE_LONG, 7},
@ -928,30 +929,6 @@ s2s/ammc: warning: s2s.mx2t6_20151224_26.grib2, field 47 [surface_air_maximum_te
{&point_in_time, &given_thickness, &has_bitmap}, {&point_in_time, &given_thickness, &has_bitmap},
}, },
{
"maximum_wind_gust.glob",
0,
10,
0,
100,
{
{"model", GRIB_TYPE_STRING, 0, "glob"},
{"discipline", GRIB_TYPE_LONG, 0},
{"parameterCategory", GRIB_TYPE_LONG, 2},
{"parameterNumber", GRIB_TYPE_LONG, 22},
{"typeOfStatisticalProcessing", GRIB_TYPE_LONG, 2},
{"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 103},
{"scaleFactorOfFirstFixedSurface", GRIB_TYPE_LONG, 0},
{"scaledValueOfFirstFixedSurface", GRIB_TYPE_LONG, 10},
/* {"typeOfSecondFixedSurface", GRIB_TYPE_LONG, 255}, */
{NULL, },
},
{&three_hourly, &given_level},
},
/* /*
cosmoleps-arpasimc-eu 20140323, 12UTC, prod: tigge_lam.vmax_10m.9999.grib2, field 11 [maximum_wind_gust.lam]: maximum_wind_gust.lam maximum value 106.861 is not in [0,100] cosmoleps-arpasimc-eu 20140323, 12UTC, prod: tigge_lam.vmax_10m.9999.grib2, field 11 [maximum_wind_gust.lam]: maximum_wind_gust.lam maximum value 106.861 is not in [0,100]
@ -994,7 +971,7 @@ s2s/ammc: warning: s2s.mx2t6_20151224_26.grib2, field 47 [surface_air_maximum_te
*/ */
{ {
"maximum_wind_gust.lam", "maximum_wind_gust.lam.mogreps",
0, 0,
20, 20,
0, 0,
@ -1086,27 +1063,6 @@ s2s/egrr: s2s.z_s2s_c_ukmo_20160102000000_glob_prod_pf_1440_002.rt.pl.grib2, fie
200, 200,
35000, 35000,
{ {
{"model", GRIB_TYPE_STRING, 0, "glob"},
{"discipline", GRIB_TYPE_LONG, 0},
{"parameterCategory", GRIB_TYPE_LONG, 3},
{"parameterNumber", GRIB_TYPE_LONG, 5},
{"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 100},
{NULL, },
},
{&point_in_time, &given_level, &pressure_level},
},
{
"geopotential_height_pl.uerra",
-5000,
30600,
200,
35000,
{
{"paramId", GRIB_TYPE_LONG, 156},
{"class", GRIB_TYPE_STRING, 0, "ur"},
{"discipline", GRIB_TYPE_LONG, 0}, {"discipline", GRIB_TYPE_LONG, 0},
{"parameterCategory", GRIB_TYPE_LONG, 3}, {"parameterCategory", GRIB_TYPE_LONG, 3},
{"parameterNumber", GRIB_TYPE_LONG, 5}, {"parameterNumber", GRIB_TYPE_LONG, 5},
@ -1124,8 +1080,6 @@ s2s/egrr: s2s.z_s2s_c_ukmo_20160102000000_glob_prod_pf_1440_002.rt.pl.grib2, fie
2000, 2000,
350000, 350000,
{ {
{"model", GRIB_TYPE_STRING, 0, "glob"},
{"discipline", GRIB_TYPE_LONG, 0}, {"discipline", GRIB_TYPE_LONG, 0},
{"parameterCategory", GRIB_TYPE_LONG, 3}, {"parameterCategory", GRIB_TYPE_LONG, 3},
{"parameterNumber", GRIB_TYPE_LONG, 4}, {"parameterNumber", GRIB_TYPE_LONG, 4},
@ -1136,25 +1090,6 @@ s2s/egrr: s2s.z_s2s_c_ukmo_20160102000000_glob_prod_pf_1440_002.rt.pl.grib2, fie
{&point_in_time, &given_level, &pressure_level}, {&point_in_time, &given_level, &pressure_level},
}, },
{
"geopotential_pl.uerra",
-5000,
306000,
2000,
350000,
{
{"paramId", GRIB_TYPE_LONG, 129},
{"class", GRIB_TYPE_STRING, 0, "ur"},
{"discipline", GRIB_TYPE_LONG, 0},
{"parameterCategory", GRIB_TYPE_LONG, 3},
{"parameterNumber", GRIB_TYPE_LONG, 4},
{"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 100},
{NULL, },
},
{&point_in_time, &given_level, &pressure_level},
},
/* /*
warning: s2s.lfpw_t_10.grib2, field 61 [temperature_pl]: temperature_pl minimum value 159.934 is not in [160,260] warning: s2s.lfpw_t_10.grib2, field 61 [temperature_pl]: temperature_pl minimum value 159.934 is not in [160,260]
@ -2442,55 +2377,6 @@ uerra/egrr (something like ad hoc 1 grid-point issue (similarly grid-point storm
{&point_in_time, &given_level}, /* check model levels?? */ {&point_in_time, &given_level}, /* check model levels?? */
}, },
/*
uerra/egrr warning: oper.2010-03-13.ml.grib2, field 16 [cloud_cover_ml]: cloud_cover_ml minimum value -0.906414 is not in [0,1e-10]
{
"cloud_cover_ml.uerra.egrr",
-10,
1e-10,
0,
100.00001,
{
{"class", GRIB_TYPE_STRING, 0, "ur"},
{"centre", GRIB_TYPE_STRING, 1, "egrr"},
{"discipline", GRIB_TYPE_LONG, 0},
{"parameterCategory", GRIB_TYPE_LONG, 6},
{"parameterNumber", GRIB_TYPE_LONG, 22},
{"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 105},
{"scaleFactorOfFirstFixedSurface", GRIB_TYPE_LONG, 0},
{NULL, },
},
{&point_in_time, &given_level},
},
*/
/* pressure level */
/*
uerra:edzw-an warning: /tmp/marm/uerra/cosmo/sample2/grib2/fc.200812021200+27.pl.grib2, field 76 [geopotential_height_pl.ur]: geopotential_height_pl.ur minimum value -2938.29 is not in [-1300,300000]
??? xxx TBD to be deleted and the global one used only!
{
"geopotential_height_pl.ur",
-5000,
300000,
2000,
350000,
{
{"class", GRIB_TYPE_STRING, 0, "ur"},
{"discipline", GRIB_TYPE_LONG, 0},
{"parameterCategory", GRIB_TYPE_LONG, 3},
{"parameterNumber", GRIB_TYPE_LONG, 5},
{"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 100},
{NULL, },
},
{&point_in_time, &given_level, &pressure_level},
},
*/
{ {
"specific_cloud_ice_water_content_pl", "specific_cloud_ice_water_content_pl",
0, 0,
@ -2510,12 +2396,13 @@ uerra:edzw-an warning: /tmp/marm/uerra/cosmo/sample2/grib2/fc.200812021200+27.pl
}, },
{ {
"cloud_cover_pl", "cloud_cover_pl.glob",
0, 0,
1e-10, 1e-10,
100, 100,
100.00001, 100.00001,
{ {
{"paramId", GRIB_TYPE_LONG, 260257},
{"discipline", GRIB_TYPE_LONG, 0}, {"discipline", GRIB_TYPE_LONG, 0},
{"parameterCategory", GRIB_TYPE_LONG, 6}, {"parameterCategory", GRIB_TYPE_LONG, 6},
{"parameterNumber", GRIB_TYPE_LONG, 22}, {"parameterNumber", GRIB_TYPE_LONG, 22},
@ -2623,14 +2510,13 @@ uerra:edzw-an warning: /tmp/marm/uerra/cosmo/sample2/grib2/fc.200812021200+27.pl
*/ */
{ {
"relative_humidity_pl.ur", "relative_humidity_pl",
0, 0,
30, 30,
0, 0,
180, 180,
{ {
{"paramId", GRIB_TYPE_LONG, 157}, {"paramId", GRIB_TYPE_LONG, 157},
{"class", GRIB_TYPE_STRING, 0, "ur"},
{"discipline", GRIB_TYPE_LONG, 0}, {"discipline", GRIB_TYPE_LONG, 0},
{"parameterCategory", GRIB_TYPE_LONG, 1}, {"parameterCategory", GRIB_TYPE_LONG, 1},
@ -2933,13 +2819,12 @@ uerra:edzw-an warning: /tmp/marm/uerra/cosmo/sample2/grib2/fc.200812021200+27.pl
uerra, eswi-fc: fc.tidirswrf.sfc.grib2, field 6 [time_integrated_surface_direct_solar_radiation]: time_integrated_surface_direct_solar_radiation minimum value 58442 is not in [-0.1,20000] uerra, eswi-fc: fc.tidirswrf.sfc.grib2, field 6 [time_integrated_surface_direct_solar_radiation]: time_integrated_surface_direct_solar_radiation minimum value 58442 is not in [-0.1,20000]
*/ */
{ {
"time_integrated_surface_direct_solar_radiation.ur", "time_integrated_surface_direct_solar_radiation",
-10, -10,
1e+08, 1e+08,
0, 0,
1e+09, 1e+09,
{ {
{"class", GRIB_TYPE_STRING, 0, "ur"},
{"paramId", GRIB_TYPE_LONG, 260264}, {"paramId", GRIB_TYPE_LONG, 260264},
{"discipline", GRIB_TYPE_LONG, 0}, {"discipline", GRIB_TYPE_LONG, 0},
{"parameterCategory", GRIB_TYPE_LONG, 4}, {"parameterCategory", GRIB_TYPE_LONG, 4},
@ -2951,36 +2836,13 @@ uerra:edzw-an warning: /tmp/marm/uerra/cosmo/sample2/grib2/fc.200812021200+27.pl
{&from_start, &predefined_level}, {&from_start, &predefined_level},
}, },
/*
s2s, lfpw-enfo: time_integrated_surface_net_solar_radiation_downwards_sfc minimum value -1.02308 is not in [-1,1e+07]
*/
{ {
"time_integrated_surface_net_solar_radiation_downwards_sfc.ur", "time_integrated_surface_net_solar_radiation_sfc.lam",
-10,
1e+08,
0,
1e+09,
{
{"class", GRIB_TYPE_STRING, 0, "ur"},
{"paramId", GRIB_TYPE_LONG, 169},
{"discipline", GRIB_TYPE_LONG, 0},
{"parameterCategory", GRIB_TYPE_LONG, 4},
{"parameterNumber", GRIB_TYPE_LONG, 7},
{"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 1},
{"typeOfStatisticalProcessing", GRIB_TYPE_LONG, 1},
{NULL, },
},
{&from_start, &predefined_level},
},
{
"time_integrated_surface_net_solar_radiation_sfc.ur",
-0.1, -0.1,
1e+08, 1e+08,
0, 0,
1e+09, 1e+09,
{ {
{"class", GRIB_TYPE_STRING, 0, "ur"},
{"paramId", GRIB_TYPE_LONG, 176}, {"paramId", GRIB_TYPE_LONG, 176},
{"discipline", GRIB_TYPE_LONG, 0}, {"discipline", GRIB_TYPE_LONG, 0},
{"parameterCategory", GRIB_TYPE_LONG, 4}, {"parameterCategory", GRIB_TYPE_LONG, 4},
@ -3032,34 +2894,35 @@ uerra:edzw-an warning: /tmp/marm/uerra/cosmo/sample2/grib2/fc.200812021200+27.pl
{&point_in_time, &given_level}, {&point_in_time, &given_level},
}, },
{ {
"10_metre_wind_gust_uerra", "10_metre_wind_gust_since_pp",
0.001, 0.001,
10, 10,
10, 10,
150, 150,
{ {
{"paramId", GRIB_TYPE_LONG, 49}, {"paramId", GRIB_TYPE_LONG, 49},
{"class", GRIB_TYPE_STRING, 0, "ur"},
{"discipline", GRIB_TYPE_LONG, 0}, {"discipline", GRIB_TYPE_LONG, 0},
{"parameterCategory", GRIB_TYPE_LONG, 2}, {"parameterCategory", GRIB_TYPE_LONG, 2},
{"parameterNumber", GRIB_TYPE_LONG, 22}, {"parameterNumber", GRIB_TYPE_LONG, 22},
{"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 103}, {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 103},
{"scaleFactorOfFirstFixedSurface", GRIB_TYPE_LONG, 0}, {"scaleFactorOfFirstFixedSurface", GRIB_TYPE_LONG, 0},
{"scaledValueOfFirstFixedSurface", GRIB_TYPE_LONG, 10}, {"scaledValueOfFirstFixedSurface", GRIB_TYPE_LONG, 10},
{"typeOfStatisticalProcessing", GRIB_TYPE_LONG, 2}, {"typeOfStatisticalProcessing", GRIB_TYPE_LONG, 2},
{NULL, }, {NULL, },
}, },
{&since_prev_pp, &given_level}, {&since_prev_pp, &given_level},
}, },
{ {
"2_metre_maximum_temperature_uerra", "2_metre_maximum_temperature",
200, 200,
340, 340,
200, 200,
340, 340,
{ {
{"paramId", GRIB_TYPE_LONG, 201}, {"paramId", GRIB_TYPE_LONG, 201},
{"class", GRIB_TYPE_STRING, 0, "ur"},
{"discipline", GRIB_TYPE_LONG, 0}, {"discipline", GRIB_TYPE_LONG, 0},
{"parameterCategory", GRIB_TYPE_LONG, 0}, {"parameterCategory", GRIB_TYPE_LONG, 0},
{"parameterNumber", GRIB_TYPE_LONG, 0}, {"parameterNumber", GRIB_TYPE_LONG, 0},
@ -3070,14 +2933,13 @@ uerra:edzw-an warning: /tmp/marm/uerra/cosmo/sample2/grib2/fc.200812021200+27.pl
{&since_prev_pp, &given_level}, {&since_prev_pp, &given_level},
}, },
{ {
"2_metre_minimum_temperature_uerra", "2_metre_minimum_temperature",
200, 200,
340, 340,
200, 200,
340, 340,
{ {
{"paramId", GRIB_TYPE_LONG, 202}, {"paramId", GRIB_TYPE_LONG, 202},
{"class", GRIB_TYPE_STRING, 0, "ur"},
{"discipline", GRIB_TYPE_LONG, 0}, {"discipline", GRIB_TYPE_LONG, 0},
{"parameterCategory", GRIB_TYPE_LONG, 0}, {"parameterCategory", GRIB_TYPE_LONG, 0},
{"parameterNumber", GRIB_TYPE_LONG, 0}, {"parameterNumber", GRIB_TYPE_LONG, 0},
@ -3274,14 +3136,13 @@ uerra:edzw-an warning: /tmp/marm/uerra/cosmo/sample2/grib2/fc.200812021200+27.pl
}, },
{ {
"cloud_cover_pl.ur", "cloud_cover_pl.lam",
0, 0,
1e-10, 1e-10,
0, 0,
100, 100,
{ {
{"paramId", GRIB_TYPE_LONG, 260257}, {"paramId", GRIB_TYPE_LONG, 260257},
{"class", GRIB_TYPE_STRING, 0, "ur"},
{"discipline", GRIB_TYPE_LONG, 0}, {"discipline", GRIB_TYPE_LONG, 0},
{"parameterCategory", GRIB_TYPE_LONG, 6}, {"parameterCategory", GRIB_TYPE_LONG, 6},
{"parameterNumber", GRIB_TYPE_LONG, 22}, {"parameterNumber", GRIB_TYPE_LONG, 22},
@ -4008,12 +3869,10 @@ uerra, eswi-enfo:total_cloud_cover_sfc maximum value 96.4844 is not in [100,100]
{"parameterNumber", GRIB_TYPE_LONG, 2}, {"parameterNumber", GRIB_TYPE_LONG, 2},
{"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 160}, {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 160},
{"scaleFactorOfFirstFixedSurface", GRIB_TYPE_LONG, 0},
{"scaledValueOfFirstFixedSurface", GRIB_TYPE_LONG, 0},
{NULL, }, {NULL, },
}, },
{&daily_average, &given_level, &has_bitmap}, {&daily_average, &predefined_level, &has_bitmap},
}, },
{ {
"northward_sea_water_velocity_o2d.s2", "northward_sea_water_velocity_o2d.s2",
@ -4030,12 +3889,10 @@ uerra, eswi-enfo:total_cloud_cover_sfc maximum value 96.4844 is not in [100,100]
{"parameterNumber", GRIB_TYPE_LONG, 3}, {"parameterNumber", GRIB_TYPE_LONG, 3},
{"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 160}, {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 160},
{"scaleFactorOfFirstFixedSurface", GRIB_TYPE_LONG, 0},
{"scaledValueOfFirstFixedSurface", GRIB_TYPE_LONG, 0},
{NULL, }, {NULL, },
}, },
{&daily_average, &given_level, &has_bitmap}, {&daily_average, &predefined_level, &has_bitmap},
}, },
{ {
"sea-ice_thickness_o2d.s2", "sea-ice_thickness_o2d.s2",

View File

@ -9,7 +9,9 @@
*/ */
#include "grib_api_internal.h" #include "grib_api_internal.h"
static int fail_on_error = 1; static int fail_on_error = 1;
static const char* tool_name = NULL;
static void usage(const char* prog) static void usage(const char* prog)
{ {
@ -64,6 +66,18 @@ static int count_messages(FILE* in, int message_type, unsigned long *count)
return err; return err;
} }
static int is_a_directory(const char* filename)
{
struct stat s;
int stat_val = stat(filename, &s);
if ( stat_val == 0 ) {
if (S_ISDIR(s.st_mode)) {
return 1;
}
}
return 0;
}
int main(int argc,char* argv[]) int main(int argc,char* argv[])
{ {
FILE* infh = NULL; FILE* infh = NULL;
@ -73,11 +87,12 @@ int main(int argc,char* argv[])
unsigned long count_total=0, count_curr=0; unsigned long count_total=0, count_curr=0;
int message_type = 0; /* GRIB, BUFR etc */ int message_type = 0; /* GRIB, BUFR etc */
if (argc <2) usage(argv[0]); tool_name = argv[0];
if (argc <2) usage(tool_name);
if (strstr(argv[0], "grib_count")) message_type = CODES_GRIB;
if (strstr(argv[0], "bufr_count")) message_type = CODES_BUFR; if (strstr(tool_name, "grib_count")) message_type = CODES_GRIB;
if (strstr(argv[0], "gts_count")) message_type = CODES_GTS; if (strstr(tool_name, "bufr_count")) message_type = CODES_BUFR;
if (strstr(tool_name, "gts_count")) message_type = CODES_GTS;
count_total=0; count_total=0;
for (i=1;i<argc;i++) { for (i=1;i<argc;i++) {
@ -90,6 +105,11 @@ int main(int argc,char* argv[])
continue; continue;
} }
filename=argv[i]; filename=argv[i];
if (is_a_directory(filename)) {
fprintf(stderr, "%s: ERROR: \"%s\": Is a directory\n", tool_name, filename);
continue;
}
if (strcmp(filename,"-")==0) if (strcmp(filename,"-")==0)
infh=stdin; infh=stdin;
else else