diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index d114942b6..082dab058 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -69,6 +69,8 @@ jobs: secrets: url_debian_11: ${{ secrets.NEXUS_TEST_REPO_NIGHTLY_URL_DEBIAN_11 }} token_debian_11: ${{ secrets.NEXUS_TEST_REPO_UPLOAD_TOKEN }} + url_debian_12: ${{ secrets.NEXUS_TEST_REPO_URL_DEBIAN_12 }} + token_debian_12: ${{ secrets.NEXUS_TEST_REPO_UPLOAD_TOKEN }} url_centos_7: ${{ secrets.NEXUS_TEST_REPO_NIGHTLY_URL_CENTOS_7 }} token_centos_7: ${{ secrets.NEXUS_TEST_REPO_UPLOAD_TOKEN }} url_rocky_8: ${{ secrets.NEXUS_TEST_REPO_NIGHTLY_URL_ROCKY_8 }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 062da488a..7e5290fa0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -379,6 +379,16 @@ if( HAVE_FORTRAN AND CMAKE_Fortran_COMPILER_ID MATCHES "GNU" AND NOT CMAKE_Fortr ecbuild_add_fortran_flags("-fallow-argument-mismatch") endif() +if(GIT_FOUND AND NOT ${GIT_EXECUTABLE} STREQUAL "") + ecbuild_info("Found git: ${GIT_EXECUTABLE} (found version \"${GIT_VERSION_STRING}\")") + execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD + OUTPUT_VARIABLE eccodes_GIT_BRANCH + RESULT_VARIABLE nok ERROR_VARIABLE error + OUTPUT_STRIP_TRAILING_WHITESPACE + WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" ) + ecbuild_info("ecCodes branch = ${eccodes_GIT_BRANCH}" ) +endif() + ############################################################################### # contents diff --git a/VERSION b/VERSION index c94fd315f..f31d783fa 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.37.0 +2.38.0 diff --git a/definitions/grib1/boot.def b/definitions/grib1/boot.def index 4dd9e48e0..f98ef0442 100644 --- a/definitions/grib1/boot.def +++ b/definitions/grib1/boot.def @@ -16,7 +16,7 @@ constant three=1 : hidden; constant eight=8 : hidden; constant eleven=11 : hidden; constant epsPoint=1 : hidden; -constant epsContinous=11 : hidden; +constant epsContinuous=11 : hidden; constant epsStatisticsPoint=2 : hidden; constant epsStatisticsContinous=12 : hidden; diff --git a/definitions/grib1/local.214.1.def b/definitions/grib1/local.214.1.def index 51e0254aa..82ba4e74d 100644 --- a/definitions/grib1/local.214.1.def +++ b/definitions/grib1/local.214.1.def @@ -32,7 +32,7 @@ if (stepType is "instant" ) { } } else { if (numberOfForecastsInEnsemble!=0) { - alias productDefinitionTemplateNumber=epsContinous; + alias productDefinitionTemplateNumber=epsContinuous; } } diff --git a/definitions/grib1/local.34.1.def b/definitions/grib1/local.34.1.def index 078e15cf8..1a96674b4 100644 --- a/definitions/grib1/local.34.1.def +++ b/definitions/grib1/local.34.1.def @@ -40,7 +40,7 @@ if (stepType is "instant" ) { } else { alias typeOfEnsembleForecast=three; } - alias productDefinitionTemplateNumber=epsContinous; + alias productDefinitionTemplateNumber=epsContinuous; } else { alias productDefinitionTemplateNumber=eight; } diff --git a/definitions/grib1/local.98.1.def b/definitions/grib1/local.98.1.def index d908b43ed..a1a5adddf 100644 --- a/definitions/grib1/local.98.1.def +++ b/definitions/grib1/local.98.1.def @@ -41,7 +41,7 @@ if (stepType is "instant" ) { } else { alias typeOfEnsembleForecast=three; } - alias productDefinitionTemplateNumber=epsContinous; + alias productDefinitionTemplateNumber=epsContinuous; } else { alias productDefinitionTemplateNumber=eight; } diff --git a/definitions/grib1/local.98.13.def b/definitions/grib1/local.98.13.def index c205278b0..056f94ec3 100644 --- a/definitions/grib1/local.98.13.def +++ b/definitions/grib1/local.98.13.def @@ -11,15 +11,19 @@ alias totalNumber=numberOfForecastsInEnsemble; unsigned[1] directionNumber : dump ; alias mars.direction = directionNumber; +alias waveDirectionNumber = directionNumber; unsigned[1] frequencyNumber : dump ; alias mars.frequency = frequencyNumber; +alias waveFrequencyNumber = frequencyNumber; unsigned[1] numberOfDirections : dump ; alias totalNumberOfDirections = numberOfDirections ; +alias numberOfWaveDirections = numberOfDirections; unsigned[1] numberOfFrequencies : dump; alias totalNumberOfFrequencies = numberOfFrequencies ; +alias numberOfWaveFrequencies = numberOfFrequencies; unsigned[4] directionScalingFactor : dump; alias integerScalingFactorAppliedToDirections = directionScalingFactor; @@ -161,4 +165,15 @@ if(localFlag == 4) unsigned[4] scaledDirections[numberOfDirections] : dump; unsigned[4] scaledFrequencies[numberOfFrequencies] : dump; +alias scaledValuesOfWaveDirections = scaledDirections : hidden; +alias scaledValuesOfWaveFrequencies = scaledFrequencies : hidden; + constant GRIBEXSection1Problem = 100 + 4 * numberOfDirections + 4 * numberOfFrequencies - section1Length ; + +# ECC-1907 +constant ninety_nine = 99 : hidden; +if (stream is 'ewla' or stream is 'waef') { + alias productDefinitionTemplateNumber = hundred; +} else { + alias productDefinitionTemplateNumber = ninety_nine; +} diff --git a/definitions/grib1/local.98.18.def b/definitions/grib1/local.98.18.def index 2897af593..f51f19970 100644 --- a/definitions/grib1/local.98.18.def +++ b/definitions/grib1/local.98.18.def @@ -10,7 +10,7 @@ constant grib2LocalSectionNumber=18; if (stepType is "instant" ) { alias productDefinitionTemplateNumber=epsPoint; } else { - alias productDefinitionTemplateNumber=epsContinous; + alias productDefinitionTemplateNumber=epsContinuous; } template mars_labeling "grib1/mars_labeling.def"; diff --git a/definitions/grib1/local.98.218.def b/definitions/grib1/local.98.218.def index c6787e258..872a4e734 100644 --- a/definitions/grib1/local.98.218.def +++ b/definitions/grib1/local.98.218.def @@ -10,7 +10,7 @@ constant grib2LocalSectionNumber=18; if (stepType is "instant" ) { alias productDefinitionTemplateNumber=epsPoint; } else { - alias productDefinitionTemplateNumber=epsContinous; + alias productDefinitionTemplateNumber=epsContinuous; } template mars_labeling "grib1/mars_labeling.def"; diff --git a/definitions/grib1/local.98.26.def b/definitions/grib1/local.98.26.def index 4a9ce6c3e..3c1ad63e0 100644 --- a/definitions/grib1/local.98.26.def +++ b/definitions/grib1/local.98.26.def @@ -14,7 +14,7 @@ constant grib2LocalSectionNumber=26; if (stepType is "instant" ) { alias productDefinitionTemplateNumber=epsPoint; } else { - alias productDefinitionTemplateNumber=epsContinous; + alias productDefinitionTemplateNumber=epsContinuous; } constant wrongPadding=1 : hidden; diff --git a/definitions/grib1/local.98.30.def b/definitions/grib1/local.98.30.def index ee7c46a5e..e19efd77f 100644 --- a/definitions/grib1/local.98.30.def +++ b/definitions/grib1/local.98.30.def @@ -23,7 +23,7 @@ if (stepType is "instant" ) { if (type is "em" || type is "es" ) { alias productDefinitionTemplateNumber=epsStatisticsContinous; } else { - alias productDefinitionTemplateNumber=epsContinous; + alias productDefinitionTemplateNumber=epsContinuous; } } diff --git a/definitions/grib1/local.98.36.def b/definitions/grib1/local.98.36.def index c0b6a1baf..32329c92c 100644 --- a/definitions/grib1/local.98.36.def +++ b/definitions/grib1/local.98.36.def @@ -47,7 +47,7 @@ if (stepType is "instant" ) { } else { alias typeOfEnsembleForecast=three; } - alias productDefinitionTemplateNumber=epsContinous; + alias productDefinitionTemplateNumber=epsContinuous; } else { alias productDefinitionTemplateNumber=eight; } diff --git a/definitions/grib1/local/ecmf/3.table b/definitions/grib1/local/ecmf/3.table index 767213f12..8589b462e 100644 --- a/definitions/grib1/local/ecmf/3.table +++ b/definitions/grib1/local/ecmf/3.table @@ -42,10 +42,12 @@ 141 141 Layer between two isobaric surfaces (mixed precision) pressure of top, in kPa 1100hPa minus pressure of bottom, in hPa # 142-159 Reserved 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) 201 201 Entire ocean considered as a single layer 0 (2 octets) -# 202-209 Reserved +202 al Abstract Single Level +203 al Abstract Multiple Level +# 204-209 Reserved 210 pl Isobaric surface (Pa) (ECMWF extension) # 211-254 Reserved for local use 211 wv Ocean wave level (ECMWF extension) diff --git a/definitions/grib1/local_no_mars.98.1.def b/definitions/grib1/local_no_mars.98.1.def index bbb31966c..f028eb030 100644 --- a/definitions/grib1/local_no_mars.98.1.def +++ b/definitions/grib1/local_no_mars.98.1.def @@ -48,7 +48,7 @@ if (stepType is "instant" ) { } else { alias typeOfEnsembleForecast=three; } - alias productDefinitionTemplateNumber=epsContinous; + alias productDefinitionTemplateNumber=epsContinuous; } else { alias productDefinitionTemplateNumber=eight; } diff --git a/definitions/grib1/predefined_grid.def b/definitions/grib1/predefined_grid.def index 03352f650..02a6994ad 100644 --- a/definitions/grib1/predefined_grid.def +++ b/definitions/grib1/predefined_grid.def @@ -121,7 +121,7 @@ constant numberOfUnusedBitsAtEndOfSection3 = 0; constant tableReference = 0; #position offsetBeforeBitmap; -meta bitmap gds_not_present_bitmap( missingValue,numberOfValues, - numberOfPoints, - latitudeOfFirstGridPoint, - Ni,numberOfUnusedBitsAtEndOfSection3) : read_only; +# meta bitmap gds_not_present_bitmap( missingValue,numberOfValues, +# numberOfPoints, +# latitudeOfFirstGridPoint, +# Ni,numberOfUnusedBitsAtEndOfSection3) : read_only; diff --git a/definitions/grib1/section.1.def b/definitions/grib1/section.1.def index c2dd5c5e0..3e8f936a8 100644 --- a/definitions/grib1/section.1.def +++ b/definitions/grib1/section.1.def @@ -105,7 +105,8 @@ if( indicatorOfTypeOfLevel == 109 || indicatorOfTypeOfLevel == 100 || indicatorOfTypeOfLevel == 110 || indicatorOfTypeOfLevel == 113 || - indicatorOfTypeOfLevel == 117) + indicatorOfTypeOfLevel == 117 || + indicatorOfTypeOfLevel == 203) { alias mars.levelist = level; } diff --git a/definitions/grib1/typeOfLevel.def b/definitions/grib1/typeOfLevel.def index ccf74d5be..f5154a706 100644 --- a/definitions/grib1/typeOfLevel.def +++ b/definitions/grib1/typeOfLevel.def @@ -34,3 +34,5 @@ 'depthBelowSea' = {indicatorOfTypeOfLevel=160;} 'entireAtmosphere' = {indicatorOfTypeOfLevel=200;} 'entireOcean' = {indicatorOfTypeOfLevel=201;} +'abstractSingleLevel' = {indicatorOfTypeOfLevel=202; level=missing();} +'abstractMultipleLevels' = {indicatorOfTypeOfLevel=203;} diff --git a/definitions/grib2/templates/template.4.reforecast.def b/definitions/grib2/templates/template.4.reforecast.def index a8a431936..15e7c6ec4 100644 --- a/definitions/grib2/templates/template.4.reforecast.def +++ b/definitions/grib2/templates/template.4.reforecast.def @@ -12,5 +12,7 @@ unsigned[1] SecondOfModelVersion = 0: edition_specific; meta modelVersionDate g2date(YearOfModelVersion,MonthOfModelVersion,DayOfModelVersion) : dump; meta modelVersionTime time(HourOfModelVersion, MinuteOfModelVersion, SecondOfModelVersion) : dump; +alias referenceDate = modelVersionDate ; + remove isHindcast; constant isHindcast = 1; diff --git a/definitions/grib2/templates/template.4.statistical.def b/definitions/grib2/templates/template.4.statistical.def index a98b8f212..fde76eba3 100644 --- a/definitions/grib2/templates/template.4.statistical.def +++ b/definitions/grib2/templates/template.4.statistical.def @@ -54,12 +54,9 @@ statisticalProcessesList list(numberOfTimeRanges) if (numberOfTimeRanges == 1 || numberOfTimeRanges == 2) { concept stepTypeInternal { "instant" = {typeOfStatisticalProcessing=255;} - "avg" = {typeOfStatisticalProcessing=0;typeOfTimeIncrement=255;} - "avg" = {typeOfStatisticalProcessing=0;typeOfTimeIncrement=2;} - "avg" = {typeOfStatisticalProcessing=0;typeOfTimeIncrement=3;} + "avg" = {typeOfStatisticalProcessing=0;} "avgd" = {typeOfStatisticalProcessing=0;typeOfTimeIncrement=1;} - "accum" = {typeOfStatisticalProcessing=1;typeOfTimeIncrement=255;} - "accum" = {typeOfStatisticalProcessing=1;typeOfTimeIncrement=2;} + "accum" = {typeOfStatisticalProcessing=1;} "max" = {typeOfStatisticalProcessing=2;} "min" = {typeOfStatisticalProcessing=3;} "diff" = {typeOfStatisticalProcessing=4;} # end-start diff --git a/definitions/grib2/templates/template.4.wave.def b/definitions/grib2/templates/template.4.wave.def index 742c0ece4..c58a45019 100644 --- a/definitions/grib2/templates/template.4.wave.def +++ b/definitions/grib2/templates/template.4.wave.def @@ -1,21 +1,21 @@ # (C) Copyright 2005- ECMWF. # Template for wave parameters -## Direction part +# Direction part unsigned[2] waveDirectionNumber : dump; alias mars.direction = waveDirectionNumber; alias directionNumber = waveDirectionNumber; -unsigned[2] numberOfWaveDirections = 1 : dump; +unsigned[2] numberOfWaveDirections = 0 : dump; alias totalNumberOfWaveDirections = numberOfWaveDirections; alias numberOfDirections = totalNumberOfWaveDirections; -## Frequency part +# Frequency part unsigned[2] waveFrequencyNumber : dump; alias mars.frequency = waveFrequencyNumber; alias frequencyNumber = waveFrequencyNumber; -unsigned[2] numberOfWaveFrequencies = 1 : dump; +unsigned[2] numberOfWaveFrequencies = 0 : dump; alias totalNumberOfWaveFrequencies = numberOfWaveFrequencies; alias numberOfFrequencies = totalNumberOfWaveFrequencies; diff --git a/definitions/grib2/templates/template.4.wave_spectra_list.def b/definitions/grib2/templates/template.4.wave_spectra_list.def index ca7768604..60d279c4f 100644 --- a/definitions/grib2/templates/template.4.wave_spectra_list.def +++ b/definitions/grib2/templates/template.4.wave_spectra_list.def @@ -2,18 +2,22 @@ # Template for wave spectra defined using an array of frequencies and directions -## Direction part +# Direction part signed[1] scaleFactorOfWaveDirections : dump; alias integerScalingFactorAppliedToDirections = scaleFactorOfWaveDirections; alias directionScalingFactor = integerScalingFactorAppliedToDirections; -unsigned[4] scaledValuesOfWaveDirections[numberOfWaveDirections] : dump; -alias scaledDirections = scaledValuesOfWaveDirections ; +if (numberOfWaveDirections > 0) { + unsigned[4] scaledValuesOfWaveDirections[numberOfWaveDirections] : dump; + alias scaledDirections = scaledValuesOfWaveDirections ; +} -## Frequency part +# Frequency part signed[1] scaleFactorOfWaveFrequencies : dump; alias integerScalingFactorAppliedToFrequencies = scaleFactorOfWaveFrequencies; alias frequencyScalingFactor = integerScalingFactorAppliedToFrequencies; -unsigned[4] scaledValuesOfWaveFrequencies[numberOfWaveFrequencies] : dump; -alias scaledFrequencies = scaledValuesOfWaveFrequencies; +if (numberOfWaveFrequencies > 0) { + unsigned[4] scaledValuesOfWaveFrequencies[numberOfWaveFrequencies] : dump; + alias scaledFrequencies = scaledValuesOfWaveFrequencies; +} diff --git a/eccodes_config.h.in b/eccodes_config.h.in index 4432f9a10..29877a3d9 100644 --- a/eccodes_config.h.in +++ b/eccodes_config.h.in @@ -115,6 +115,7 @@ #cmakedefine HAVE_GEOGRAPHY #cmakedefine HAVE_MEMFS +#cmakedefine HAVE_FORTRAN #ifdef HAVE_MEMFS #undef ECCODES_DEFINITION_PATH diff --git a/examples/C/CMakeLists.txt b/examples/C/CMakeLists.txt index 5e3795ef8..d25014ed0 100644 --- a/examples/C/CMakeLists.txt +++ b/examples/C/CMakeLists.txt @@ -26,7 +26,6 @@ list( APPEND test_bins grib_get_data grib_sections_copy grib_copy_keys - grib_iterator_bitmap grib_clone grib_copy_message grib_ensemble_index diff --git a/examples/C/bufr_clone.c b/examples/C/bufr_clone.c index 3cda29678..6a617eb50 100644 --- a/examples/C/bufr_clone.c +++ b/examples/C/bufr_clone.c @@ -18,11 +18,6 @@ #include #include "eccodes.h" -static void usage(const char* app) -{ - fprintf(stderr, "Usage is: %s input_file ouput_file\n", app); -} - int main(int argc, char* argv[]) { FILE* in = NULL; @@ -36,7 +31,6 @@ int main(int argc, char* argv[]) int i, err = 0; if (argc != 3) { - usage(argv[0]); return 1; } diff --git a/examples/C/grib_clone.c b/examples/C/grib_clone.c index c2964b54a..dce6c909d 100644 --- a/examples/C/grib_clone.c +++ b/examples/C/grib_clone.c @@ -18,11 +18,6 @@ #include #include "eccodes.h" -static void usage(const char* app) -{ - fprintf(stderr, "Usage is: %s input_file ouput_file\n", app); -} - int main(int argc, char* argv[]) { FILE* in = NULL; @@ -33,7 +28,6 @@ int main(int argc, char* argv[]) int err = 0; if (argc != 3) { - usage(argv[0]); return 1; } diff --git a/examples/C/grib_copy_message.c b/examples/C/grib_copy_message.c index 461bf4ea6..7757fd94a 100644 --- a/examples/C/grib_copy_message.c +++ b/examples/C/grib_copy_message.c @@ -18,11 +18,6 @@ #include "eccodes.h" #include -static void usage(const char* prog) -{ - fprintf(stderr, "Usage is: %s input_file ouput_file\n", prog); -} - int main(int argc, char* argv[]) { FILE* in = NULL; @@ -30,7 +25,6 @@ int main(int argc, char* argv[]) int err = 0; if (argc != 3) { - usage(argv[0]); return 1; } diff --git a/examples/C/grib_multi.c b/examples/C/grib_multi.c index 617c30a71..58f19086a 100644 --- a/examples/C/grib_multi.c +++ b/examples/C/grib_multi.c @@ -42,14 +42,14 @@ int main(int argc, char** argv) return 1; } - CODES_CHECK(grib_count_in_file(NULL, in, &mcount), 0); + CODES_CHECK(codes_count_in_file(NULL, in, &mcount), 0); assert(mcount == 56); - printf("grib_count_in_file counted %d messages\n", mcount); + printf("count_in_file counted %d messages\n", mcount); mcount = 0; - CODES_CHECK(grib_count_in_filename(NULL, filename, &mcount), 0); + CODES_CHECK(codes_count_in_filename(NULL, filename, &mcount), 0); assert(mcount == 56); - printf("grib_count_in_filename counted %d messages\n", mcount); + printf("count_in_filename counted %d messages\n", mcount); mcount = 0; while ((h = codes_handle_new_from_file(0, in, PRODUCT_GRIB, &err)) != NULL) { diff --git a/examples/C/grib_set_pv.c b/examples/C/grib_set_pv.c index e279aec8b..7352f6f84 100644 --- a/examples/C/grib_set_pv.c +++ b/examples/C/grib_set_pv.c @@ -19,12 +19,6 @@ #include #include "eccodes.h" -static void usage(const char* prog) -{ - fprintf(stderr, "usage: %s in out\n", prog); - exit(1); -} - int main(int argc, char** argv) { int err = 0; @@ -40,7 +34,7 @@ int main(int argc, char** argv) codes_handle* h = NULL; const void* buffer = NULL; - if (argc != 3) usage(argv[0]); + if (argc != 3) return 1; infile = argv[1]; outfile = argv[2]; diff --git a/examples/C/mars_param.c b/examples/C/mars_param.c index aff84d385..ee56cad31 100644 --- a/examples/C/mars_param.c +++ b/examples/C/mars_param.c @@ -20,14 +20,11 @@ int main(int argc, char** argv) { - codes_string_list* list; - codes_string_list* list2; - - list = codes_grib_util_get_param_id("11.2"); + const codes_string_list* list = codes_grib_util_get_param_id("11.2"); printf("mars.param=11.2 -> paramId= "); while (list) { + const codes_string_list* list2 = codes_grib_util_get_param_id("130.128"); printf("%s ", list->value); - list2 = codes_grib_util_get_param_id("130.128"); printf("mars.param=11.2 -> paramId= "); while (list2) { printf("%s ", list2->value); diff --git a/examples/C/nc.c b/examples/C/nc.c index 35b844f1e..6858a6ac5 100644 --- a/examples/C/nc.c +++ b/examples/C/nc.c @@ -9,7 +9,7 @@ */ #include "eccodes.h" -void usage(char* prog) +void usage(const char* prog) { printf("usage: %s in.nc\n", prog); exit(1); diff --git a/examples/F90/CMakeLists.txt b/examples/F90/CMakeLists.txt index 30a3de0e9..7ec9c28b2 100644 --- a/examples/F90/CMakeLists.txt +++ b/examples/F90/CMakeLists.txt @@ -155,12 +155,12 @@ ecbuild_add_test( TARGET eccodes_f_grib_set_packing COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_set_packing.sh ) # Executables without a shell script -ecbuild_add_executable( TARGET eccodes_f_new_from_file - NOINSTALL - SOURCES new_from_file.f90 - CONDITION HAVE_FORTRAN - LINKER_LANGUAGE Fortran - LIBS eccodes_f90 eccodes ) +#ecbuild_add_executable( TARGET eccodes_f_new_from_file +# NOINSTALL +# SOURCES new_from_file.f90 +# CONDITION HAVE_FORTRAN +# LINKER_LANGUAGE Fortran +# LIBS eccodes_f90 eccodes ) ecbuild_add_executable( TARGET eccodes_f_grib_set_gvc NOINSTALL SOURCES grib_set_gvc.f90 diff --git a/examples/F90/codes_dump.f90 b/examples/F90/codes_dump.f90 index ab547ec04..84f04f668 100644 --- a/examples/F90/codes_dump.f90 +++ b/examples/F90/codes_dump.f90 @@ -21,6 +21,7 @@ program codes_dump_test call getarg(2, infile_name) + call codes_set_debug(-1) call codes_open_file(ifile, infile_name, 'r') print *, "===== FILE:", infile_name @@ -29,7 +30,9 @@ program codes_dump_test !call codes_any_new_from_file(ifile, msgid, iret) if (iret == CODES_END_OF_FILE) exit + call codes_set_debug(0) call codes_dump(msgid) + call codes_set_debug(1) call codes_release(msgid) diff --git a/examples/F90/grib_keys_iterator_skip.f90 b/examples/F90/grib_keys_iterator_skip.f90 index f6c58d227..c64df2447 100644 --- a/examples/F90/grib_keys_iterator_skip.f90 +++ b/examples/F90/grib_keys_iterator_skip.f90 @@ -15,13 +15,12 @@ program keys_iterator_skip character(len=256) :: key character(len=256) :: value character(len=512) :: all1 - integer :: grib_count + integer :: grib_count = 0 call codes_open_file(ifile, & '../../data/regular_latlon_surface.grib1', 'r') ! Loop on all the messages in a file - grib_count = 0 do while (.true.) call codes_grib_new_from_file(ifile, igrib, iret) if (iret == CODES_END_OF_FILE) exit @@ -37,15 +36,20 @@ program keys_iterator_skip call codes_skip_coded(kiter) call codes_skip_duplicates(kiter) call codes_skip_read_only(kiter) + call codes_skip_function(kiter) + call codes_skip_edition_specific(kiter) do call codes_keys_iterator_next(kiter, iret) - if (iret .ne. CODES_SUCCESS) exit !terminate the loop + if (iret .ne. CODES_SUCCESS) exit ! Terminate the loop - call codes_keys_iterator_get_name(kiter, key) - call codes_get(igrib, trim(key), value) - all1 = trim(key)//' = '//trim(value) - write (*, *) trim(all1) + ! All keys should be skipped so should not get here + call codes_check(CODES_INTERNAL_ERROR, 'Error', 'iterator next should have failed') + + !call codes_keys_iterator_get_name(kiter, key) + !call codes_get(igrib, trim(key), value) + !all1 = trim(key)//' = '//trim(value) + !write (*, *) trim(all1) end do call codes_keys_iterator_delete(kiter) diff --git a/examples/F90/new_from_file.f90 b/examples/F90/new_from_file.f90 deleted file mode 100644 index d1eecf272..000000000 --- a/examples/F90/new_from_file.f90 +++ /dev/null @@ -1,40 +0,0 @@ -! (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. -! -! -! -program new_from_file - use eccodes - implicit none - integer :: ifile - integer :: iret - integer :: count1 = 0 - - ! Message identifier. - integer :: igrib - - ifile = 5 - - call codes_open_file(ifile, '../../data/collection.grib1', 'r') - - ! Loop on all the messages in a file. - call codes_grib_new_from_file(ifile, igrib, iret) - - do while (iret == CODES_SUCCESS) - count1 = count1 + 1 - print *, "===== Message #", count1 - call codes_grib_new_from_file(ifile, igrib, iret) - - end do - if (iret /= CODES_END_OF_FILE) then - call codes_check(iret, 'new_from_file', '') - end if - - call codes_close_file(ifile) - -end program diff --git a/examples/extra/f_clone.f90 b/examples/extra/f_clone.f90 index 7eedd1dfe..f9552d0c1 100755 --- a/examples/extra/f_clone.f90 +++ b/examples/extra/f_clone.f90 @@ -6,10 +6,9 @@ ! 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. ! -! Description: how to create a new GRIB message by cloning +! Description: how to create a new GRIB message by cloning ! an existing message. ! -! ! Author: Cristian D. Codorean ! ! diff --git a/fortran/eccodes_f90_tail.f90 b/fortran/eccodes_f90_tail.f90 index 4ecf52d03..4e7a951e9 100644 --- a/fortran/eccodes_f90_tail.f90 +++ b/fortran/eccodes_f90_tail.f90 @@ -2765,12 +2765,29 @@ call grib_skip_read_only(iterid, status) end subroutine codes_skip_read_only + subroutine codes_skip_function(iterid, status) + integer(kind=kindOfInt), intent(in) :: iterid + integer(kind=kindOfInt), optional, intent(out) :: status + + call grib_skip_function(iterid, status) + end subroutine codes_skip_function + + subroutine codes_skip_edition_specific(iterid, status) + integer(kind=kindOfInt), intent(in) :: iterid + integer(kind=kindOfInt), optional, intent(out) :: status + + call grib_skip_edition_specific(iterid, status) + end subroutine codes_skip_edition_specific + + !> Set debug mode subroutine codes_set_debug(dmode) integer(kind=kindOfInt), intent(in) :: dmode call grib_set_debug(dmode) end subroutine codes_set_debug + + !> Set the definition path !> !> In case of error, if the status parameter (optional) is not given, the program will diff --git a/fortran/eccodes_visibility.h b/fortran/eccodes_visibility.h index 0c26a53f7..9e720f1cd 100644 --- a/fortran/eccodes_visibility.h +++ b/fortran/eccodes_visibility.h @@ -7,6 +7,8 @@ public :: codes_keys_iterator_new, & public :: codes_skip_computed, & codes_skip_coded, & codes_skip_duplicates, & + codes_skip_function, & + codes_skip_edition_specific, & codes_skip_read_only public :: codes_keys_iterator_get_name, & codes_keys_iterator_rewind diff --git a/fortran/grib_f90_tail.f90 b/fortran/grib_f90_tail.f90 index 790ae3ace..ffd5b598c 100644 --- a/fortran/grib_f90_tail.f90 +++ b/fortran/grib_f90_tail.f90 @@ -3177,6 +3177,34 @@ end if end subroutine grib_skip_read_only + + subroutine grib_skip_function(iterid, status) + integer(kind=kindOfInt), intent(in) :: iterid + integer(kind=kindOfInt), optional, intent(out) :: status + integer(kind=kindOfInt) :: iret + + iret = grib_f_skip_function(iterid) + if (present(status)) then + status = iret + else + call grib_check(iret, 'skip_function', '') + end if + end subroutine grib_skip_function + + !!! + subroutine grib_skip_edition_specific(iterid, status) + integer(kind=kindOfInt), intent(in) :: iterid + integer(kind=kindOfInt), optional, intent(out) :: status + integer(kind=kindOfInt) :: iret + + iret = grib_f_skip_edition_specific(iterid) + if (present(status)) then + status = iret + else + call grib_check(iret, 'skip_edition_specific', '') + end if + end subroutine grib_skip_edition_specific + !> Set debug mode subroutine grib_set_debug(dmode) integer(kind=kindOfInt), intent(in) :: dmode diff --git a/fortran/grib_fortran.cc b/fortran/grib_fortran.cc index 84fe48997..fd0a0e726 100644 --- a/fortran/grib_fortran.cc +++ b/fortran/grib_fortran.cc @@ -865,13 +865,11 @@ int grib_f_read_any_headers_only_from_file_(int* fid, char* buffer, size_t* nbyt /*****************************************************************************/ int grib_f_read_any_from_file_(int* fid, void* buffer, size_t* nbytes) { - grib_context* c; - int err=0; - FILE* f=get_file(*fid); + FILE* f = get_file(*fid); if (f) { - c=grib_context_get_default( ); - err=grib_read_any_from_file(c,f,buffer,nbytes); + grib_context* c = grib_context_get_default( ); + int err=grib_read_any_from_file(c,f,buffer,nbytes); return err; } else { return GRIB_INVALID_FILE; @@ -1141,7 +1139,6 @@ int grib_f_iterator_delete_(int* iterid) { /*****************************************************************************/ static int _grib_f_keys_iterator_new_(int* gid,int* iterid,char* name_space,int len) { - int err=0; char buf[1024]; grib_handle* h; grib_keys_iterator* iter; @@ -1156,7 +1153,7 @@ static int _grib_f_keys_iterator_new_(int* gid,int* iterid,char* name_space,int *iterid=push_keys_iterator(iter); else *iterid=-1; - return err; + return GRIB_SUCCESS; } int grib_f_keys_iterator_new_(int* gid,int* iterid,char* name_space,int len) { @@ -1276,7 +1273,6 @@ int grib_f_keys_iterator_rewind_(int* kiter) /*****************************************************************************/ static int _codes_f_bufr_keys_iterator_new_(int* gid,int* iterid) { - int err=0; grib_handle* h; bufr_keys_iterator* iter; @@ -1291,7 +1287,7 @@ static int _codes_f_bufr_keys_iterator_new_(int* gid,int* iterid) *iterid=push_bufr_keys_iterator(iter); else *iterid=-1; - return err; + return GRIB_SUCCESS; } int codes_f_bufr_keys_iterator_new_(int* gid,int* iterid) { @@ -1767,8 +1763,7 @@ int grib_f_index_add_file_(int* index_id, char* file, int lfile) if (!i) { return GRIB_INVALID_INDEX; } else { - int err = grib_index_add_file(i,cast_char(buf,file,lfile)); - return err; + return grib_index_add_file(i,cast_char(buf,file,lfile)); } } @@ -1799,14 +1794,12 @@ int grib_f_index_read_(char* file, int* gid, int lfile) int grib_f_index_write_(int* gid, char* file, int lfile) { grib_index *i = get_index(*gid); - int err = GRIB_SUCCESS; char buf[1024]; if (!i) { return GRIB_INVALID_GRIB; } else { - err = grib_index_write(i,cast_char(buf,file,lfile)); - return err; + return grib_index_write(i,cast_char(buf,file,lfile)); } } @@ -1898,51 +1891,44 @@ int grib_f_get_api_version_(int* apiVersion,int len) int grib_f_get_size_int_(int* gid, char* key, int* val, int len) { grib_handle* h = get_handle(*gid); - int err = GRIB_SUCCESS; + char buf[1024]; size_t tsize = 0; - if (!h) { - return GRIB_INVALID_GRIB; - } - else { - err = grib_get_size(h, cast_char(buf, key, len), &tsize); - *val = tsize; - return err; - } + if (!h) return GRIB_INVALID_GRIB; + + int err = grib_get_size(h, cast_char(buf, key, len), &tsize); + *val = tsize; + return err; } int grib_f_get_size_long_(int* gid, char* key, long* val, int len) { grib_handle *h = get_handle(*gid); - int err = GRIB_SUCCESS; + char buf[1024]; size_t tsize = 0; - if(!h){ - return GRIB_INVALID_GRIB; - }else{ - err = grib_get_size(h, cast_char(buf,key,len), &tsize); - *val = tsize; - return err; - } + if (!h) return GRIB_INVALID_GRIB; + + int err = grib_get_size(h, cast_char(buf,key,len), &tsize); + *val = tsize; + return err; } /*****************************************************************************/ int grib_f_index_get_size_int_(int* index_id, char* key, int* val, int len) { grib_index *h = get_index(*index_id); - int err = GRIB_SUCCESS; + char buf[1024]; size_t tsize = 0; - if(!h){ - return GRIB_INVALID_GRIB; - }else{ - err = grib_index_get_size(h, cast_char(buf,key,len), &tsize); - *val = tsize; - return err; - } + if (!h) return GRIB_INVALID_GRIB; + + int err = grib_index_get_size(h, cast_char(buf,key,len), &tsize); + *val = tsize; + return err; } int grib_f_index_get_size_long_(int* index_id, char* key, long* val, int len) @@ -1951,13 +1937,11 @@ int grib_f_index_get_size_long_(int* index_id, char* key, long* val, int len) char buf[1024]; size_t tsize = 0; - if (!h){ - return GRIB_INVALID_GRIB; - } else{ - int err = grib_index_get_size(h, cast_char(buf,key,len), &tsize); - *val = tsize; - return err; - } + if (!h) return GRIB_INVALID_GRIB; + + int err = grib_index_get_size(h, cast_char(buf,key,len), &tsize); + *val = tsize; + return err; } /*****************************************************************************/ @@ -1965,11 +1949,10 @@ int grib_f_get_int_(int* gid, char* key, int* val, int len) { grib_handle *h = get_handle(*gid); long long_val; - int err = GRIB_SUCCESS; char buf[1024]; - if(!h) return GRIB_INVALID_GRIB; - err = grib_get_long(h, cast_char(buf,key,len),&long_val); + if (!h) return GRIB_INVALID_GRIB; + int err = grib_get_long(h, cast_char(buf,key,len),&long_val); *val = long_val; return err; } @@ -1977,11 +1960,11 @@ int grib_f_get_int_(int* gid, char* key, int* val, int len) int grib_f_get_long_(int* gid, char* key, long* val, int len) { grib_handle *h = get_handle(*gid); - int err = GRIB_SUCCESS; + char buf[1024]; - if(!h) return GRIB_INVALID_GRIB; - err = grib_get_long(h, cast_char(buf,key,len),val); + if (!h) return GRIB_INVALID_GRIB; + int err = grib_get_long(h, cast_char(buf,key,len),val); return err; } @@ -1990,11 +1973,10 @@ int grib_f_get_native_type_(int* gid, char* key, int* val, int len) { grib_handle *h = get_handle(*gid); int type_val = 0; - int err = GRIB_SUCCESS; char buf[1024]; if (!h) return GRIB_INVALID_GRIB; - err = grib_get_native_type(h, cast_char(buf,key,len), &type_val); + int err = grib_get_native_type(h, cast_char(buf,key,len), &type_val); *val = type_val; return err; } @@ -2034,13 +2016,13 @@ int grib_f_get_int_array_(int* gid, char* key, int *val, int* size, int len) int grib_f_get_long_array_(int* gid, char* key, long *val, int* size, int len) { grib_handle *h = get_handle(*gid); - int err = GRIB_SUCCESS; + char buf[1024]; size_t lsize = *size; if(!h) return GRIB_INVALID_GRIB; - err = grib_get_long_array(h, cast_char(buf,key,len), val, &lsize); + int err = grib_get_long_array(h, cast_char(buf,key,len), val, &lsize); *size=lsize; return err; @@ -2050,13 +2032,13 @@ int grib_f_get_long_array_(int* gid, char* key, long *val, int* size, int len) int grib_f_get_byte_array_(int* gid, char* key, unsigned char *val, int* size, int len, int lenv) { grib_handle *h = get_handle(*gid); - int err = GRIB_SUCCESS; + char buf[1024]; size_t lsize = *size; if(!h) return GRIB_INVALID_GRIB; - err = grib_get_bytes(h, cast_char(buf,key,len), val, &lsize); + int err = grib_get_bytes(h, cast_char(buf,key,len), val, &lsize); *size = (int) lsize; return err; @@ -2066,25 +2048,22 @@ int grib_f_get_byte_array_(int* gid, char* key, unsigned char *val, int* size, i int grib_f_index_get_string_(int* index_id, char* key, char* val, int *eachsize,int* size, int len) { grib_index *h = get_index(*index_id); - int err = GRIB_SUCCESS; - int i; + char buf[1024]; size_t lsize = *size; - char** bufval; - char* p=val; + char* p = val; if(!h) return GRIB_INVALID_GRIB; - bufval=(char**)grib_context_malloc_clear(h->context,sizeof(char*)* *size); + char** bufval=(char**)grib_context_malloc_clear(h->context,sizeof(char*)* *size); - err = grib_index_get_string(h, cast_char(buf,key,len), bufval, &lsize); + int err = grib_index_get_string(h, cast_char(buf,key,len), bufval, &lsize); *size = lsize; if (err) return err; - for (i=0;icontext, bufval[i]); } grib_context_free(h->context,bufval); - return err; + return err; } /*****************************************************************************/ int grib_f_index_get_long_(int* index_id, char* key, long *val, int* size, int len) { - int err = 0; grib_index* h = get_index(*index_id); char buf[1024]; size_t lsize = *size; if (!h) return GRIB_INVALID_GRIB; - err = grib_index_get_long(h, cast_char(buf,key,len), val, &lsize); + int err = grib_index_get_long(h, cast_char(buf,key,len), val, &lsize); *size = lsize; return err; } @@ -2121,17 +2099,17 @@ int grib_f_index_get_long_(int* index_id, char* key, long *val, int* size, int l int grib_f_index_get_int_(int* index_id, char* key, int *val, int* size, int len) { grib_index *h = get_index(*index_id); - int err = GRIB_SUCCESS; + char buf[1024]; size_t lsize = *size, i = 0; long* lval=0; - if(!h) return GRIB_INVALID_GRIB; + if (!h) return GRIB_INVALID_GRIB; lval=(long*)grib_context_malloc(h->context,sizeof(long)* *size); if (!lval) return GRIB_OUT_OF_MEMORY; - err = grib_index_get_long(h, cast_char(buf,key,len), lval, &lsize); + int err = grib_index_get_long(h, cast_char(buf,key,len), lval, &lsize); for (i=0;i +#include +#include grib_accessor_concept_t _grib_accessor_concept{}; grib_accessor* grib_accessor_concept = &_grib_accessor_concept; @@ -43,8 +46,28 @@ void grib_accessor_concept_t::dump(grib_dumper* dumper) grib_dump_string(dumper, this, NULL); } +// See ECC-1905 +static int grib_get_long_memoize( + grib_handle* h, const char* key, long* value, + std::unordered_map& memo) +{ + int err = 0; + auto pos = memo.find(key); + if (pos == memo.end()) { // not in map so decode & insert + err = grib_get_long(h, key, value); + if (!err) { + memo.insert( std::make_pair(key, *value) ); + } + } else { + *value = pos->second; // found in map + } + return err; +} + /* Return 1 (=True) or 0 (=False) */ -static int concept_condition_expression_true(grib_handle* h, grib_concept_condition* c) +static int concept_condition_expression_true( + grib_handle* h, grib_concept_condition* c, + std::unordered_map& memo) { long lval; long lres = 0; @@ -55,8 +78,10 @@ static int concept_condition_expression_true(grib_handle* h, grib_concept_condit switch (type) { case GRIB_TYPE_LONG: grib_expression_evaluate_long(h, c->expression, &lres); - ok = (grib_get_long(h, c->name, &lval) == GRIB_SUCCESS) && + // Use memoization for the most common type (integer keys) + ok = (grib_get_long_memoize(h, c->name, &lval, memo) == GRIB_SUCCESS) && (lval == lres); + //ok = (grib_get_long(h, c->name, &lval) == GRIB_SUCCESS) && (lval == lres); break; case GRIB_TYPE_DOUBLE: { @@ -120,12 +145,14 @@ static int concept_condition_iarray_true(grib_handle* h, grib_concept_condition* } /* Return 1 (=True) or 0 (=False) */ -static int concept_condition_true(grib_handle* h, grib_concept_condition* c) +static int concept_condition_true( + grib_handle* h, grib_concept_condition* c, + std::unordered_map& memo) { if (c->expression == NULL) return concept_condition_iarray_true(h, c); else - return concept_condition_expression_true(h, c); + return concept_condition_expression_true(h, c, memo); } static const char* concept_evaluate(grib_accessor* a) @@ -136,12 +163,14 @@ static const char* concept_evaluate(grib_accessor* a) grib_concept_value* c = action_concept_get_concept(a); grib_handle* h = grib_handle_of_accessor(a); + std::unordered_map memo; // See ECC-1905 + // fprintf(stderr, "DEBUG: concept_evaluate: %s %s\n", name_ , c->name); while (c) { grib_concept_condition* e = c->conditions; int cnt = 0; while (e) { - if (!concept_condition_true(h, e)) + if (!concept_condition_true(h, e, memo)) break; e = e->next; cnt++; diff --git a/src/accessor/grib_accessor_class_dictionary.cc b/src/accessor/grib_accessor_class_dictionary.cc index bdaf20eb7..6bca21294 100644 --- a/src/accessor/grib_accessor_class_dictionary.cc +++ b/src/accessor/grib_accessor_class_dictionary.cc @@ -138,25 +138,27 @@ static grib_trie* load_dictionary(grib_accessor* a, int* err) fclose(f); if (localFilename != 0) { - f = codes_fopen(localFilename, "r"); - if (!f) { - *err = GRIB_IO_PROBLEM; - return NULL; - } + *err = GRIB_NOT_IMPLEMENTED; + return NULL; + // f = codes_fopen(localFilename, "r"); + // if (!f) { + // *err = GRIB_IO_PROBLEM; + // return NULL; + // } - while (fgets(line, sizeof(line) - 1, f)) { - i = 0; - while (line[i] != '|' && line[i] != 0) { - key[i] = line[i]; - i++; - } - key[i] = 0; - list = (char*)grib_context_malloc_clear(c, strlen(line) + 1); - memcpy(list, line, strlen(line)); - grib_trie_insert(dictionary, key, list); - } + //while (fgets(line, sizeof(line) - 1, f)) { + // i = 0; + // while (line[i] != '|' && line[i] != 0) { + // key[i] = line[i]; + // i++; + // } + // key[i] = 0; + // list = (char*)grib_context_malloc_clear(c, strlen(line) + 1); + // memcpy(list, line, strlen(line)); + // grib_trie_insert(dictionary, key, list); + //} - fclose(f); + //fclose(f); } grib_trie_insert(c->lists, filename, dictionary); return dictionary; diff --git a/src/accessor/grib_accessor_class_local_definition.cc b/src/accessor/grib_accessor_class_local_definition.cc index e8da63455..0a45b96ef 100644 --- a/src/accessor/grib_accessor_class_local_definition.cc +++ b/src/accessor/grib_accessor_class_local_definition.cc @@ -203,7 +203,7 @@ int grib_accessor_local_definition_t::pack_long(const long* val, size_t* len) // In test & development mode, fail so we remember to adjust PDTN grib_context_log(context_, GRIB_LOG_ERROR, "grib_accessor_local_definition_t: Invalid localDefinitionNumber %d", localDefinitionNumber); - return GRIB_ENCODING_ERROR; + // return GRIB_ENCODING_ERROR; #endif // ECC-1253: Do not fail in operations. Leave PDTN as is productDefinitionTemplateNumberNew = productDefinitionTemplateNumber; diff --git a/src/accessor_class_hierarchy.txt b/src/accessor_class_hierarchy.txt index 78f67c6fa..78eaf2530 100644 --- a/src/accessor_class_hierarchy.txt +++ b/src/accessor_class_hierarchy.txt @@ -85,7 +85,6 @@ Generated by src/make_accessor_class_hierarchy_dirs.sh |---grib_accessor_class_g2_mars_labeling |---grib_accessor_class_g2step_range |---grib_accessor_class_gaussian_grid_name - |---grib_accessor_class_gds_not_present_bitmap |---grib_accessor_class_group |---grib_accessor_class_hash_array |---grib_accessor_class_headers_only diff --git a/src/action.cc b/src/action.cc index 026bca74e..a5496c32d 100644 --- a/src/action.cc +++ b/src/action.cc @@ -95,7 +95,6 @@ static void grib_dump(grib_action* a, FILE* f, int l) } c = c->super ? *(c->super) : NULL; } - DEBUG_ASSERT(0); } // void grib_xref(grib_action* a, FILE* f, const char* path) @@ -210,7 +209,27 @@ void grib_dump_action_tree(grib_context* ctx, FILE* out) Assert(ctx->grib_reader); Assert(ctx->grib_reader->first); Assert(out); - grib_dump_action_branch(out, ctx->grib_reader->first->root, 0); + + // grib_dump_action_branch(out, ctx->grib_reader->first->root, 0); + // grib_action* next = ctx->grib_reader->first->root; + // while (next) { + // fprintf(out, "Dump %s\n", next->name); + // grib_dump_action_branch(out, next, 0); + // next = next->next; + // } + + grib_action_file* fr = ctx->grib_reader->first; + grib_action_file* fn = fr; + while (fn) { + fr = fn; + fn = fn->next; + grib_action* a = fr->root; + while (a) { + grib_action* na = a->next; + grib_dump_action_branch(out, a, 0); + a = na; + } + } } // void grib_xref_action_branch(FILE* out, grib_action* a, const char* path) diff --git a/src/action.class b/src/action.class index 772c328c6..704079e07 100644 --- a/src/action.class +++ b/src/action.class @@ -17,20 +17,17 @@ MEMBERS extern grib_action_class* SUPER; static grib_action_class _grib_action_class_NAME = { - &SUPER, /* super */ - "action_class_NAME", /* name */ - sizeof(grib_action_NAME), /* size */ - 0, /* inited */ + &SUPER, /* super */ + "action_class_NAME", /* name */ + sizeof(grib_action_NAME), /* size */ + 0, /* inited */ &init_class, /* init_class */ - &init, /* init */ + &init, /* init */ &destroy, /* destroy */ - - &dump, /* dump */ - &xref, /* xref */ - - &create_accessor, /* create_accessor*/ - - ¬ify_change, /* notify_change */ + &dump, /* dump */ + &xref, /* xref */ + &create_accessor, /* create_accessor */ + ¬ify_change, /* notify_change */ &reparse, /* reparse */ &execute, /* execute */ }; diff --git a/src/action_class_alias.cc b/src/action_class_alias.cc index 49ef35e43..3ae756cbe 100644 --- a/src/action_class_alias.cc +++ b/src/action_class_alias.cc @@ -49,20 +49,17 @@ typedef struct grib_action_alias { static grib_action_class _grib_action_class_alias = { - 0, /* super */ - "action_class_alias", /* name */ - sizeof(grib_action_alias), /* size */ - 0, /* inited */ + 0, /* super */ + "action_class_alias", /* name */ + sizeof(grib_action_alias), /* size */ + 0, /* inited */ &init_class, /* init_class */ - 0, /* init */ + 0, /* init */ &destroy, /* destroy */ - - &dump, /* dump */ - 0, /* xref */ - - &create_accessor, /* create_accessor*/ - - 0, /* notify_change */ + &dump, /* dump */ + 0, /* xref */ + &create_accessor, /* create_accessor */ + 0, /* notify_change */ 0, /* reparse */ 0, /* execute */ }; diff --git a/src/action_class_assert.cc b/src/action_class_assert.cc index b19330505..bc449c7ab 100644 --- a/src/action_class_assert.cc +++ b/src/action_class_assert.cc @@ -49,20 +49,17 @@ typedef struct grib_action_assert { static grib_action_class _grib_action_class_assert = { - 0, /* super */ - "action_class_assert", /* name */ - sizeof(grib_action_assert), /* size */ - 0, /* inited */ + 0, /* super */ + "action_class_assert", /* name */ + sizeof(grib_action_assert), /* size */ + 0, /* inited */ &init_class, /* init_class */ - 0, /* init */ + 0, /* init */ &destroy, /* destroy */ - - &dump, /* dump */ - 0, /* xref */ - - &create_accessor, /* create_accessor*/ - - ¬ify_change, /* notify_change */ + &dump, /* dump */ + 0, /* xref */ + &create_accessor, /* create_accessor */ + ¬ify_change, /* notify_change */ 0, /* reparse */ &execute, /* execute */ }; diff --git a/src/action_class_close.cc b/src/action_class_close.cc index dfe635890..00108c607 100644 --- a/src/action_class_close.cc +++ b/src/action_class_close.cc @@ -43,20 +43,17 @@ typedef struct grib_action_close { static grib_action_class _grib_action_class_close = { - 0, /* super */ - "action_class_close", /* name */ - sizeof(grib_action_close), /* size */ - 0, /* inited */ + 0, /* super */ + "action_class_close", /* name */ + sizeof(grib_action_close), /* size */ + 0, /* inited */ &init_class, /* init_class */ - 0, /* init */ + 0, /* init */ &destroy, /* destroy */ - - 0, /* dump */ - 0, /* xref */ - - 0, /* create_accessor*/ - - 0, /* notify_change */ + 0, /* dump */ + 0, /* xref */ + 0, /* create_accessor */ + 0, /* notify_change */ 0, /* reparse */ &execute, /* execute */ }; diff --git a/src/action_class_concept.cc b/src/action_class_concept.cc index eea243888..4e6592199 100644 --- a/src/action_class_concept.cc +++ b/src/action_class_concept.cc @@ -60,20 +60,17 @@ typedef struct grib_action_concept { extern grib_action_class* grib_action_class_gen; static grib_action_class _grib_action_class_concept = { - &grib_action_class_gen, /* super */ - "action_class_concept", /* name */ - sizeof(grib_action_concept), /* size */ - 0, /* inited */ + &grib_action_class_gen, /* super */ + "action_class_concept", /* name */ + sizeof(grib_action_concept), /* size */ + 0, /* inited */ &init_class, /* init_class */ - 0, /* init */ + 0, /* init */ &destroy, /* destroy */ - - &dump, /* dump */ - 0, /* xref */ - - 0, /* create_accessor*/ - - 0, /* notify_change */ + &dump, /* dump */ + 0, /* xref */ + 0, /* create_accessor */ + 0, /* notify_change */ 0, /* reparse */ 0, /* execute */ }; @@ -187,15 +184,12 @@ grib_action* grib_action_create_concept(grib_context* context, static void dump(grib_action* act, FILE* f, int lvl) { - int i = 0; - - for (i = 0; i < lvl; i++) + for (int i = 0; i < lvl; i++) grib_context_print(act->context, f, " "); - printf("concept(%s) { ", act->name); - printf("\n"); + printf("concept(%s) { \n", act->name); - for (i = 0; i < lvl; i++) + for (int i = 0; i < lvl; i++) grib_context_print(act->context, f, " "); printf("}\n"); } diff --git a/src/action_class_gen.cc b/src/action_class_gen.cc index a4a95b438..eaf1627ff 100644 --- a/src/action_class_gen.cc +++ b/src/action_class_gen.cc @@ -54,20 +54,17 @@ typedef struct grib_action_gen { static grib_action_class _grib_action_class_gen = { - 0, /* super */ - "action_class_gen", /* name */ - sizeof(grib_action_gen), /* size */ - 0, /* inited */ + 0, /* super */ + "action_class_gen", /* name */ + sizeof(grib_action_gen), /* size */ + 0, /* inited */ &init_class, /* init_class */ - 0, /* init */ + 0, /* init */ &destroy, /* destroy */ - - &dump, /* dump */ - 0, /* xref */ - - &create_accessor, /* create_accessor*/ - - ¬ify_change, /* notify_change */ + &dump, /* dump */ + 0, /* xref */ + &create_accessor, /* create_accessor */ + ¬ify_change, /* notify_change */ 0, /* reparse */ 0, /* execute */ }; diff --git a/src/action_class_hash_array.cc b/src/action_class_hash_array.cc index 9a61f9e56..55e87ddda 100644 --- a/src/action_class_hash_array.cc +++ b/src/action_class_hash_array.cc @@ -61,20 +61,17 @@ typedef struct grib_action_hash_array { extern grib_action_class* grib_action_class_gen; static grib_action_class _grib_action_class_hash_array = { - &grib_action_class_gen, /* super */ - "action_class_hash_array", /* name */ - sizeof(grib_action_hash_array), /* size */ - 0, /* inited */ + &grib_action_class_gen, /* super */ + "action_class_hash_array", /* name */ + sizeof(grib_action_hash_array), /* size */ + 0, /* inited */ &init_class, /* init_class */ - 0, /* init */ + 0, /* init */ &destroy, /* destroy */ - - &dump, /* dump */ - 0, /* xref */ - - 0, /* create_accessor*/ - - 0, /* notify_change */ + &dump, /* dump */ + 0, /* xref */ + 0, /* create_accessor */ + 0, /* notify_change */ 0, /* reparse */ 0, /* execute */ }; diff --git a/src/action_class_if.cc b/src/action_class_if.cc index c9c7d9d48..5d4140710 100644 --- a/src/action_class_if.cc +++ b/src/action_class_if.cc @@ -61,20 +61,17 @@ typedef struct grib_action_if { extern grib_action_class* grib_action_class_section; static grib_action_class _grib_action_class_if = { - &grib_action_class_section, /* super */ - "action_class_if", /* name */ - sizeof(grib_action_if), /* size */ - 0, /* inited */ + &grib_action_class_section, /* super */ + "action_class_if", /* name */ + sizeof(grib_action_if), /* size */ + 0, /* inited */ &init_class, /* init_class */ - 0, /* init */ + 0, /* init */ &destroy, /* destroy */ - - &dump, /* dump */ - 0, /* xref */ - - &create_accessor, /* create_accessor*/ - - 0, /* notify_change */ + &dump, /* dump */ + 0, /* xref */ + &create_accessor, /* create_accessor */ + 0, /* notify_change */ &reparse, /* reparse */ &execute, /* execute */ }; diff --git a/src/action_class_list.cc b/src/action_class_list.cc index 3441a6a39..00f8d1459 100644 --- a/src/action_class_list.cc +++ b/src/action_class_list.cc @@ -56,20 +56,17 @@ typedef struct grib_action_list { extern grib_action_class* grib_action_class_section; static grib_action_class _grib_action_class_list = { - &grib_action_class_section, /* super */ - "action_class_list", /* name */ - sizeof(grib_action_list), /* size */ - 0, /* inited */ + &grib_action_class_section, /* super */ + "action_class_list", /* name */ + sizeof(grib_action_list), /* size */ + 0, /* inited */ &init_class, /* init_class */ - 0, /* init */ + 0, /* init */ &destroy, /* destroy */ - - &dump, /* dump */ - 0, /* xref */ - - &create_accessor, /* create_accessor*/ - - 0, /* notify_change */ + &dump, /* dump */ + 0, /* xref */ + &create_accessor, /* create_accessor */ + 0, /* notify_change */ &reparse, /* reparse */ 0, /* execute */ }; diff --git a/src/action_class_meta.cc b/src/action_class_meta.cc index 3b5c375eb..7164593e7 100644 --- a/src/action_class_meta.cc +++ b/src/action_class_meta.cc @@ -51,20 +51,17 @@ typedef struct grib_action_meta { extern grib_action_class* grib_action_class_gen; static grib_action_class _grib_action_class_meta = { - &grib_action_class_gen, /* super */ - "action_class_meta", /* name */ - sizeof(grib_action_meta), /* size */ - 0, /* inited */ + &grib_action_class_gen, /* super */ + "action_class_meta", /* name */ + sizeof(grib_action_meta), /* size */ + 0, /* inited */ &init_class, /* init_class */ - 0, /* init */ + 0, /* init */ 0, /* destroy */ - - &dump, /* dump */ - 0, /* xref */ - - 0, /* create_accessor*/ - - 0, /* notify_change */ + &dump, /* dump */ + 0, /* xref */ + 0, /* create_accessor */ + 0, /* notify_change */ 0, /* reparse */ &execute, /* execute */ }; diff --git a/src/action_class_modify.cc b/src/action_class_modify.cc index e707d2d46..44583d87c 100644 --- a/src/action_class_modify.cc +++ b/src/action_class_modify.cc @@ -49,20 +49,17 @@ typedef struct grib_action_modify { static grib_action_class _grib_action_class_modify = { - 0, /* super */ - "action_class_modify", /* name */ - sizeof(grib_action_modify), /* size */ - 0, /* inited */ + 0, /* super */ + "action_class_modify", /* name */ + sizeof(grib_action_modify), /* size */ + 0, /* inited */ &init_class, /* init_class */ - 0, /* init */ + 0, /* init */ &destroy, /* destroy */ - - 0, /* dump */ - 0, /* xref */ - - &create_accessor, /* create_accessor*/ - - 0, /* notify_change */ + 0, /* dump */ + 0, /* xref */ + &create_accessor, /* create_accessor */ + 0, /* notify_change */ 0, /* reparse */ 0, /* execute */ }; diff --git a/src/action_class_noop.cc b/src/action_class_noop.cc index aa5196a46..2b7c1ab62 100644 --- a/src/action_class_noop.cc +++ b/src/action_class_noop.cc @@ -44,20 +44,17 @@ typedef struct grib_action_noop { static grib_action_class _grib_action_class_noop = { - 0, /* super */ - "action_class_noop", /* name */ - sizeof(grib_action_noop), /* size */ - 0, /* inited */ + 0, /* super */ + "action_class_noop", /* name */ + sizeof(grib_action_noop), /* size */ + 0, /* inited */ &init_class, /* init_class */ - 0, /* init */ + 0, /* init */ &destroy, /* destroy */ - - 0, /* dump */ - 0, /* xref */ - - 0, /* create_accessor*/ - - 0, /* notify_change */ + 0, /* dump */ + 0, /* xref */ + 0, /* create_accessor */ + 0, /* notify_change */ 0, /* reparse */ &execute, /* execute */ }; diff --git a/src/action_class_print.cc b/src/action_class_print.cc index 0286c636f..c96e6e22c 100644 --- a/src/action_class_print.cc +++ b/src/action_class_print.cc @@ -48,20 +48,17 @@ typedef struct grib_action_print { static grib_action_class _grib_action_class_print = { - 0, /* super */ - "action_class_print", /* name */ - sizeof(grib_action_print), /* size */ - 0, /* inited */ + 0, /* super */ + "action_class_print", /* name */ + sizeof(grib_action_print), /* size */ + 0, /* inited */ &init_class, /* init_class */ - 0, /* init */ + 0, /* init */ &destroy, /* destroy */ - - 0, /* dump */ - 0, /* xref */ - - 0, /* create_accessor*/ - - 0, /* notify_change */ + 0, /* dump */ + 0, /* xref */ + 0, /* create_accessor */ + 0, /* notify_change */ 0, /* reparse */ &execute, /* execute */ }; diff --git a/src/action_class_remove.cc b/src/action_class_remove.cc index 9764bd8c8..479811381 100644 --- a/src/action_class_remove.cc +++ b/src/action_class_remove.cc @@ -49,20 +49,17 @@ typedef struct grib_action_remove { static grib_action_class _grib_action_class_remove = { - 0, /* super */ - "action_class_remove", /* name */ - sizeof(grib_action_remove), /* size */ - 0, /* inited */ + 0, /* super */ + "action_class_remove", /* name */ + sizeof(grib_action_remove), /* size */ + 0, /* inited */ &init_class, /* init_class */ - 0, /* init */ + 0, /* init */ &destroy, /* destroy */ - - &dump, /* dump */ - 0, /* xref */ - - &create_accessor, /* create_accessor*/ - - 0, /* notify_change */ + &dump, /* dump */ + 0, /* xref */ + &create_accessor, /* create_accessor */ + 0, /* notify_change */ 0, /* reparse */ 0, /* execute */ }; diff --git a/src/action_class_rename.cc b/src/action_class_rename.cc index 1f3744b46..247478554 100644 --- a/src/action_class_rename.cc +++ b/src/action_class_rename.cc @@ -51,20 +51,17 @@ typedef struct grib_action_rename { static grib_action_class _grib_action_class_rename = { - 0, /* super */ - "action_class_rename", /* name */ - sizeof(grib_action_rename), /* size */ - 0, /* inited */ + 0, /* super */ + "action_class_rename", /* name */ + sizeof(grib_action_rename), /* size */ + 0, /* inited */ &init_class, /* init_class */ - 0, /* init */ + 0, /* init */ &destroy, /* destroy */ - - &dump, /* dump */ - 0, /* xref */ - - &create_accessor, /* create_accessor*/ - - 0, /* notify_change */ + &dump, /* dump */ + 0, /* xref */ + &create_accessor, /* create_accessor */ + 0, /* notify_change */ 0, /* reparse */ 0, /* execute */ }; @@ -127,12 +124,12 @@ static int create_accessor(grib_section* p, grib_action* act, grib_loader* h) static void dump(grib_action* act, FILE* f, int lvl) { - // grib_action_rename* a = (grib_action_rename*)act; - // int i = 0; - // for (i = 0; i < lvl; i++) - // grib_context_print(act->context, f, " "); + grib_action_rename* a = (grib_action_rename*)act; + int i = 0; + for (i = 0; i < lvl; i++) + grib_context_print(act->context, f, " "); - // grib_context_print(act->context, f, "rename %s as %s in %s\n", a->the_old, act->name, a->the_new); + grib_context_print(act->context, f, "rename %s as %s in %s\n", a->the_old, act->name, a->the_new); } static void destroy(grib_context* context, grib_action* act) diff --git a/src/action_class_section.cc b/src/action_class_section.cc index fb9fe690d..35d1e1bf5 100644 --- a/src/action_class_section.cc +++ b/src/action_class_section.cc @@ -44,20 +44,17 @@ typedef struct grib_action_section { static grib_action_class _grib_action_class_section = { - 0, /* super */ - "action_class_section", /* name */ - sizeof(grib_action_section), /* size */ - 0, /* inited */ + 0, /* super */ + "action_class_section", /* name */ + sizeof(grib_action_section), /* size */ + 0, /* inited */ &init_class, /* init_class */ - 0, /* init */ + 0, /* init */ 0, /* destroy */ - - 0, /* dump */ - 0, /* xref */ - - 0, /* create_accessor*/ - - ¬ify_change, /* notify_change */ + 0, /* dump */ + 0, /* xref */ + 0, /* create_accessor */ + ¬ify_change, /* notify_change */ 0, /* reparse */ 0, /* execute */ }; diff --git a/src/action_class_set.cc b/src/action_class_set.cc index fee2ca406..799bd6be1 100644 --- a/src/action_class_set.cc +++ b/src/action_class_set.cc @@ -49,20 +49,17 @@ typedef struct grib_action_set { static grib_action_class _grib_action_class_set = { - 0, /* super */ - "action_class_set", /* name */ - sizeof(grib_action_set), /* size */ - 0, /* inited */ + 0, /* super */ + "action_class_set", /* name */ + sizeof(grib_action_set), /* size */ + 0, /* inited */ &init_class, /* init_class */ - 0, /* init */ + 0, /* init */ &destroy, /* destroy */ - - &dump, /* dump */ - 0, /* xref */ - - 0, /* create_accessor*/ - - 0, /* notify_change */ + &dump, /* dump */ + 0, /* xref */ + 0, /* create_accessor */ + 0, /* notify_change */ 0, /* reparse */ &execute, /* execute */ }; diff --git a/src/action_class_set_darray.cc b/src/action_class_set_darray.cc index bbf36f1d6..33ab219f1 100644 --- a/src/action_class_set_darray.cc +++ b/src/action_class_set_darray.cc @@ -47,20 +47,17 @@ typedef struct grib_action_set_darray { static grib_action_class _grib_action_class_set_darray = { - 0, /* super */ - "action_class_set_darray", /* name */ - sizeof(grib_action_set_darray), /* size */ - 0, /* inited */ + 0, /* super */ + "action_class_set_darray", /* name */ + sizeof(grib_action_set_darray), /* size */ + 0, /* inited */ &init_class, /* init_class */ - 0, /* init */ + 0, /* init */ &destroy, /* destroy */ - - &dump, /* dump */ - 0, /* xref */ - - 0, /* create_accessor*/ - - 0, /* notify_change */ + &dump, /* dump */ + 0, /* xref */ + 0, /* create_accessor */ + 0, /* notify_change */ 0, /* reparse */ &execute, /* execute */ }; diff --git a/src/action_class_set_missing.cc b/src/action_class_set_missing.cc index 03bd4ffc3..0907c3760 100644 --- a/src/action_class_set_missing.cc +++ b/src/action_class_set_missing.cc @@ -45,20 +45,17 @@ typedef struct grib_action_set_missing { static grib_action_class _grib_action_class_set_missing = { - 0, /* super */ - "action_class_set_missing", /* name */ - sizeof(grib_action_set_missing), /* size */ - 0, /* inited */ + 0, /* super */ + "action_class_set_missing", /* name */ + sizeof(grib_action_set_missing), /* size */ + 0, /* inited */ &init_class, /* init_class */ - 0, /* init */ + 0, /* init */ &destroy, /* destroy */ - - &dump, /* dump */ - 0, /* xref */ - - 0, /* create_accessor*/ - - 0, /* notify_change */ + &dump, /* dump */ + 0, /* xref */ + 0, /* create_accessor */ + 0, /* notify_change */ 0, /* reparse */ &execute, /* execute */ }; diff --git a/src/action_class_set_sarray.cc b/src/action_class_set_sarray.cc index bc51c2475..50626a0a9 100644 --- a/src/action_class_set_sarray.cc +++ b/src/action_class_set_sarray.cc @@ -47,20 +47,17 @@ typedef struct grib_action_set_sarray { static grib_action_class _grib_action_class_set_sarray = { - 0, /* super */ - "action_class_set_sarray", /* name */ - sizeof(grib_action_set_sarray), /* size */ - 0, /* inited */ + 0, /* super */ + "action_class_set_sarray", /* name */ + sizeof(grib_action_set_sarray), /* size */ + 0, /* inited */ &init_class, /* init_class */ - 0, /* init */ + 0, /* init */ &destroy, /* destroy */ - - &dump, /* dump */ - 0, /* xref */ - - 0, /* create_accessor*/ - - 0, /* notify_change */ + &dump, /* dump */ + 0, /* xref */ + 0, /* create_accessor */ + 0, /* notify_change */ 0, /* reparse */ &execute, /* execute */ }; diff --git a/src/action_class_switch.cc b/src/action_class_switch.cc index fa58071ce..547149987 100644 --- a/src/action_class_switch.cc +++ b/src/action_class_switch.cc @@ -51,20 +51,17 @@ typedef struct grib_action_switch { extern grib_action_class* grib_action_class_section; static grib_action_class _grib_action_class_switch = { - &grib_action_class_section, /* super */ - "action_class_switch", /* name */ - sizeof(grib_action_switch), /* size */ - 0, /* inited */ + &grib_action_class_section, /* super */ + "action_class_switch", /* name */ + sizeof(grib_action_switch), /* size */ + 0, /* inited */ &init_class, /* init_class */ - 0, /* init */ + 0, /* init */ &destroy, /* destroy */ - - 0, /* dump */ - 0, /* xref */ - - 0, /* create_accessor*/ - - 0, /* notify_change */ + 0, /* dump */ + 0, /* xref */ + 0, /* create_accessor */ + 0, /* notify_change */ 0, /* reparse */ &execute, /* execute */ }; diff --git a/src/action_class_template.cc b/src/action_class_template.cc index 9b715fb0a..8858ab309 100644 --- a/src/action_class_template.cc +++ b/src/action_class_template.cc @@ -57,20 +57,17 @@ typedef struct grib_action_template { extern grib_action_class* grib_action_class_section; static grib_action_class _grib_action_class_template = { - &grib_action_class_section, /* super */ - "action_class_template", /* name */ - sizeof(grib_action_template), /* size */ - 0, /* inited */ + &grib_action_class_section, /* super */ + "action_class_template", /* name */ + sizeof(grib_action_template), /* size */ + 0, /* inited */ &init_class, /* init_class */ - 0, /* init */ + 0, /* init */ &destroy, /* destroy */ - - &dump, /* dump */ - 0, /* xref */ - - &create_accessor, /* create_accessor*/ - - 0, /* notify_change */ + &dump, /* dump */ + 0, /* xref */ + &create_accessor, /* create_accessor */ + 0, /* notify_change */ &reparse, /* reparse */ 0, /* execute */ }; diff --git a/src/action_class_transient_darray.cc b/src/action_class_transient_darray.cc index b70924251..697cc790c 100644 --- a/src/action_class_transient_darray.cc +++ b/src/action_class_transient_darray.cc @@ -52,20 +52,17 @@ typedef struct grib_action_transient_darray { extern grib_action_class* grib_action_class_gen; static grib_action_class _grib_action_class_transient_darray = { - &grib_action_class_gen, /* super */ - "action_class_transient_darray", /* name */ - sizeof(grib_action_transient_darray), /* size */ - 0, /* inited */ + &grib_action_class_gen, /* super */ + "action_class_transient_darray", /* name */ + sizeof(grib_action_transient_darray), /* size */ + 0, /* inited */ &init_class, /* init_class */ - 0, /* init */ + 0, /* init */ &destroy, /* destroy */ - - &dump, /* dump */ - 0, /* xref */ - - 0, /* create_accessor*/ - - 0, /* notify_change */ + &dump, /* dump */ + 0, /* xref */ + 0, /* create_accessor */ + 0, /* notify_change */ 0, /* reparse */ &execute, /* execute */ }; diff --git a/src/action_class_variable.cc b/src/action_class_variable.cc index 5b7e636ac..1ad93390c 100644 --- a/src/action_class_variable.cc +++ b/src/action_class_variable.cc @@ -48,20 +48,17 @@ typedef struct grib_action_variable { extern grib_action_class* grib_action_class_gen; static grib_action_class _grib_action_class_variable = { - &grib_action_class_gen, /* super */ - "action_class_variable", /* name */ - sizeof(grib_action_variable), /* size */ - 0, /* inited */ + &grib_action_class_gen, /* super */ + "action_class_variable", /* name */ + sizeof(grib_action_variable), /* size */ + 0, /* inited */ &init_class, /* init_class */ - 0, /* init */ + 0, /* init */ 0, /* destroy */ - - 0, /* dump */ - 0, /* xref */ - - 0, /* create_accessor*/ - - 0, /* notify_change */ + 0, /* dump */ + 0, /* xref */ + 0, /* create_accessor */ + 0, /* notify_change */ 0, /* reparse */ &execute, /* execute */ }; diff --git a/src/action_class_when.cc b/src/action_class_when.cc index 9627d2b7d..a2a770e7f 100644 --- a/src/action_class_when.cc +++ b/src/action_class_when.cc @@ -53,20 +53,17 @@ typedef struct grib_action_when { static grib_action_class _grib_action_class_when = { - 0, /* super */ - "action_class_when", /* name */ - sizeof(grib_action_when), /* size */ - 0, /* inited */ + 0, /* super */ + "action_class_when", /* name */ + sizeof(grib_action_when), /* size */ + 0, /* inited */ &init_class, /* init_class */ - 0, /* init */ + 0, /* init */ &destroy, /* destroy */ - - &dump, /* dump */ - 0, /* xref */ - - &create_accessor, /* create_accessor*/ - - ¬ify_change, /* notify_change */ + &dump, /* dump */ + 0, /* xref */ + &create_accessor, /* create_accessor */ + ¬ify_change, /* notify_change */ 0, /* reparse */ 0, /* execute */ }; diff --git a/src/action_class_write.cc b/src/action_class_write.cc index 190264e9c..01d5d8a54 100644 --- a/src/action_class_write.cc +++ b/src/action_class_write.cc @@ -47,20 +47,17 @@ typedef struct grib_action_write { static grib_action_class _grib_action_class_write = { - 0, /* super */ - "action_class_write", /* name */ - sizeof(grib_action_write), /* size */ - 0, /* inited */ + 0, /* super */ + "action_class_write", /* name */ + sizeof(grib_action_write), /* size */ + 0, /* inited */ &init_class, /* init_class */ - 0, /* init */ + 0, /* init */ &destroy, /* destroy */ - - 0, /* dump */ - 0, /* xref */ - - 0, /* create_accessor*/ - - 0, /* notify_change */ + 0, /* dump */ + 0, /* xref */ + 0, /* create_accessor */ + 0, /* notify_change */ 0, /* reparse */ &execute, /* execute */ }; diff --git a/src/codes_util.cc b/src/codes_util.cc index 9e7507c23..bb705b335 100644 --- a/src/codes_util.cc +++ b/src/codes_util.cc @@ -9,6 +9,7 @@ */ #include "grib_api_internal.h" +#include "eccodes.h" // Input lon must be in degrees not radians // Not to be used for latitudes as they can be -ve @@ -279,7 +280,7 @@ long convert_to_minutes(long step, long stepUnits) return (long)result; } -bool is_sorted_ascending(double arr[], size_t n) +bool is_sorted_ascending(const double arr[], size_t n) { for (size_t i = 0; i < n-1; i++) { if (arr[i] > arr[i+1]) { @@ -289,7 +290,7 @@ bool is_sorted_ascending(double arr[], size_t n) return true; } -bool is_sorted_descending(double arr[], size_t n) +bool is_sorted_descending(const double arr[], size_t n) { for (size_t i = 0; i < n-1; i++) { if (arr[i] < arr[i+1]) { @@ -404,3 +405,143 @@ int compute_scaled_value_and_scale_factor( } return err; } + +static const char* known_features[] = { + "AEC", + "MEMFS", + "JPG", + "PNG", + "ECCODES_THREADS", + "ECCODES_OMP_THREADS", + "NETCDF", + "FORTRAN", + "GEOGRAPHY" +}; + +#define NUMBER(x) (sizeof(x) / sizeof(x[0])) +int codes_is_feature_enabled(const char* feature) +{ + int aec_enabled = 0; // or CCSDS + int memfs_enabled = 0; + int jpg_enabled = 0; // JasPer or OpenJPEG or both + int png_enabled = 0; + int posix_threads_enabled = 0; + int omp_threads_enabled = 0; + int netcdf_enabled = 0; + int fortran_enabled = 0; + int geography_enabled = 0; + + int found_feature = 0; + const size_t num = NUMBER(known_features); + for (size_t i = 0; i < num; ++i) { + if (STR_EQUAL(feature, known_features[i])) { + found_feature = 1; + break; + } + } + if (!found_feature) { + const grib_context* c = grib_context_get_default(); + grib_context_log(c, GRIB_LOG_ERROR, "Unknown feature '%s'. Select one of:", feature); + for (size_t i = 0; i < num; ++i) { + grib_context_log(c, GRIB_LOG_ERROR, "\t%s", known_features[i]); + } + return 0; + } + +#if defined(HAVE_LIBAEC) || defined(HAVE_AEC) + aec_enabled = 1; +#endif +#if HAVE_JPEG + #if HAVE_LIBJASPER + jpg_enabled = 1; + #endif + #if HAVE_LIBOPENJPEG + jpg_enabled = 1; + #endif +#endif +#if HAVE_LIBPNG + png_enabled = 1; +#endif +#if defined(HAVE_MEMFS) + memfs_enabled = 1; +#endif +#if GRIB_PTHREADS + posix_threads_enabled = 1; +#endif +#if GRIB_OMP_THREADS + omp_threads_enabled = 1; +#endif +#if defined(HAVE_NETCDF) + netcdf_enabled = 1; +#endif +#if defined(HAVE_FORTRAN) + fortran_enabled = 1; +#endif +#if defined(HAVE_GEOGRAPHY) + geography_enabled = 1; +#endif + + if (STR_EQUAL(feature, "AEC") || STR_EQUAL(feature, "CCSDS")) { + return aec_enabled; + } + if (STR_EQUAL(feature, "JPG") || STR_EQUAL(feature, "JPEG")) { + return jpg_enabled; + } + if (STR_EQUAL(feature, "PNG")) { + return png_enabled; + } + if (STR_EQUAL(feature, "MEMFS")) { + return memfs_enabled; + } + if (STR_EQUAL(feature, "ECCODES_THREADS")) { + return posix_threads_enabled; + } + if (STR_EQUAL(feature, "ECCODES_OMP_THREADS")) { + return omp_threads_enabled; + } + if (STR_EQUAL(feature, "NETCDF")) { + return netcdf_enabled; + } + if (STR_EQUAL(feature, "FORTRAN")) { + return fortran_enabled; + } + if (STR_EQUAL(feature, "GEOGRAPHY")) { + return geography_enabled; + } + + return 0; +} + +int codes_get_features(char* result, size_t* length, int select) +{ + Assert(select == CODES_FEATURES_ALL || select == CODES_FEATURES_ENABLED || select == CODES_FEATURES_DISABLED); + + const size_t num = NUMBER(known_features); + result[0] = '\0'; + for (size_t i = 0; i < num; ++i) { + if (select == CODES_FEATURES_ALL) { + strcat(result, known_features[i]); + strcat(result, " "); + } + else if (select == CODES_FEATURES_ENABLED) { + if (codes_is_feature_enabled(known_features[i])) { + strcat(result, known_features[i]); + strcat(result, " "); + } + } + else if (select == CODES_FEATURES_DISABLED) { + if (!codes_is_feature_enabled(known_features[i])) { + strcat(result, known_features[i]); + strcat(result, " "); + } + } + } + + const size_t actual_length = strlen(result); + if (result[actual_length - 1] == ' ') + result[actual_length - 1] = '\0'; + + Assert(*length >= actual_length); + *length = actual_length; + return GRIB_SUCCESS; +} diff --git a/src/deprecated/grib_accessor_class_gds_not_present_bitmap.1.cc b/src/deprecated/grib_accessor_class_gds_not_present_bitmap.1.cc new file mode 100644 index 000000000..53066528c --- /dev/null +++ b/src/deprecated/grib_accessor_class_gds_not_present_bitmap.1.cc @@ -0,0 +1,117 @@ +/* + * (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. + */ + +#include "grib_accessor_class_gds_not_present_bitmap.h" + +grib_accessor_class_gds_not_present_bitmap_t _grib_accessor_class_gds_not_present_bitmap{ "gds_not_present_bitmap" }; +grib_accessor_class* grib_accessor_class_gds_not_present_bitmap = &_grib_accessor_class_gds_not_present_bitmap; + + +void grib_accessor_class_gds_not_present_bitmap_t::init(grib_accessor* a, const long v, grib_arguments* args) +{ + Assert(!"grib_accessor_class_gds_not_present_bitmap_t::init should not be called"); + // grib_accessor_class_gen_t::init(a, v, args); + // int n = 0; + // grib_accessor_gds_not_present_bitmap_t* self = (grib_accessor_gds_not_present_bitmap_t*)a; + // grib_handle* hand = grib_handle_of_accessor(a); + + // self->missing_value = grib_arguments_get_name(hand, args, n++); + // self->number_of_values = grib_arguments_get_name(hand, args, n++); + // self->number_of_points = grib_arguments_get_name(hand, args, n++); + // self->latitude_of_first_point = grib_arguments_get_name(hand, args, n++); + // self->ni = grib_arguments_get_name(hand, args, n++); + // a->length = 0; +} + +int grib_accessor_class_gds_not_present_bitmap_t::value_count(grib_accessor* a, long* number_of_points) +{ + return GRIB_NOT_IMPLEMENTED; + // grib_accessor_gds_not_present_bitmap_t* self = (grib_accessor_gds_not_present_bitmap_t*)a; + // *number_of_points = 0; + // return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_points, number_of_points); +} + +int grib_accessor_class_gds_not_present_bitmap_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ + return GRIB_NOT_IMPLEMENTED; + + // grib_accessor_gds_not_present_bitmap_t* self = (grib_accessor_gds_not_present_bitmap_t*)a; + // grib_handle* hand = grib_handle_of_accessor(a); + + // long number_of_points = 0, number_of_values = 0, ni = 0; + // long latitude_of_first_point = 0; + // size_t i = 0; + // size_t n_vals = 0; + // long nn = 0; + // long missing_value; + + // double* coded_vals = NULL; + // int err = a->value_count(&nn); + // n_vals = nn; + // if (err) + // return err; + + // if ((err = grib_get_long(hand, self->number_of_points, &number_of_points)) != GRIB_SUCCESS) + // return err; + + // if ((err = grib_get_long(hand, self->number_of_values, &number_of_values)) != GRIB_SUCCESS) + // return err; + + // if ((err = grib_get_long(hand, self->latitude_of_first_point, &latitude_of_first_point)) != GRIB_SUCCESS) + // return err; + + // if ((err = grib_get_long(hand, self->missing_value, &missing_value)) != GRIB_SUCCESS) + // return err; + + // if ((err = grib_get_long(hand, self->ni, &ni)) != GRIB_SUCCESS) + // return err; + + // if (*len < number_of_points) { + // *len = n_vals; + // return GRIB_ARRAY_TOO_SMALL; + // } + + // if (number_of_values > 0) { + // coded_vals = (double*)grib_context_malloc(a->context, number_of_values * sizeof(double)); + + // if (coded_vals == NULL) + // return GRIB_OUT_OF_MEMORY; + // } + + // if (latitude_of_first_point == 0) { + // for (i = 0; i < number_of_values; i++) + // val[i] = 1; + // for (i = number_of_values; i < number_of_points; i++) + // val[i] = 0; + // } + // else { + // for (i = 0; i < ni - 1; i++) + // val[i] = 0; + // for (i = ni - 1; i < number_of_points; i++) + // val[i] = 1; + // } + + // *len = number_of_points; + + // grib_context_free(a->context, coded_vals); + // return err; +} + +int grib_accessor_class_gds_not_present_bitmap_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ + // See deprecated/grib_accessor_class_gds_not_present_bitmap.cc for + // a possible implementation + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_gds_not_present_bitmap_t::get_native_type(grib_accessor* a) +{ + return GRIB_TYPE_DOUBLE; +} diff --git a/src/accessor/grib_accessor_class_gds_not_present_bitmap.h b/src/deprecated/grib_accessor_class_gds_not_present_bitmap.h similarity index 100% rename from src/accessor/grib_accessor_class_gds_not_present_bitmap.h rename to src/deprecated/grib_accessor_class_gds_not_present_bitmap.h diff --git a/src/eccodes.cc b/src/eccodes.cc index 779690790..2220f2eeb 100644 --- a/src/eccodes.cc +++ b/src/eccodes.cc @@ -28,6 +28,11 @@ const char* codes_get_git_sha1() { return grib_get_git_sha1(); } +const char* codes_get_git_branch() +{ + return grib_get_git_branch(); +} + const char* codes_get_package_name(void) { return grib_get_package_name(); @@ -475,7 +480,7 @@ void codes_gribex_mode_on(grib_context* c) { grib_gribex_mode_on(c); } -int codes_get_gribex_mode(grib_context* c) +int codes_get_gribex_mode(const grib_context* c) { return grib_get_gribex_mode(c); } diff --git a/src/eccodes.h b/src/eccodes.h index 0c8f7193c..c21d03545 100644 --- a/src/eccodes.h +++ b/src/eccodes.h @@ -809,12 +809,12 @@ int codes_get_float_elements(const codes_handle* h, const char* key, const int* * * @param h : the handle to get the data from * @param key : the key to be searched - * @param mesg : the address of a string where the data will be retrieved + * @param value : the address of a string where the data will be retrieved * @param length : the address of a size_t that contains allocated length of the string on input, * and that contains the actual length of the string on output * @return 0 if OK, integer value on error */ -int codes_get_string(const codes_handle* h, const char* key, char* mesg, size_t* length); +int codes_get_string(const codes_handle* h, const char* key, char* value, size_t* length); /** * Get string array values from a key. If several keys of the same name are present, the last one is returned @@ -910,12 +910,12 @@ int codes_set_double(codes_handle* h, const char* key, double val); * * @param h : the handle to set the data to * @param key : the key to be searched - * @param mesg : the address of a string where the data will be read + * @param value : the address of a string where the data will be read * @param length : the address of a size_t that contains the length of the string on input, * and that contains the actual packed length of the string on output * @return 0 if OK, integer value on error */ -int codes_set_string(codes_handle* h, const char* key, const char* mesg, size_t* length); +int codes_set_string(codes_handle* h, const char* key, const char* value, size_t* length); /** * Set a bytes array from a key. If several keys of the same name are present, the last one is set @@ -1143,7 +1143,7 @@ void codes_gribex_mode_on(codes_context* c); * * @param c : the context */ -int codes_get_gribex_mode(codes_context* c); +int codes_get_gribex_mode(const codes_context* c); /** * Set the GRIBEX mode off. @@ -1264,6 +1264,7 @@ long codes_get_api_version(void); */ const char* codes_get_git_sha1(void); +const char* codes_get_git_branch(void); const char* codes_get_build_date(void); /** @@ -1399,6 +1400,14 @@ int codes_get_product_kind(const codes_handle* h, ProductKind* product_kind); int codes_check_message_header(const void* bytes, size_t length, ProductKind product); int codes_check_message_footer(const void* bytes, size_t length, ProductKind product); +/* Features */ +#define CODES_FEATURES_ALL 0 +#define CODES_FEATURES_ENABLED 1 +#define CODES_FEATURES_DISABLED 2 +int codes_is_feature_enabled(const char* feature); +/* result is a space-separated list of features and + must be allocated by the caller (its length must be large enough) */ +int codes_get_features(char* result, size_t* length, int select); /* --------------------------------------- */ #define CODES_UTIL_GRID_SPEC_REGULAR_LL GRIB_UTIL_GRID_SPEC_REGULAR_LL diff --git a/src/eccodes_prototypes.h b/src/eccodes_prototypes.h index e0582076d..d65c8a908 100644 --- a/src/eccodes_prototypes.h +++ b/src/eccodes_prototypes.h @@ -402,8 +402,8 @@ void codes_dump_bufr_flat(grib_accessors_list* al, grib_handle* h, FILE* f, cons size_t grib_context_read(const grib_context* c, void* ptr, size_t size, void* stream); off_t grib_context_tell(const grib_context* c, void* stream); int grib_context_seek(const grib_context* c, off_t offset, int whence, void* stream); -int grib_context_eof(const grib_context* c, void* stream); -size_t grib_context_write(const grib_context* c, const void* ptr, size_t size, void* stream); +// int grib_context_eof(const grib_context* c, void* stream); +// size_t grib_context_write(const grib_context* c, const void* ptr, size_t size, void* stream); void grib_context_set_print_proc(grib_context* c, grib_print_proc p); void grib_context_set_debug(grib_context* c, int mode); void grib_context_set_logging_proc(grib_context* c, grib_log_proc p); @@ -450,7 +450,7 @@ bufr_descriptors_array* grib_context_expanded_descriptors_list_get(grib_context* void grib_context_expanded_descriptors_list_push(grib_context* c, const char* key, bufr_descriptors_array* expanded, bufr_descriptors_array* unexpanded); void codes_set_codes_assertion_failed_proc(codes_assertion_failed_proc proc); void codes_assertion_failed(const char* message, const char* file, int line); -int grib_get_gribex_mode(grib_context* c); +int grib_get_gribex_mode(const grib_context* c); void grib_gribex_mode_on(grib_context* c); void grib_gribex_mode_off(grib_context* c); void grib_gts_header_on(grib_context* c); @@ -466,7 +466,6 @@ long grib_julian_to_date(long jdate); long grib_date_to_julian(long ddate); /* grib_fieldset.cc */ -int grib_fieldset_new_column(grib_fieldset* set, int id, char* key, int type); grib_fieldset* grib_fieldset_new_from_files(grib_context* c, const char* filenames[], int nfiles, const char** keys, int nkeys, const char* where_string, const char* order_by_string, int* err); int grib_fieldset_apply_where(grib_fieldset* set, const char* where_string); int grib_fieldset_apply_order_by(grib_fieldset* set, const char* order_by_string); @@ -855,9 +854,12 @@ int codes_flush_sync_close_file(FILE* f); int is_date_valid(long year, long month, long day, long hour, long minute, double second); int is_time_valid(long number); // number is HHMM long convert_to_minutes(long step, long stepUnits); -bool is_sorted_ascending(double arr[], size_t n); -bool is_sorted_descending(double arr[], size_t n); +bool is_sorted_ascending(const double arr[], size_t n); +bool is_sorted_descending(const double arr[], size_t n); int compute_scaled_value_and_scale_factor(double input, int64_t scaled_value_max, int64_t scale_factor_max, int64_t* ret_value, int64_t* ret_factor); +int codes_is_feature_enabled(const char* feature); +int codes_get_features(char* result, size_t* length, int select); + /* grib_util.cc */ grib_handle* grib_util_sections_copy(grib_handle* hfrom, grib_handle* hto, int what, int* err); @@ -942,6 +944,7 @@ int grib_optimize_decimal_factor(grib_accessor* a, const char* reference_value, /* grib_api_version.cc */ const char* grib_get_git_sha1(void); +const char* grib_get_git_branch(void); const char* codes_get_build_date(void); /* grib_bits_any_endian.cc */ diff --git a/src/expression.class b/src/expression.class index 64c9a2e70..0db380e7c 100644 --- a/src/expression.class +++ b/src/expression.class @@ -2,7 +2,7 @@ typedef const char* string; /* to keep make_class.pl happy */ static void init(grib_expression* e); static void destroy(grib_context*,grib_expression* e); -static void print(grib_context*,grib_expression*,grib_handle*); +static void print(grib_context*, grib_expression*, grib_handle*, FILE*); static void add_dependency(grib_expression* e, grib_accessor* observer); static string get_name(grib_expression* e); static int native_type(grib_expression*,grib_handle*); @@ -18,12 +18,12 @@ typedef struct grib_expression_NAME{ extern grib_expression_class* SUPER; static grib_expression_class _grib_expression_class_NAME = { - &SUPER, /* super */ - "NAME", /* name */ - sizeof(grib_expression_NAME),/* size of instance */ + &SUPER, /* super */ + "NAME", /* name */ + sizeof(grib_expression_NAME),/* size of instance */ 0, /* inited */ - &init, /* constructor */ - &destroy, /* destructor */ + &init, /* constructor */ + &destroy, /* destructor */ &print, &add_dependency, &native_type, diff --git a/src/grib_accessor_class.cc b/src/grib_accessor_class.cc index ff30662dc..67ce6b92f 100644 --- a/src/grib_accessor_class.cc +++ b/src/grib_accessor_class.cc @@ -74,7 +74,7 @@ static struct table_entry table[] = { grib_section* grib_create_root_section(const grib_context* context, grib_handle* h) { - char* fpath = 0; + const char* fpath = 0; grib_section* s = (grib_section*)grib_context_malloc_clear(context, sizeof(grib_section)); GRIB_MUTEX_INIT_ONCE(&once, &init_mutex); diff --git a/src/grib_accessor_class.h b/src/grib_accessor_class.h index edf01f1a2..aafc22d97 100644 --- a/src/grib_accessor_class.h +++ b/src/grib_accessor_class.h @@ -101,7 +101,6 @@ extern grib_accessor* grib_accessor_g2lon; extern grib_accessor* grib_accessor_g2step_range; extern grib_accessor* grib_accessor_gaussian_grid_name; extern grib_accessor* grib_accessor_gds_is_present; -extern grib_accessor* grib_accessor_gds_not_present_bitmap; extern grib_accessor* grib_accessor_gen; extern grib_accessor* grib_accessor_getenv; extern grib_accessor* grib_accessor_global_gaussian; diff --git a/src/grib_accessor_classes_hash.cc b/src/grib_accessor_classes_hash.cc index ec9a693c1..a97859d89 100644 --- a/src/grib_accessor_classes_hash.cc +++ b/src/grib_accessor_classes_hash.cc @@ -37,12 +37,12 @@ #line 6 "accessor_class_list.gperf" struct accessor_class_hash { const char *name; grib_accessor **cclass;}; -#define TOTAL_KEYWORDS 206 +#define TOTAL_KEYWORDS 205 #define MIN_WORD_LENGTH 1 #define MAX_WORD_LENGTH 44 #define MIN_HASH_VALUE 1 -#define MAX_HASH_VALUE 545 -/* maximum key range = 545, duplicates = 0 */ +#define MAX_HASH_VALUE 665 +/* maximum key range = 665, duplicates = 0 */ #ifdef __GNUC__ @@ -56,32 +56,32 @@ grib_accessor_classes_get_id (const char *str, size_t len) { static const unsigned short asso_values[] = { - 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 546, 0, 546, 546, 546, 546, 546, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 546, 1, 145, - 23, 6, 2, 546, 4, 546, 1, 546, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 546, 546, 546, 546, 0, 546, 0, 69, 84, - 0, 0, 200, 24, 219, 1, 8, 6, 87, 102, - 13, 51, 6, 546, 118, 1, 40, 59, 171, 0, - 28, 11, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, - 546, 546, 546, 546, 546, 546 + 666, 666, 666, 666, 666, 666, 666, 666, 666, 666, + 666, 666, 666, 666, 666, 666, 666, 666, 666, 666, + 666, 666, 666, 666, 666, 666, 666, 666, 666, 666, + 666, 666, 0, 666, 666, 666, 666, 666, 666, 666, + 666, 666, 666, 666, 666, 666, 666, 666, 1, 189, + 23, 11, 4, 666, 10, 666, 0, 666, 666, 666, + 666, 666, 666, 666, 666, 666, 666, 666, 666, 666, + 666, 666, 666, 666, 666, 666, 666, 666, 666, 666, + 666, 666, 666, 666, 666, 666, 666, 666, 666, 666, + 666, 666, 666, 666, 666, 0, 666, 0, 69, 85, + 0, 0, 175, 24, 230, 1, 0, 4, 74, 223, + 13, 50, 6, 666, 129, 1, 40, 71, 191, 0, + 52, 5, 666, 666, 666, 666, 666, 666, 666, 666, + 666, 666, 666, 666, 666, 666, 666, 666, 666, 666, + 666, 666, 666, 666, 666, 666, 666, 666, 666, 666, + 666, 666, 666, 666, 666, 666, 666, 666, 666, 666, + 666, 666, 666, 666, 666, 666, 666, 666, 666, 666, + 666, 666, 666, 666, 666, 666, 666, 666, 666, 666, + 666, 666, 666, 666, 666, 666, 666, 666, 666, 666, + 666, 666, 666, 666, 666, 666, 666, 666, 666, 666, + 666, 666, 666, 666, 666, 666, 666, 666, 666, 666, + 666, 666, 666, 666, 666, 666, 666, 666, 666, 666, + 666, 666, 666, 666, 666, 666, 666, 666, 666, 666, + 666, 666, 666, 666, 666, 666, 666, 666, 666, 666, + 666, 666, 666, 666, 666, 666, 666, 666, 666, 666, + 666, 666, 666, 666, 666, 666 }; unsigned int hval = len; @@ -118,30 +118,30 @@ static const struct accessor_class_hash classes[] = #line 9 "accessor_class_list.gperf" {" "}, {""}, {""}, {""}, {""}, -#line 179 "accessor_class_list.gperf" +#line 178 "accessor_class_list.gperf" {"size", &grib_accessor_size}, #line 12 "accessor_class_list.gperf" {"ascii", &grib_accessor_ascii}, -#line 176 "accessor_class_list.gperf" +#line 175 "accessor_class_list.gperf" {"signed", &grib_accessor_signed}, -#line 156 "accessor_class_list.gperf" +#line 155 "accessor_class_list.gperf" {"pad", &grib_accessor_pad}, -#line 182 "accessor_class_list.gperf" +#line 181 "accessor_class_list.gperf" {"spd", &grib_accessor_spd}, - {""}, {""}, {""}, -#line 177 "accessor_class_list.gperf" +#line 75 "accessor_class_list.gperf" + {"dirty", &grib_accessor_dirty}, + {""}, {""}, +#line 176 "accessor_class_list.gperf" {"signed_bits", &grib_accessor_signed_bits}, {""}, #line 66 "accessor_class_list.gperf" {"data_raw_packing", &grib_accessor_data_raw_packing}, -#line 75 "accessor_class_list.gperf" - {"dirty", &grib_accessor_dirty}, - {""}, {""}, + {""}, {""}, {""}, #line 72 "accessor_class_list.gperf" {"data_simple_packing", &grib_accessor_data_simple_packing}, #line 68 "accessor_class_list.gperf" {"data_secondary_bitmap", &grib_accessor_data_secondary_bitmap}, -#line 170 "accessor_class_list.gperf" +#line 169 "accessor_class_list.gperf" {"section", &grib_accessor_section}, #line 43 "accessor_class_list.gperf" {"data_apply_bitmap", &grib_accessor_data_apply_bitmap}, @@ -149,40 +149,40 @@ static const struct accessor_class_hash classes[] = #line 74 "accessor_class_list.gperf" {"dictionary", &grib_accessor_dictionary}, {""}, -#line 112 "accessor_class_list.gperf" +#line 111 "accessor_class_list.gperf" {"gen", &grib_accessor_gen}, #line 64 "accessor_class_list.gperf" {"data_jpeg2000_packing", &grib_accessor_data_jpeg2000_packing}, #line 65 "accessor_class_list.gperf" {"data_png_packing", &grib_accessor_data_png_packing}, -#line 172 "accessor_class_list.gperf" +#line 171 "accessor_class_list.gperf" {"section_padding", &grib_accessor_section_padding}, -#line 173 "accessor_class_list.gperf" +#line 172 "accessor_class_list.gperf" {"section_pointer", &grib_accessor_section_pointer}, #line 44 "accessor_class_list.gperf" {"data_apply_boustrophedonic", &grib_accessor_data_apply_boustrophedonic}, {""}, {""}, {""}, {""}, {""}, -#line 157 "accessor_class_list.gperf" +#line 156 "accessor_class_list.gperf" {"padding", &grib_accessor_padding}, #line 45 "accessor_class_list.gperf" {"data_apply_boustrophedonic_bitmap", &grib_accessor_data_apply_boustrophedonic_bitmap}, #line 110 "accessor_class_list.gperf" {"gds_is_present", &grib_accessor_gds_is_present}, -#line 169 "accessor_class_list.gperf" +#line 168 "accessor_class_list.gperf" {"second_order_bits_per_value", &grib_accessor_second_order_bits_per_value}, -#line 171 "accessor_class_list.gperf" +#line 170 "accessor_class_list.gperf" {"section_length", &grib_accessor_section_length}, -#line 113 "accessor_class_list.gperf" +#line 112 "accessor_class_list.gperf" {"getenv", &grib_accessor_getenv}, #line 57 "accessor_class_list.gperf" {"data_g22order_packing", &grib_accessor_data_g22order_packing}, -#line 191 "accessor_class_list.gperf" +#line 190 "accessor_class_list.gperf" {"time", &grib_accessor_time}, {""}, #line 61 "accessor_class_list.gperf" {"data_g2shsimple_packing", &grib_accessor_data_g2shsimple_packing}, {""}, -#line 155 "accessor_class_list.gperf" +#line 154 "accessor_class_list.gperf" {"packing_type", &grib_accessor_packing_type}, #line 62 "accessor_class_list.gperf" {"data_g2simple_packing", &grib_accessor_data_g2simple_packing}, @@ -196,173 +196,204 @@ static const struct accessor_class_hash classes[] = {"g2end_step", &grib_accessor_g2end_step}, #line 98 "accessor_class_list.gperf" {"g2_eps", &grib_accessor_g2_eps}, -#line 142 "accessor_class_list.gperf" +#line 141 "accessor_class_list.gperf" {"nearest", &grib_accessor_nearest}, -#line 80 "accessor_class_list.gperf" - {"expanded_descriptors", &grib_accessor_expanded_descriptors}, -#line 158 "accessor_class_list.gperf" +#line 157 "accessor_class_list.gperf" {"padto", &grib_accessor_padto}, -#line 189 "accessor_class_list.gperf" - {"sum", &grib_accessor_sum}, - {""}, + {""}, {""}, {""}, #line 107 "accessor_class_list.gperf" {"g2lon", &grib_accessor_g2lon}, -#line 203 "accessor_class_list.gperf" - {"uint8", &grib_accessor_uint8}, - {""}, -#line 188 "accessor_class_list.gperf" + {""}, {""}, +#line 187 "accessor_class_list.gperf" {"step_in_units", &grib_accessor_step_in_units}, #line 63 "accessor_class_list.gperf" {"data_g2simple_packing_with_preprocessing", &grib_accessor_data_g2simple_packing_with_preprocessing}, -#line 201 "accessor_class_list.gperf" - {"uint64", &grib_accessor_uint64}, #line 47 "accessor_class_list.gperf" {"data_complex_packing", &grib_accessor_data_complex_packing}, -#line 199 "accessor_class_list.gperf" - {"uint32", &grib_accessor_uint32}, + {""}, {""}, #line 13 "accessor_class_list.gperf" {"bit", &grib_accessor_bit}, #line 15 "accessor_class_list.gperf" {"bits", &grib_accessor_bits}, -#line 48 "accessor_class_list.gperf" - {"data_dummy_field", &grib_accessor_data_dummy_field}, +#line 188 "accessor_class_list.gperf" + {"sum", &grib_accessor_sum}, #line 14 "accessor_class_list.gperf" {"bitmap", &grib_accessor_bitmap}, -#line 124 "accessor_class_list.gperf" - {"julian_day", &grib_accessor_julian_day}, -#line 123 "accessor_class_list.gperf" - {"julian_date", &grib_accessor_julian_date}, -#line 143 "accessor_class_list.gperf" +#line 202 "accessor_class_list.gperf" + {"uint8", &grib_accessor_uint8}, +#line 142 "accessor_class_list.gperf" {"non_alpha", &grib_accessor_non_alpha}, - {""}, {""}, -#line 67 "accessor_class_list.gperf" - {"data_run_length_packing", &grib_accessor_data_run_length_packing}, + {""}, +#line 29 "accessor_class_list.gperf" + {"bytes", &grib_accessor_bytes}, +#line 123 "accessor_class_list.gperf" + {"julian_day", &grib_accessor_julian_day}, +#line 122 "accessor_class_list.gperf" + {"julian_date", &grib_accessor_julian_date}, #line 108 "accessor_class_list.gperf" {"g2step_range", &grib_accessor_g2step_range}, #line 16 "accessor_class_list.gperf" {"bits_per_value", &grib_accessor_bits_per_value}, +#line 80 "accessor_class_list.gperf" + {"expanded_descriptors", &grib_accessor_expanded_descriptors}, {""}, -#line 29 "accessor_class_list.gperf" - {"bytes", &grib_accessor_bytes}, - {""}, {""}, {""}, -#line 167 "accessor_class_list.gperf" +#line 48 "accessor_class_list.gperf" + {"data_dummy_field", &grib_accessor_data_dummy_field}, +#line 200 "accessor_class_list.gperf" + {"uint64", &grib_accessor_uint64}, +#line 198 "accessor_class_list.gperf" + {"uint32", &grib_accessor_uint32}, + {""}, +#line 166 "accessor_class_list.gperf" {"scale", &grib_accessor_scale}, - {""}, -#line 185 "accessor_class_list.gperf" +#line 184 "accessor_class_list.gperf" {"statistics", &grib_accessor_statistics}, #line 102 "accessor_class_list.gperf" {"g2date", &grib_accessor_g2date}, -#line 145 "accessor_class_list.gperf" - {"number_of_points", &grib_accessor_number_of_points}, +#line 67 "accessor_class_list.gperf" + {"data_run_length_packing", &grib_accessor_data_run_length_packing}, #line 100 "accessor_class_list.gperf" {"g2bitmap", &grib_accessor_g2bitmap}, - {""}, #line 60 "accessor_class_list.gperf" {"data_g2secondary_bitmap", &grib_accessor_data_g2secondary_bitmap}, #line 58 "accessor_class_list.gperf" {"data_g2bifourier_packing", &grib_accessor_data_g2bifourier_packing}, -#line 111 "accessor_class_list.gperf" - {"gds_not_present_bitmap", &grib_accessor_gds_not_present_bitmap}, -#line 122 "accessor_class_list.gperf" + {""}, +#line 121 "accessor_class_list.gperf" {"iterator", &grib_accessor_iterator}, -#line 186 "accessor_class_list.gperf" +#line 177 "accessor_class_list.gperf" + {"simple_packing_error", &grib_accessor_simple_packing_error}, +#line 185 "accessor_class_list.gperf" {"statistics_spectral", &grib_accessor_statistics_spectral}, + {""}, #line 46 "accessor_class_list.gperf" {"data_ccsds_packing", &grib_accessor_data_ccsds_packing}, -#line 146 "accessor_class_list.gperf" - {"number_of_points_gaussian", &grib_accessor_number_of_points_gaussian}, -#line 206 "accessor_class_list.gperf" - {"unsigned", &grib_accessor_unsigned}, -#line 138 "accessor_class_list.gperf" - {"md5", &grib_accessor_md5}, {""}, {""}, +#line 144 "accessor_class_list.gperf" + {"number_of_points", &grib_accessor_number_of_points}, #line 96 "accessor_class_list.gperf" {"g2_aerosol", &grib_accessor_g2_aerosol}, -#line 139 "accessor_class_list.gperf" - {"message", &grib_accessor_message}, -#line 207 "accessor_class_list.gperf" - {"unsigned_bits", &grib_accessor_unsigned_bits}, -#line 174 "accessor_class_list.gperf" + {""}, {""}, {""}, {""}, +#line 173 "accessor_class_list.gperf" {"select_step_template", &grib_accessor_select_step_template}, -#line 136 "accessor_class_list.gperf" - {"mars_param", &grib_accessor_mars_param}, -#line 204 "accessor_class_list.gperf" - {"unexpanded_descriptors", &grib_accessor_unexpanded_descriptors}, -#line 193 "accessor_class_list.gperf" +#line 192 "accessor_class_list.gperf" {"to_integer", &grib_accessor_to_integer}, -#line 178 "accessor_class_list.gperf" - {"simple_packing_error", &grib_accessor_simple_packing_error}, - {""}, {""}, {""}, -#line 187 "accessor_class_list.gperf" - {"step_human_readable", &grib_accessor_step_human_readable}, -#line 140 "accessor_class_list.gperf" - {"message_copy", &grib_accessor_message_copy}, -#line 163 "accessor_class_list.gperf" - {"raw", &grib_accessor_raw}, - {""}, {""}, -#line 202 "accessor_class_list.gperf" - {"uint64_little_endian", &grib_accessor_uint64_little_endian}, - {""}, -#line 200 "accessor_class_list.gperf" - {"uint32_little_endian", &grib_accessor_uint32_little_endian}, -#line 114 "accessor_class_list.gperf" +#line 113 "accessor_class_list.gperf" {"global_gaussian", &grib_accessor_global_gaussian}, +#line 145 "accessor_class_list.gperf" + {"number_of_points_gaussian", &grib_accessor_number_of_points_gaussian}, +#line 205 "accessor_class_list.gperf" + {"unsigned", &grib_accessor_unsigned}, {""}, {""}, -#line 76 "accessor_class_list.gperf" - {"divdouble", &grib_accessor_divdouble}, - {""}, -#line 175 "accessor_class_list.gperf" +#line 174 "accessor_class_list.gperf" {"sexagesimal2decimal", &grib_accessor_sexagesimal2decimal}, -#line 99 "accessor_class_list.gperf" - {"g2_mars_labeling", &grib_accessor_g2_mars_labeling}, + {""}, #line 78 "accessor_class_list.gperf" {"element", &grib_accessor_element}, -#line 160 "accessor_class_list.gperf" - {"padtomultiple", &grib_accessor_padtomultiple}, -#line 127 "accessor_class_list.gperf" +#line 206 "accessor_class_list.gperf" + {"unsigned_bits", &grib_accessor_unsigned_bits}, +#line 126 "accessor_class_list.gperf" {"latitudes", &grib_accessor_latitudes}, -#line 164 "accessor_class_list.gperf" - {"rdbtime_guess_date", &grib_accessor_rdbtime_guess_date}, - {""}, {""}, {""}, -#line 194 "accessor_class_list.gperf" - {"to_string", &grib_accessor_to_string}, -#line 132 "accessor_class_list.gperf" + {""}, +#line 203 "accessor_class_list.gperf" + {"unexpanded_descriptors", &grib_accessor_unexpanded_descriptors}, + {""}, {""}, +#line 131 "accessor_class_list.gperf" {"long", &grib_accessor_long}, -#line 19 "accessor_class_list.gperf" - {"bufr_data_array", &grib_accessor_bufr_data_array}, +#line 76 "accessor_class_list.gperf" + {"divdouble", &grib_accessor_divdouble}, #line 77 "accessor_class_list.gperf" {"double", &grib_accessor_double}, -#line 20 "accessor_class_list.gperf" - {"bufr_data_element", &grib_accessor_bufr_data_element}, +#line 186 "accessor_class_list.gperf" + {"step_human_readable", &grib_accessor_step_human_readable}, +#line 162 "accessor_class_list.gperf" + {"raw", &grib_accessor_raw}, +#line 99 "accessor_class_list.gperf" + {"g2_mars_labeling", &grib_accessor_g2_mars_labeling}, + {""}, {""}, {""}, {""}, {""}, {""}, +#line 193 "accessor_class_list.gperf" + {"to_string", &grib_accessor_to_string}, + {""}, +#line 201 "accessor_class_list.gperf" + {"uint64_little_endian", &grib_accessor_uint64_little_endian}, +#line 199 "accessor_class_list.gperf" + {"uint32_little_endian", &grib_accessor_uint32_little_endian}, + {""}, #line 105 "accessor_class_list.gperf" {"g2latlon", &grib_accessor_g2latlon}, - {""}, {""}, -#line 26 "accessor_class_list.gperf" - {"bufr_simple_thinning", &grib_accessor_bufr_simple_thinning}, - {""}, -#line 137 "accessor_class_list.gperf" - {"mars_step", &grib_accessor_mars_step}, - {""}, -#line 115 "accessor_class_list.gperf" - {"group", &grib_accessor_group}, - {""}, -#line 28 "accessor_class_list.gperf" - {"bufrdc_expanded_descriptors", &grib_accessor_bufrdc_expanded_descriptors}, -#line 161 "accessor_class_list.gperf" - {"position", &grib_accessor_position}, - {""}, {""}, {""}, +#line 159 "accessor_class_list.gperf" + {"padtomultiple", &grib_accessor_padtomultiple}, #line 17 "accessor_class_list.gperf" {"blob", &grib_accessor_blob}, +#line 163 "accessor_class_list.gperf" + {"rdbtime_guess_date", &grib_accessor_rdbtime_guess_date}, + {""}, {""}, {""}, +#line 118 "accessor_class_list.gperf" + {"ibmfloat", &grib_accessor_ibmfloat}, +#line 125 "accessor_class_list.gperf" + {"label", &grib_accessor_label}, +#line 160 "accessor_class_list.gperf" + {"position", &grib_accessor_position}, +#line 19 "accessor_class_list.gperf" + {"bufr_data_array", &grib_accessor_bufr_data_array}, + {""}, +#line 20 "accessor_class_list.gperf" + {"bufr_data_element", &grib_accessor_bufr_data_element}, + {""}, {""}, {""}, +#line 26 "accessor_class_list.gperf" + {"bufr_simple_thinning", &grib_accessor_bufr_simple_thinning}, + {""}, {""}, +#line 114 "accessor_class_list.gperf" + {"group", &grib_accessor_group}, + {""}, {""}, +#line 28 "accessor_class_list.gperf" + {"bufrdc_expanded_descriptors", &grib_accessor_bufrdc_expanded_descriptors}, + {""}, {""}, {""}, {""}, #line 109 "accessor_class_list.gperf" {"gaussian_grid_name", &grib_accessor_gaussian_grid_name}, -#line 197 "accessor_class_list.gperf" +#line 196 "accessor_class_list.gperf" {"trim", &grib_accessor_trim}, - {""}, {""}, -#line 119 "accessor_class_list.gperf" - {"ibmfloat", &grib_accessor_ibmfloat}, - {""}, {""}, -#line 195 "accessor_class_list.gperf" + {""}, {""}, {""}, {""}, {""}, +#line 194 "accessor_class_list.gperf" {"transient", &grib_accessor_transient}, + {""}, {""}, +#line 38 "accessor_class_list.gperf" + {"concept", &grib_accessor_concept}, + {""}, +#line 165 "accessor_class_list.gperf" + {"round", &grib_accessor_round}, + {""}, +#line 195 "accessor_class_list.gperf" + {"transient_darray", &grib_accessor_transient_darray}, + {""}, +#line 18 "accessor_class_list.gperf" + {"budgdate", &grib_accessor_budgdate}, + {""}, {""}, +#line 143 "accessor_class_list.gperf" + {"number_of_coded_values", &grib_accessor_number_of_coded_values}, + {""}, {""}, {""}, +#line 182 "accessor_class_list.gperf" + {"spectral_truncation", &grib_accessor_spectral_truncation}, +#line 39 "accessor_class_list.gperf" + {"constant", &grib_accessor_constant}, +#line 209 "accessor_class_list.gperf" + {"values", &grib_accessor_values}, + {""}, {""}, +#line 149 "accessor_class_list.gperf" + {"octet_number", &grib_accessor_octet_number}, +#line 134 "accessor_class_list.gperf" + {"lookup", &grib_accessor_lookup}, +#line 183 "accessor_class_list.gperf" + {"sprintf", &grib_accessor_sprintf}, + {""}, {""}, {""}, +#line 133 "accessor_class_list.gperf" + {"longitudes", &grib_accessor_longitudes}, + {""}, {""}, {""}, +#line 161 "accessor_class_list.gperf" + {"proj_string", &grib_accessor_proj_string}, + {""}, +#line 189 "accessor_class_list.gperf" + {"suppressed", &grib_accessor_suppressed}, #line 55 "accessor_class_list.gperf" {"data_g1shsimple_packing", &grib_accessor_data_g1shsimple_packing}, {""}, {""}, @@ -370,263 +401,249 @@ static const struct accessor_class_hash classes[] = {"data_g1simple_packing", &grib_accessor_data_g1simple_packing}, #line 49 "accessor_class_list.gperf" {"data_g1complex_packing", &grib_accessor_data_g1complex_packing}, -#line 166 "accessor_class_list.gperf" - {"round", &grib_accessor_round}, -#line 196 "accessor_class_list.gperf" - {"transient_darray", &grib_accessor_transient_darray}, -#line 18 "accessor_class_list.gperf" - {"budgdate", &grib_accessor_budgdate}, -#line 210 "accessor_class_list.gperf" - {"values", &grib_accessor_values}, -#line 144 "accessor_class_list.gperf" - {"number_of_coded_values", &grib_accessor_number_of_coded_values}, -#line 126 "accessor_class_list.gperf" - {"label", &grib_accessor_label}, - {""}, {""}, -#line 38 "accessor_class_list.gperf" - {"concept", &grib_accessor_concept}, +#line 191 "accessor_class_list.gperf" + {"to_double", &grib_accessor_to_double}, + {""}, {""}, {""}, +#line 27 "accessor_class_list.gperf" + {"bufr_string_values", &grib_accessor_bufr_string_values}, {""}, -#line 183 "accessor_class_list.gperf" - {"spectral_truncation", &grib_accessor_spectral_truncation}, +#line 129 "accessor_class_list.gperf" + {"library_version", &grib_accessor_library_version}, + {""}, +#line 137 "accessor_class_list.gperf" + {"md5", &grib_accessor_md5}, +#line 130 "accessor_class_list.gperf" + {"local_definition", &grib_accessor_local_definition}, {""}, {""}, +#line 138 "accessor_class_list.gperf" + {"message", &grib_accessor_message}, #line 83 "accessor_class_list.gperf" {"g1_message_length", &grib_accessor_g1_message_length}, - {""}, -#line 190 "accessor_class_list.gperf" - {"suppressed", &grib_accessor_suppressed}, - {""}, {""}, {""}, {""}, -#line 180 "accessor_class_list.gperf" - {"smart_table", &grib_accessor_smart_table}, - {""}, -#line 39 "accessor_class_list.gperf" - {"constant", &grib_accessor_constant}, - {""}, {""}, -#line 162 "accessor_class_list.gperf" - {"proj_string", &grib_accessor_proj_string}, -#line 150 "accessor_class_list.gperf" - {"octet_number", &grib_accessor_octet_number}, -#line 181 "accessor_class_list.gperf" - {"smart_table_column", &grib_accessor_smart_table_column}, - {""}, +#line 101 "accessor_class_list.gperf" + {"g2bitmap_present", &grib_accessor_g2bitmap_present}, #line 135 "accessor_class_list.gperf" - {"lookup", &grib_accessor_lookup}, + {"mars_param", &grib_accessor_mars_param}, +#line 212 "accessor_class_list.gperf" + {"when", &grib_accessor_when}, +#line 119 "accessor_class_list.gperf" + {"ieeefloat", &grib_accessor_ieeefloat}, +#line 150 "accessor_class_list.gperf" + {"offset_file", &grib_accessor_offset_file}, + {""}, {""}, {""}, {""}, +#line 139 "accessor_class_list.gperf" + {"message_copy", &grib_accessor_message_copy}, + {""}, {""}, +#line 207 "accessor_class_list.gperf" + {"validity_date", &grib_accessor_validity_date}, +#line 208 "accessor_class_list.gperf" + {"validity_time", &grib_accessor_validity_time}, +#line 21 "accessor_class_list.gperf" + {"bufr_elements_table", &grib_accessor_bufr_elements_table}, +#line 211 "accessor_class_list.gperf" + {"vector", &grib_accessor_vector}, {""}, #line 94 "accessor_class_list.gperf" {"g1step_range", &grib_accessor_g1step_range}, -#line 73 "accessor_class_list.gperf" - {"decimal_precision", &grib_accessor_decimal_precision}, {""}, -#line 134 "accessor_class_list.gperf" - {"longitudes", &grib_accessor_longitudes}, +#line 33 "accessor_class_list.gperf" + {"closest_date", &grib_accessor_closest_date}, +#line 70 "accessor_class_list.gperf" + {"data_sh_unpacked", &grib_accessor_data_sh_unpacked}, +#line 35 "accessor_class_list.gperf" + {"codetable", &grib_accessor_codetable}, + {""}, {""}, +#line 158 "accessor_class_list.gperf" + {"padtoeven", &grib_accessor_padtoeven}, +#line 71 "accessor_class_list.gperf" + {"data_shsimple_packing", &grib_accessor_data_shsimple_packing}, {""}, -#line 27 "accessor_class_list.gperf" - {"bufr_string_values", &grib_accessor_bufr_string_values}, -#line 198 "accessor_class_list.gperf" - {"uint16", &grib_accessor_uint16}, - {""}, {""}, {""}, #line 86 "accessor_class_list.gperf" {"g1date", &grib_accessor_g1date}, {""}, #line 85 "accessor_class_list.gperf" {"g1bitmap", &grib_accessor_g1bitmap}, - {""}, #line 54 "accessor_class_list.gperf" {"data_g1secondary_bitmap", &grib_accessor_data_g1secondary_bitmap}, -#line 192 "accessor_class_list.gperf" - {"to_double", &grib_accessor_to_double}, -#line 101 "accessor_class_list.gperf" - {"g2bitmap_present", &grib_accessor_g2bitmap_present}, + {""}, +#line 132 "accessor_class_list.gperf" + {"long_vector", &grib_accessor_long_vector}, + {""}, {""}, +#line 197 "accessor_class_list.gperf" + {"uint16", &grib_accessor_uint16}, + {""}, +#line 127 "accessor_class_list.gperf" + {"latlon_increment", &grib_accessor_latlon_increment}, {""}, #line 213 "accessor_class_list.gperf" - {"when", &grib_accessor_when}, -#line 208 "accessor_class_list.gperf" - {"validity_date", &grib_accessor_validity_date}, -#line 209 "accessor_class_list.gperf" - {"validity_time", &grib_accessor_validity_time}, - {""}, -#line 184 "accessor_class_list.gperf" - {"sprintf", &grib_accessor_sprintf}, -#line 212 "accessor_class_list.gperf" - {"vector", &grib_accessor_vector}, -#line 84 "accessor_class_list.gperf" - {"g1_section4_length", &grib_accessor_g1_section4_length}, -#line 141 "accessor_class_list.gperf" - {"multdouble", &grib_accessor_multdouble}, + {"cf_var_name", &grib_accessor_cf_var_name}, +#line 136 "accessor_class_list.gperf" + {"mars_step", &grib_accessor_mars_step}, +#line 210 "accessor_class_list.gperf" + {"variable", &grib_accessor_variable}, #line 52 "accessor_class_list.gperf" {"data_g1second_order_general_packing", &grib_accessor_data_g1second_order_general_packing}, -#line 130 "accessor_class_list.gperf" - {"library_version", &grib_accessor_library_version}, +#line 84 "accessor_class_list.gperf" + {"g1_section4_length", &grib_accessor_g1_section4_length}, {""}, #line 53 "accessor_class_list.gperf" {"data_g1second_order_row_by_row_packing", &grib_accessor_data_g1second_order_row_by_row_packing}, - {""}, {""}, -#line 159 "accessor_class_list.gperf" - {"padtoeven", &grib_accessor_padtoeven}, + {""}, +#line 25 "accessor_class_list.gperf" + {"bufr_group", &grib_accessor_bufr_group}, + {""}, #line 50 "accessor_class_list.gperf" {"data_g1second_order_constant_width_packing", &grib_accessor_data_g1second_order_constant_width_packing}, {""}, #line 51 "accessor_class_list.gperf" {"data_g1second_order_general_extended_packing", &grib_accessor_data_g1second_order_general_extended_packing}, -#line 70 "accessor_class_list.gperf" - {"data_sh_unpacked", &grib_accessor_data_sh_unpacked}, - {""}, {""}, {""}, {""}, -#line 71 "accessor_class_list.gperf" - {"data_shsimple_packing", &grib_accessor_data_shsimple_packing}, -#line 21 "accessor_class_list.gperf" - {"bufr_elements_table", &grib_accessor_bufr_elements_table}, - {""}, {""}, {""}, {""}, -#line 154 "accessor_class_list.gperf" +#line 153 "accessor_class_list.gperf" {"pack_bufr_values", &grib_accessor_pack_bufr_values}, -#line 35 "accessor_class_list.gperf" - {"codetable", &grib_accessor_codetable}, -#line 131 "accessor_class_list.gperf" - {"local_definition", &grib_accessor_local_definition}, + {""}, {""}, {""}, {""}, +#line 167 "accessor_class_list.gperf" + {"scale_values", &grib_accessor_scale_values}, {""}, -#line 25 "accessor_class_list.gperf" - {"bufr_group", &grib_accessor_bufr_group}, - {""}, -#line 88 "accessor_class_list.gperf" - {"g1end_of_interval_monthly", &grib_accessor_g1end_of_interval_monthly}, -#line 147 "accessor_class_list.gperf" +#line 146 "accessor_class_list.gperf" {"number_of_values", &grib_accessor_number_of_values}, + {""}, {""}, {""}, {""}, {""}, #line 24 "accessor_class_list.gperf" {"bufr_extract_subsets", &grib_accessor_bufr_extract_subsets}, -#line 120 "accessor_class_list.gperf" - {"ieeefloat", &grib_accessor_ieeefloat}, -#line 151 "accessor_class_list.gperf" - {"offset_file", &grib_accessor_offset_file}, -#line 33 "accessor_class_list.gperf" - {"closest_date", &grib_accessor_closest_date}, -#line 153 "accessor_class_list.gperf" - {"optimal_step_units", &grib_accessor_optimal_step_units}, -#line 22 "accessor_class_list.gperf" - {"bufr_extract_area_subsets", &grib_accessor_bufr_extract_area_subsets}, -#line 211 "accessor_class_list.gperf" - {"variable", &grib_accessor_variable}, -#line 133 "accessor_class_list.gperf" - {"long_vector", &grib_accessor_long_vector}, -#line 168 "accessor_class_list.gperf" - {"scale_values", &grib_accessor_scale_values}, -#line 23 "accessor_class_list.gperf" - {"bufr_extract_datetime_subsets", &grib_accessor_bufr_extract_datetime_subsets}, - {""}, {""}, -#line 128 "accessor_class_list.gperf" - {"latlon_increment", &grib_accessor_latlon_increment}, - {""}, {""}, {""}, -#line 148 "accessor_class_list.gperf" - {"number_of_values_data_raw_packing", &grib_accessor_number_of_values_data_raw_packing}, - {""}, -#line 79 "accessor_class_list.gperf" - {"evaluate", &grib_accessor_evaluate}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, #line 11 "accessor_class_list.gperf" {"abstract_vector", &grib_accessor_abstract_vector}, - {""}, {""}, {""}, {""}, -#line 41 "accessor_class_list.gperf" - {"count_missing", &grib_accessor_count_missing}, -#line 205 "accessor_class_list.gperf" - {"unpack_bufr_values", &grib_accessor_unpack_bufr_values}, -#line 116 "accessor_class_list.gperf" - {"gts_header", &grib_accessor_gts_header}, - {""}, -#line 214 "accessor_class_list.gperf" - {"cf_var_name", &grib_accessor_cf_var_name}, - {""}, {""}, {""}, #line 36 "accessor_class_list.gperf" {"codetable_title", &grib_accessor_codetable_title}, - {""}, {""}, {""}, -#line 89 "accessor_class_list.gperf" - {"g1fcperiod", &grib_accessor_g1fcperiod}, - {""}, {""}, {""}, {""}, {""}, -#line 125 "accessor_class_list.gperf" - {"ksec1expver", &grib_accessor_ksec1expver}, - {""}, {""}, -#line 106 "accessor_class_list.gperf" - {"g2level", &grib_accessor_g2level}, #line 42 "accessor_class_list.gperf" {"count_total", &grib_accessor_count_total}, +#line 88 "accessor_class_list.gperf" + {"g1end_of_interval_monthly", &grib_accessor_g1end_of_interval_monthly}, +#line 22 "accessor_class_list.gperf" + {"bufr_extract_area_subsets", &grib_accessor_bufr_extract_area_subsets}, + {""}, +#line 115 "accessor_class_list.gperf" + {"gts_header", &grib_accessor_gts_header}, + {""}, +#line 23 "accessor_class_list.gperf" + {"bufr_extract_datetime_subsets", &grib_accessor_bufr_extract_datetime_subsets}, + {""}, +#line 147 "accessor_class_list.gperf" + {"number_of_values_data_raw_packing", &grib_accessor_number_of_values_data_raw_packing}, +#line 151 "accessor_class_list.gperf" + {"offset_values", &grib_accessor_offset_values}, +#line 79 "accessor_class_list.gperf" + {"evaluate", &grib_accessor_evaluate}, {""}, {""}, {""}, +#line 73 "accessor_class_list.gperf" + {"decimal_precision", &grib_accessor_decimal_precision}, +#line 179 "accessor_class_list.gperf" + {"smart_table", &grib_accessor_smart_table}, +#line 204 "accessor_class_list.gperf" + {"unpack_bufr_values", &grib_accessor_unpack_bufr_values}, +#line 117 "accessor_class_list.gperf" + {"headers_only", &grib_accessor_headers_only}, +#line 34 "accessor_class_list.gperf" + {"codeflag", &grib_accessor_codeflag}, +#line 106 "accessor_class_list.gperf" + {"g2level", &grib_accessor_g2level}, +#line 120 "accessor_class_list.gperf" + {"ifs_param", &grib_accessor_ifs_param}, + {""}, +#line 180 "accessor_class_list.gperf" + {"smart_table_column", &grib_accessor_smart_table_column}, + {""}, {""}, {""}, {""}, +#line 128 "accessor_class_list.gperf" + {"latlonvalues", &grib_accessor_latlonvalues}, + {""}, #line 69 "accessor_class_list.gperf" {"data_sh_packed", &grib_accessor_data_sh_packed}, #line 37 "accessor_class_list.gperf" {"codetable_units", &grib_accessor_codetable_units}, -#line 118 "accessor_class_list.gperf" - {"headers_only", &grib_accessor_headers_only}, - {""}, -#line 129 "accessor_class_list.gperf" - {"latlonvalues", &grib_accessor_latlonvalues}, - {""}, -#line 152 "accessor_class_list.gperf" - {"offset_values", &grib_accessor_offset_values}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, -#line 121 "accessor_class_list.gperf" - {"ifs_param", &grib_accessor_ifs_param}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, #line 10 "accessor_class_list.gperf" {"abstract_long_vector", &grib_accessor_abstract_long_vector}, -#line 34 "accessor_class_list.gperf" - {"codeflag", &grib_accessor_codeflag}, - {""}, {""}, {""}, -#line 117 "accessor_class_list.gperf" - {"hash_array", &grib_accessor_hash_array}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, +#line 89 "accessor_class_list.gperf" + {"g1fcperiod", &grib_accessor_g1fcperiod}, {""}, -#line 30 "accessor_class_list.gperf" - {"change_alternative_row_scanning", &grib_accessor_change_alternative_row_scanning}, - {""}, {""}, {""}, {""}, {""}, {""}, -#line 31 "accessor_class_list.gperf" - {"change_scanning_direction", &grib_accessor_change_scanning_direction}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, -#line 149 "accessor_class_list.gperf" - {"octahedral_gaussian", &grib_accessor_octahedral_gaussian}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, #line 40 "accessor_class_list.gperf" {"count_file", &grib_accessor_count_file}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, +#line 116 "accessor_class_list.gperf" + {"hash_array", &grib_accessor_hash_array}, +#line 30 "accessor_class_list.gperf" + {"change_alternative_row_scanning", &grib_accessor_change_alternative_row_scanning}, +#line 152 "accessor_class_list.gperf" + {"optimal_step_units", &grib_accessor_optimal_step_units}, + {""}, {""}, {""}, +#line 140 "accessor_class_list.gperf" + {"multdouble", &grib_accessor_multdouble}, + {""}, +#line 31 "accessor_class_list.gperf" + {"change_scanning_direction", &grib_accessor_change_scanning_direction}, + {""}, {""}, {""}, {""}, {""}, {""}, +#line 148 "accessor_class_list.gperf" + {"octahedral_gaussian", &grib_accessor_octahedral_gaussian}, + {""}, +#line 124 "accessor_class_list.gperf" + {"ksec1expver", &grib_accessor_ksec1expver}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, +#line 41 "accessor_class_list.gperf" + {"count_missing", &grib_accessor_count_missing}, + {""}, {""}, {""}, {""}, {""}, {""}, +#line 81 "accessor_class_list.gperf" + {"from_scale_factor_scaled_value", &grib_accessor_from_scale_factor_scaled_value}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, +#line 82 "accessor_class_list.gperf" + {"g1_half_byte_codeflag", &grib_accessor_g1_half_byte_codeflag}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, #line 91 "accessor_class_list.gperf" {"g1monthlydate", &grib_accessor_g1monthlydate}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, {""}, {""}, {""}, -#line 82 "accessor_class_list.gperf" - {"g1_half_byte_codeflag", &grib_accessor_g1_half_byte_codeflag}, {""}, -#line 81 "accessor_class_list.gperf" - {"from_scale_factor_scaled_value", &grib_accessor_from_scale_factor_scaled_value}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, -#line 165 "accessor_class_list.gperf" - {"reference_value_error", &grib_accessor_reference_value_error}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, #line 32 "accessor_class_list.gperf" {"check_internal_version", &grib_accessor_check_internal_version}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, {""}, {""}, {""}, -#line 97 "accessor_class_list.gperf" - {"g2_chemical", &grib_accessor_g2_chemical}, - {""}, {""}, {""}, {""}, {""}, + {""}, {""}, +#line 164 "accessor_class_list.gperf" + {"reference_value_error", &grib_accessor_reference_value_error}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, #line 87 "accessor_class_list.gperf" {"g1day_of_the_year_date", &grib_accessor_g1day_of_the_year_date}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, {""}, {""}, {""}, -#line 90 "accessor_class_list.gperf" - {"g1forecastmonth", &grib_accessor_g1forecastmonth}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, +#line 95 "accessor_class_list.gperf" + {"g1verificationdate", &grib_accessor_g1verificationdate}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, +#line 97 "accessor_class_list.gperf" + {"g2_chemical", &grib_accessor_g2_chemical}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, + {""}, {""}, {""}, {""}, {""}, #line 93 "accessor_class_list.gperf" {"g1number_of_coded_values_sh_simple", &grib_accessor_g1number_of_coded_values_sh_simple}, #line 92 "accessor_class_list.gperf" {"g1number_of_coded_values_sh_complex", &grib_accessor_g1number_of_coded_values_sh_complex}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, -#line 95 "accessor_class_list.gperf" - {"g1verificationdate", &grib_accessor_g1verificationdate} +#line 90 "accessor_class_list.gperf" + {"g1forecastmonth", &grib_accessor_g1forecastmonth} }; const struct accessor_class_hash * diff --git a/src/grib_accessor_factory.h b/src/grib_accessor_factory.h index 524458c58..a345e7391 100644 --- a/src/grib_accessor_factory.h +++ b/src/grib_accessor_factory.h @@ -100,7 +100,6 @@ { "g2step_range", &grib_accessor_g2step_range, }, { "gaussian_grid_name", &grib_accessor_gaussian_grid_name, }, { "gds_is_present", &grib_accessor_gds_is_present, }, -{ "gds_not_present_bitmap", &grib_accessor_gds_not_present_bitmap, }, { "gen", &grib_accessor_gen, }, { "getenv", &grib_accessor_getenv, }, { "global_gaussian", &grib_accessor_global_gaussian, }, diff --git a/src/grib_accessor_factory_hash_list b/src/grib_accessor_factory_hash_list index 1530448d4..3a64fd150 100644 --- a/src/grib_accessor_factory_hash_list +++ b/src/grib_accessor_factory_hash_list @@ -101,7 +101,6 @@ g2lon, &grib_accessor_g2lon g2step_range, &grib_accessor_g2step_range gaussian_grid_name, &grib_accessor_gaussian_grid_name gds_is_present, &grib_accessor_gds_is_present -gds_not_present_bitmap, &grib_accessor_gds_not_present_bitmap gen, &grib_accessor_gen getenv, &grib_accessor_getenv global_gaussian, &grib_accessor_global_gaussian diff --git a/src/grib_api.h b/src/grib_api.h index 09601899f..5bc8c1a9e 100644 --- a/src/grib_api.h +++ b/src/grib_api.h @@ -815,13 +815,14 @@ int grib_get_float_elements(const grib_handle* h, const char* key, const int* in * Get a string value from a key, if several keys of the same name are present, the last one is returned * @see grib_set_string * - * @param h : the handle to get the data from - * @param key : the key to be searched - * @param mesg : the address of a string where the data will be retrieved - * @param length : the address of a size_t that contains allocated length of the string on input, and that contains the actual length of the string on output - * @return 0 if OK, integer value on error + * @param h : the handle to get the data from + * @param key : the key to be searched + * @param value : the address of a string where the data will be retrieved + * @param length : the address of a size_t that contains allocated length of the string on input, + * and that contains the actual length of the string on output + * @return 0 if OK, integer value on error */ -int grib_get_string(const grib_handle* h, const char* key, char* mesg, size_t* length); +int grib_get_string(const grib_handle* h, const char* key, char* value, size_t* length); /** * Get string array values from a key. If several keys of the same name are present, the last one is returned @@ -912,11 +913,12 @@ int grib_set_double(grib_handle* h, const char* key, double val); * * @param h : the handle to set the data to * @param key : the key to be searched - * @param mesg : the address of a string where the data will be read - * @param length : the address of a size_t that contains the length of the string on input, and that contains the actual packed length of the string on output + * @param value : the address of a string where the data will be read + * @param length : the address of a size_t that contains the length of the string on input, + * and that contains the actual packed length of the string on output * @return 0 if OK, integer value on error */ -int grib_set_string(grib_handle* h, const char* key, const char* mesg, size_t* length); +int grib_set_string(grib_handle* h, const char* key, const char* value, size_t* length); /** * Set a bytes array from a key. If several keys of the same name are present, the last one is set @@ -1143,7 +1145,7 @@ void grib_gribex_mode_on(grib_context* c); * * @param c : the context */ -int grib_get_gribex_mode(grib_context* c); +int grib_get_gribex_mode(const grib_context* c); /** * Set the GRIBEX mode off. @@ -1259,6 +1261,8 @@ long grib_get_api_version(void); */ const char* grib_get_git_sha1(void); +const char* grib_get_git_branch(void); + /** * Get the package name * diff --git a/src/grib_api_version.cc.in b/src/grib_api_version.cc.in index 8fb7ea836..3f902f65a 100644 --- a/src/grib_api_version.cc.in +++ b/src/grib_api_version.cc.in @@ -13,6 +13,12 @@ const char* grib_get_git_sha1(void) { return "@eccodes_GIT_SHA1@"; } + +const char* grib_get_git_branch(void) +{ + return "@eccodes_GIT_BRANCH@"; +} + const char* codes_get_build_date(void) { return "@eccodes_BUILD_DATE@"; diff --git a/src/grib_context.cc b/src/grib_context.cc index 442faa1e8..75681a195 100644 --- a/src/grib_context.cc +++ b/src/grib_context.cc @@ -185,19 +185,19 @@ int grib_context_seek(const grib_context* c, off_t offset, int whence, void* str return c->seek(c, offset, whence, stream); } -int grib_context_eof(const grib_context* c, void* stream) -{ - if (!c) - c = grib_context_get_default(); - return c->eof(c, stream); -} +// int grib_context_eof(const grib_context* c, void* stream) +// { +// if (!c) +// c = grib_context_get_default(); +// return c->eof(c, stream); +// } -size_t grib_context_write(const grib_context* c, const void* ptr, size_t size, void* stream) -{ - if (!c) - c = grib_context_get_default(); - return c->write(c, ptr, size, stream); -} +// size_t grib_context_write(const grib_context* c, const void* ptr, size_t size, void* stream) +// { +// if (!c) +// c = grib_context_get_default(); +// return c->write(c, ptr, size, stream); +// } static void default_log(const grib_context* c, int level, const char* mess) { @@ -237,7 +237,7 @@ static void default_print(const grib_context* c, void* descriptor, const char* m void grib_context_set_print_proc(grib_context* c, grib_print_proc p) { c = c ? c : grib_context_get_default(); - /* Set logging back to the default if p is NULL */ + /* Set printing back to the default if p is NULL */ c->print = (p ? p : &default_print); } @@ -661,20 +661,19 @@ static int init_definition_files_dir(grib_context* c) } else { /* Definitions path contains multiple directories */ - char* dir = NULL; - dir = strtok_r(path, ECC_PATH_DELIMITER_STR, &lasts); + const char* dir = strtok_r(path, ECC_PATH_DELIMITER_STR, &lasts); while (dir != NULL) { if (next) { next->next = (grib_string_list*)grib_context_malloc_clear_persistent(c, sizeof(grib_string_list)); - next = next->next; + next = next->next; } else { c->grib_definition_files_dir = (grib_string_list*)grib_context_malloc_clear_persistent(c, sizeof(grib_string_list)); - next = c->grib_definition_files_dir; + next = c->grib_definition_files_dir; } next->value = codes_resolve_path(c, dir); - dir = strtok_r(NULL, ECC_PATH_DELIMITER_STR, &lasts); + dir = strtok_r(NULL, ECC_PATH_DELIMITER_STR, &lasts); } } @@ -1233,7 +1232,7 @@ void codes_assertion_failed(const char* message, const char* file, int line) /* Default behaviour is to abort * unless user has supplied his own assertion routine */ if (assertion == NULL) { - grib_context* c = grib_context_get_default(); + const grib_context* c = grib_context_get_default(); fprintf(stderr, "ecCodes assertion failed: `%s' in %s:%d\n", message, file, line); if (!c->no_abort) { abort(); @@ -1246,7 +1245,7 @@ void codes_assertion_failed(const char* message, const char* file, int line) } } -int grib_get_gribex_mode(grib_context* c) +int grib_get_gribex_mode(const grib_context* c) { if (!c) c = grib_context_get_default(); diff --git a/src/grib_dumper_class_debug.cc b/src/grib_dumper_class_debug.cc index 6f97c0c54..24626d884 100644 --- a/src/grib_dumper_class_debug.cc +++ b/src/grib_dumper_class_debug.cc @@ -264,22 +264,21 @@ static int test_bit(long a, long b) static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment) { grib_dumper_debug* self = (grib_dumper_debug*)d; - long value = 0; - size_t size = 1; - int err = a->unpack_long(&value, &size); - int i; if (a->length_ == 0 && (d->option_flags & GRIB_DUMP_FLAG_CODED) != 0) return; + size_t size = 1; + long value = 0; + int err = a->unpack_long(&value, &size); set_begin_end(d, a); - for (i = 0; i < d->depth; i++) + for (int i = 0; i < d->depth; i++) fprintf(self->dumper.out, " "); fprintf(self->dumper.out, "%ld-%ld %s %s = %ld [", self->begin, self->theEnd, a->creator_->op, a->name_, value); - for (i = 0; i < (a->length_ * 8); i++) { + for (long i = 0; i < (a->length_ * 8); i++) { if (test_bit(value, a->length_ * 8 - i - 1)) fprintf(self->dumper.out, "1"); else diff --git a/src/grib_dumper_class_default.cc b/src/grib_dumper_class_default.cc index 476517e62..0a8411a82 100644 --- a/src/grib_dumper_class_default.cc +++ b/src/grib_dumper_class_default.cc @@ -212,28 +212,15 @@ static int test_bit(long a, long b) static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment) { grib_dumper_default* self = (grib_dumper_default*)d; - int i; long lvalue = 0; - double dvalue = 0; size_t size = 1; int err = 0; - int isDouble = 0; - - switch (a->get_native_type()) { - case GRIB_TYPE_LONG: - a->unpack_long(&lvalue, &size); - break; - case GRIB_TYPE_DOUBLE: - a->unpack_double(&dvalue, &size); - isDouble = 1; - break; - default: - break; - } if ((a->flags_ & GRIB_ACCESSOR_FLAG_DUMP) == 0) return; + err = a->unpack_long(&lvalue, &size); + print_offset(self->dumper.out, d, a); if ((d->option_flags & GRIB_DUMP_FLAG_TYPE) != 0) { @@ -249,7 +236,7 @@ static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment) fprintf(self->dumper.out, " "); fprintf(self->dumper.out, "# flags: "); - for (i = 0; i < (a->length_ * 8); i++) { + for (long i = 0; i < (a->length_ * 8); i++) { if (test_bit(lvalue, a->length_ * 8 - i - 1)) fprintf(self->dumper.out, "1"); else @@ -261,19 +248,16 @@ static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment) fprintf(self->dumper.out, " "); fprintf(self->dumper.out, "#-READ ONLY- "); } - else + else { fprintf(self->dumper.out, " "); + } if (((a->flags_ & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && a->is_missing_internal()) fprintf(self->dumper.out, "%s = MISSING;", a->name_); else { - if (isDouble) - fprintf(self->dumper.out, "%s = %g;", a->name_, dvalue); - else - fprintf(self->dumper.out, "%s = %ld;", a->name_, lvalue); + fprintf(self->dumper.out, "%s = %ld;", a->name_, lvalue); } - if (err) { fprintf(self->dumper.out, " "); fprintf(self->dumper.out, "# *** ERR=%d (%s) [grib_dumper_default::dump_bits]", err, grib_get_error_message(err)); diff --git a/src/grib_dumper_class_wmo.cc b/src/grib_dumper_class_wmo.cc index 6c7803da1..723a09eae 100644 --- a/src/grib_dumper_class_wmo.cc +++ b/src/grib_dumper_class_wmo.cc @@ -219,7 +219,6 @@ static int test_bit(long a, long b) static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment) { grib_dumper_wmo* self = (grib_dumper_wmo*)d; - int i; long value = 0; size_t size = 1; int err = 0; @@ -237,7 +236,8 @@ static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment) fprintf(self->dumper.out, "%s (int) ", a->creator_->op); fprintf(self->dumper.out, "%s = %ld [", a->name_, value); - for (i = 0; i < (a->length_ * 8); i++) { + + for (long i = 0; i < (a->length_ * 8); i++) { if (test_bit(value, a->length_ * 8 - i - 1)) fprintf(self->dumper.out, "1"); else diff --git a/src/grib_expression_class_accessor.cc b/src/grib_expression_class_accessor.cc index ed3fcd9fe..71bc70526 100644 --- a/src/grib_expression_class_accessor.cc +++ b/src/grib_expression_class_accessor.cc @@ -42,7 +42,7 @@ or edit "expression.class" and rerun ./make_class.pl typedef const char* string; /* to keep make_class.pl happy */ static void destroy(grib_context*,grib_expression* e); -static void print(grib_context*,grib_expression*,grib_handle*, FILE*); +static void print(grib_context*, grib_expression*, grib_handle*, FILE*); static void add_dependency(grib_expression* e, grib_accessor* observer); static string get_name(grib_expression* e); static int native_type(grib_expression*,grib_handle*); @@ -60,12 +60,12 @@ typedef struct grib_expression_accessor{ static grib_expression_class _grib_expression_class_accessor = { - 0, /* super */ - "accessor", /* name */ - sizeof(grib_expression_accessor),/* size of instance */ + 0, /* super */ + "accessor", /* name */ + sizeof(grib_expression_accessor),/* size of instance */ 0, /* inited */ - 0, /* constructor */ - &destroy, /* destructor */ + 0, /* constructor */ + &destroy, /* destructor */ &print, &add_dependency, &native_type, diff --git a/src/grib_expression_class_binop.cc b/src/grib_expression_class_binop.cc index e1c4f3d02..60547ec2f 100644 --- a/src/grib_expression_class_binop.cc +++ b/src/grib_expression_class_binop.cc @@ -42,7 +42,7 @@ or edit "expression.class" and rerun ./make_class.pl typedef const char* string; /* to keep make_class.pl happy */ static void destroy(grib_context*,grib_expression* e); -static void print(grib_context*,grib_expression*,grib_handle*, FILE*); +static void print(grib_context*, grib_expression*, grib_handle*, FILE*); static void add_dependency(grib_expression* e, grib_accessor* observer); static int native_type(grib_expression*,grib_handle*); static int evaluate_long(grib_expression*,grib_handle*,long*); @@ -60,12 +60,12 @@ typedef struct grib_expression_binop{ static grib_expression_class _grib_expression_class_binop = { - 0, /* super */ - "binop", /* name */ - sizeof(grib_expression_binop),/* size of instance */ + 0, /* super */ + "binop", /* name */ + sizeof(grib_expression_binop),/* size of instance */ 0, /* inited */ - 0, /* constructor */ - &destroy, /* destructor */ + 0, /* constructor */ + &destroy, /* destructor */ &print, &add_dependency, &native_type, @@ -85,7 +85,6 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) long v2 = 0; grib_expression_binop* e = (grib_expression_binop*)g; -// #if DEBUGGING // { // int typeLeft, typeRight; // const char* nameLeft; @@ -117,7 +116,6 @@ static int evaluate_double(grib_expression* g, grib_handle* h, double* dres) double v2 = 0.0; grib_expression_binop* e = (grib_expression_binop*)g; -// #if DEBUGGING // { // int typeLeft, typeRight; // const char* nameLeft; diff --git a/src/grib_expression_class_double.cc b/src/grib_expression_class_double.cc index 52d40832f..14e38e973 100644 --- a/src/grib_expression_class_double.cc +++ b/src/grib_expression_class_double.cc @@ -38,7 +38,7 @@ or edit "expression.class" and rerun ./make_class.pl typedef const char* string; /* to keep make_class.pl happy */ static void destroy(grib_context*,grib_expression* e); -static void print(grib_context*,grib_expression*,grib_handle*, FILE*); +static void print(grib_context*, grib_expression*, grib_handle*, FILE*); static void add_dependency(grib_expression* e, grib_accessor* observer); static int native_type(grib_expression*,grib_handle*); static int evaluate_long(grib_expression*,grib_handle*,long*); @@ -52,12 +52,12 @@ typedef struct grib_expression_double{ static grib_expression_class _grib_expression_class_double = { - 0, /* super */ - "double", /* name */ - sizeof(grib_expression_double),/* size of instance */ + 0, /* super */ + "double", /* name */ + sizeof(grib_expression_double),/* size of instance */ 0, /* inited */ - 0, /* constructor */ - &destroy, /* destructor */ + 0, /* constructor */ + &destroy, /* destructor */ &print, &add_dependency, &native_type, diff --git a/src/grib_expression_class_functor.cc b/src/grib_expression_class_functor.cc index 0f1d80214..eb147d963 100644 --- a/src/grib_expression_class_functor.cc +++ b/src/grib_expression_class_functor.cc @@ -38,7 +38,7 @@ or edit "expression.class" and rerun ./make_class.pl typedef const char* string; /* to keep make_class.pl happy */ static void destroy(grib_context*,grib_expression* e); -static void print(grib_context*,grib_expression*,grib_handle*,FILE*); +static void print(grib_context*, grib_expression*, grib_handle*, FILE*); static void add_dependency(grib_expression* e, grib_accessor* observer); static int native_type(grib_expression*,grib_handle*); static int evaluate_long(grib_expression*,grib_handle*,long*); @@ -52,12 +52,12 @@ typedef struct grib_expression_functor{ static grib_expression_class _grib_expression_class_functor = { - 0, /* super */ - "functor", /* name */ - sizeof(grib_expression_functor),/* size of instance */ + 0, /* super */ + "functor", /* name */ + sizeof(grib_expression_functor),/* size of instance */ 0, /* inited */ - 0, /* constructor */ - &destroy, /* destructor */ + 0, /* constructor */ + &destroy, /* destructor */ &print, &add_dependency, &native_type, diff --git a/src/grib_expression_class_is_in_dict.cc b/src/grib_expression_class_is_in_dict.cc index 46e0833f6..8d86c24bf 100644 --- a/src/grib_expression_class_is_in_dict.cc +++ b/src/grib_expression_class_is_in_dict.cc @@ -39,7 +39,7 @@ or edit "expression.class" and rerun ./make_class.pl typedef const char* string; /* to keep make_class.pl happy */ -static void print(grib_context*,grib_expression*,grib_handle*,FILE*); +static void print(grib_context*, grib_expression*, grib_handle*, FILE*); static void add_dependency(grib_expression* e, grib_accessor* observer); static string get_name(grib_expression* e); static int native_type(grib_expression*,grib_handle*); @@ -56,12 +56,12 @@ typedef struct grib_expression_is_in_dict{ static grib_expression_class _grib_expression_class_is_in_dict = { - 0, /* super */ - "is_in_dict", /* name */ - sizeof(grib_expression_is_in_dict),/* size of instance */ + 0, /* super */ + "is_in_dict", /* name */ + sizeof(grib_expression_is_in_dict),/* size of instance */ 0, /* inited */ - 0, /* constructor */ - 0, /* destructor */ + 0, /* constructor */ + 0, /* destructor */ &print, &add_dependency, &native_type, diff --git a/src/grib_expression_class_is_in_list.cc b/src/grib_expression_class_is_in_list.cc index 3e5e3728d..953481ad0 100644 --- a/src/grib_expression_class_is_in_list.cc +++ b/src/grib_expression_class_is_in_list.cc @@ -41,7 +41,7 @@ or edit "expression.class" and rerun ./make_class.pl typedef const char* string; /* to keep make_class.pl happy */ static void destroy(grib_context*,grib_expression* e); -static void print(grib_context*,grib_expression*,grib_handle*,FILE*); +static void print(grib_context*, grib_expression*, grib_handle*, FILE*); static void add_dependency(grib_expression* e, grib_accessor* observer); static string get_name(grib_expression* e); static int native_type(grib_expression*,grib_handle*); @@ -58,12 +58,12 @@ typedef struct grib_expression_is_in_list{ static grib_expression_class _grib_expression_class_is_in_list = { - 0, /* super */ - "is_in_list", /* name */ - sizeof(grib_expression_is_in_list),/* size of instance */ + 0, /* super */ + "is_in_list", /* name */ + sizeof(grib_expression_is_in_list),/* size of instance */ 0, /* inited */ - 0, /* constructor */ - &destroy, /* destructor */ + 0, /* constructor */ + &destroy, /* destructor */ &print, &add_dependency, &native_type, diff --git a/src/grib_expression_class_is_integer.cc b/src/grib_expression_class_is_integer.cc index bf203bc81..d88756974 100644 --- a/src/grib_expression_class_is_integer.cc +++ b/src/grib_expression_class_is_integer.cc @@ -42,7 +42,7 @@ or edit "expression.class" and rerun ./make_class.pl typedef const char* string; /* to keep make_class.pl happy */ static void destroy(grib_context*,grib_expression* e); -static void print(grib_context*,grib_expression*,grib_handle*, FILE*); +static void print(grib_context*, grib_expression*, grib_handle*, FILE*); static void add_dependency(grib_expression* e, grib_accessor* observer); static string get_name(grib_expression* e); static int native_type(grib_expression*,grib_handle*); @@ -60,12 +60,12 @@ typedef struct grib_expression_is_integer{ static grib_expression_class _grib_expression_class_is_integer = { - 0, /* super */ - "is_integer", /* name */ - sizeof(grib_expression_is_integer),/* size of instance */ + 0, /* super */ + "is_integer", /* name */ + sizeof(grib_expression_is_integer),/* size of instance */ 0, /* inited */ - 0, /* constructor */ - &destroy, /* destructor */ + 0, /* constructor */ + &destroy, /* destructor */ &print, &add_dependency, &native_type, diff --git a/src/grib_expression_class_length.cc b/src/grib_expression_class_length.cc index c8c63f8e8..e2c0d3202 100644 --- a/src/grib_expression_class_length.cc +++ b/src/grib_expression_class_length.cc @@ -42,7 +42,7 @@ or edit "expression.class" and rerun ./make_class.pl typedef const char* string; /* to keep make_class.pl happy */ static void destroy(grib_context*,grib_expression* e); -static void print(grib_context*,grib_expression*,grib_handle*,FILE*); +static void print(grib_context*, grib_expression*, grib_handle*, FILE*); static void add_dependency(grib_expression* e, grib_accessor* observer); static string get_name(grib_expression* e); static int native_type(grib_expression*,grib_handle*); @@ -60,12 +60,12 @@ typedef struct grib_expression_length{ static grib_expression_class _grib_expression_class_length = { - 0, /* super */ - "length", /* name */ - sizeof(grib_expression_length),/* size of instance */ + 0, /* super */ + "length", /* name */ + sizeof(grib_expression_length),/* size of instance */ 0, /* inited */ - 0, /* constructor */ - &destroy, /* destructor */ + 0, /* constructor */ + &destroy, /* destructor */ &print, &add_dependency, &native_type, diff --git a/src/grib_expression_class_logical_and.cc b/src/grib_expression_class_logical_and.cc index d95de8d92..419383373 100644 --- a/src/grib_expression_class_logical_and.cc +++ b/src/grib_expression_class_logical_and.cc @@ -39,7 +39,7 @@ or edit "expression.class" and rerun ./make_class.pl typedef const char* string; /* to keep make_class.pl happy */ static void destroy(grib_context*,grib_expression* e); -static void print(grib_context*,grib_expression*,grib_handle*, FILE*); +static void print(grib_context*, grib_expression*, grib_handle*, FILE*); static void add_dependency(grib_expression* e, grib_accessor* observer); static int native_type(grib_expression*,grib_handle*); static int evaluate_long(grib_expression*,grib_handle*,long*); @@ -54,12 +54,12 @@ typedef struct grib_expression_logical_and{ static grib_expression_class _grib_expression_class_logical_and = { - 0, /* super */ - "logical_and", /* name */ - sizeof(grib_expression_logical_and),/* size of instance */ + 0, /* super */ + "logical_and", /* name */ + sizeof(grib_expression_logical_and),/* size of instance */ 0, /* inited */ - 0, /* constructor */ - &destroy, /* destructor */ + 0, /* constructor */ + &destroy, /* destructor */ &print, &add_dependency, &native_type, diff --git a/src/grib_expression_class_logical_or.cc b/src/grib_expression_class_logical_or.cc index aed0618f3..88867f35f 100644 --- a/src/grib_expression_class_logical_or.cc +++ b/src/grib_expression_class_logical_or.cc @@ -39,7 +39,7 @@ or edit "expression.class" and rerun ./make_class.pl typedef const char* string; /* to keep make_class.pl happy */ static void destroy(grib_context*,grib_expression* e); -static void print(grib_context*,grib_expression*,grib_handle*,FILE*); +static void print(grib_context*, grib_expression*, grib_handle*, FILE*); static void add_dependency(grib_expression* e, grib_accessor* observer); static int native_type(grib_expression*,grib_handle*); static int evaluate_long(grib_expression*,grib_handle*,long*); @@ -54,12 +54,12 @@ typedef struct grib_expression_logical_or{ static grib_expression_class _grib_expression_class_logical_or = { - 0, /* super */ - "logical_or", /* name */ - sizeof(grib_expression_logical_or),/* size of instance */ + 0, /* super */ + "logical_or", /* name */ + sizeof(grib_expression_logical_or),/* size of instance */ 0, /* inited */ - 0, /* constructor */ - &destroy, /* destructor */ + 0, /* constructor */ + &destroy, /* destructor */ &print, &add_dependency, &native_type, diff --git a/src/grib_expression_class_long.cc b/src/grib_expression_class_long.cc index 774f736e6..946e6456d 100644 --- a/src/grib_expression_class_long.cc +++ b/src/grib_expression_class_long.cc @@ -38,7 +38,7 @@ or edit "expression.class" and rerun ./make_class.pl typedef const char* string; /* to keep make_class.pl happy */ static void destroy(grib_context*,grib_expression* e); -static void print(grib_context*,grib_expression*,grib_handle*,FILE*); +static void print(grib_context*, grib_expression*, grib_handle*, FILE*); static void add_dependency(grib_expression* e, grib_accessor* observer); static int native_type(grib_expression*,grib_handle*); static int evaluate_long(grib_expression*,grib_handle*,long*); @@ -52,12 +52,12 @@ typedef struct grib_expression_long{ static grib_expression_class _grib_expression_class_long = { - 0, /* super */ - "long", /* name */ - sizeof(grib_expression_long),/* size of instance */ + 0, /* super */ + "long", /* name */ + sizeof(grib_expression_long),/* size of instance */ 0, /* inited */ - 0, /* constructor */ - &destroy, /* destructor */ + 0, /* constructor */ + &destroy, /* destructor */ &print, &add_dependency, &native_type, diff --git a/src/grib_expression_class_string.cc b/src/grib_expression_class_string.cc index 379140de7..a085ed69e 100644 --- a/src/grib_expression_class_string.cc +++ b/src/grib_expression_class_string.cc @@ -37,7 +37,7 @@ or edit "expression.class" and rerun ./make_class.pl typedef const char* string; /* to keep make_class.pl happy */ static void destroy(grib_context*,grib_expression* e); -static void print(grib_context*,grib_expression*,grib_handle*,FILE*); +static void print(grib_context*, grib_expression*, grib_handle*, FILE*); static void add_dependency(grib_expression* e, grib_accessor* observer); static int native_type(grib_expression*,grib_handle*); static string evaluate_string(grib_expression*,grib_handle*,char*,size_t*,int*); @@ -50,12 +50,12 @@ typedef struct grib_expression_string{ static grib_expression_class _grib_expression_class_string = { - 0, /* super */ - "string", /* name */ - sizeof(grib_expression_string),/* size of instance */ + 0, /* super */ + "string", /* name */ + sizeof(grib_expression_string),/* size of instance */ 0, /* inited */ - 0, /* constructor */ - &destroy, /* destructor */ + 0, /* constructor */ + &destroy, /* destructor */ &print, &add_dependency, &native_type, diff --git a/src/grib_expression_class_string_compare.cc b/src/grib_expression_class_string_compare.cc index ac54cb6d2..603846b7b 100644 --- a/src/grib_expression_class_string_compare.cc +++ b/src/grib_expression_class_string_compare.cc @@ -40,7 +40,7 @@ or edit "expression.class" and rerun ./make_class.pl typedef const char* string; /* to keep make_class.pl happy */ static void destroy(grib_context*,grib_expression* e); -static void print(grib_context*,grib_expression*,grib_handle*,FILE*); +static void print(grib_context*, grib_expression*, grib_handle*, FILE*); static void add_dependency(grib_expression* e, grib_accessor* observer); static int native_type(grib_expression*,grib_handle*); static int evaluate_long(grib_expression*,grib_handle*,long*); @@ -56,12 +56,12 @@ typedef struct grib_expression_string_compare{ static grib_expression_class _grib_expression_class_string_compare = { - 0, /* super */ - "string_compare", /* name */ - sizeof(grib_expression_string_compare),/* size of instance */ + 0, /* super */ + "string_compare", /* name */ + sizeof(grib_expression_string_compare),/* size of instance */ 0, /* inited */ - 0, /* constructor */ - &destroy, /* destructor */ + 0, /* constructor */ + &destroy, /* destructor */ &print, &add_dependency, &native_type, diff --git a/src/grib_expression_class_sub_string.cc b/src/grib_expression_class_sub_string.cc index dd44ec323..8ed6c3dff 100644 --- a/src/grib_expression_class_sub_string.cc +++ b/src/grib_expression_class_sub_string.cc @@ -37,7 +37,7 @@ or edit "expression.class" and rerun ./make_class.pl typedef const char* string; /* to keep make_class.pl happy */ static void destroy(grib_context*,grib_expression* e); -static void print(grib_context*,grib_expression*,grib_handle*,FILE*); +static void print(grib_context*, grib_expression*, grib_handle*, FILE*); static void add_dependency(grib_expression* e, grib_accessor* observer); static int native_type(grib_expression*,grib_handle*); static string evaluate_string(grib_expression*,grib_handle*,char*,size_t*,int*); @@ -50,12 +50,12 @@ typedef struct grib_expression_sub_string{ static grib_expression_class _grib_expression_class_sub_string = { - 0, /* super */ - "sub_string", /* name */ - sizeof(grib_expression_sub_string),/* size of instance */ + 0, /* super */ + "sub_string", /* name */ + sizeof(grib_expression_sub_string),/* size of instance */ 0, /* inited */ - 0, /* constructor */ - &destroy, /* destructor */ + 0, /* constructor */ + &destroy, /* destructor */ &print, &add_dependency, &native_type, diff --git a/src/grib_expression_class_true.cc b/src/grib_expression_class_true.cc index 382dec868..41f3a40ae 100644 --- a/src/grib_expression_class_true.cc +++ b/src/grib_expression_class_true.cc @@ -37,7 +37,7 @@ or edit "expression.class" and rerun ./make_class.pl typedef const char* string; /* to keep make_class.pl happy */ static void destroy(grib_context*,grib_expression* e); -static void print(grib_context*,grib_expression*,grib_handle*,FILE*); +static void print(grib_context*, grib_expression*, grib_handle*, FILE*); static void add_dependency(grib_expression* e, grib_accessor* observer); static int native_type(grib_expression*,grib_handle*); static int evaluate_long(grib_expression*,grib_handle*,long*); @@ -50,12 +50,12 @@ typedef struct grib_expression_true{ static grib_expression_class _grib_expression_class_true = { - 0, /* super */ - "true", /* name */ - sizeof(grib_expression_true),/* size of instance */ + 0, /* super */ + "true", /* name */ + sizeof(grib_expression_true),/* size of instance */ 0, /* inited */ - 0, /* constructor */ - &destroy, /* destructor */ + 0, /* constructor */ + &destroy, /* destructor */ &print, &add_dependency, &native_type, @@ -83,8 +83,7 @@ static int evaluate_double(grib_expression* g, grib_handle* h, double* dres) static void print(grib_context* c, grib_expression* g, grib_handle* f, FILE* out) { - fprintf(out, "true("); - fprintf(out, ")"); + fprintf(out, "true()"); } static void destroy(grib_context* c, grib_expression* g) @@ -103,7 +102,6 @@ grib_expression* new_true_expression(grib_context* c) return (grib_expression*)e; } - static int native_type(grib_expression* g, grib_handle* h) { return GRIB_TYPE_LONG; diff --git a/src/grib_expression_class_unop.cc b/src/grib_expression_class_unop.cc index 0de77a02d..18eb073fb 100644 --- a/src/grib_expression_class_unop.cc +++ b/src/grib_expression_class_unop.cc @@ -41,7 +41,7 @@ or edit "expression.class" and rerun ./make_class.pl typedef const char* string; /* to keep make_class.pl happy */ static void destroy(grib_context*,grib_expression* e); -static void print(grib_context*,grib_expression*,grib_handle*,FILE*); +static void print(grib_context*, grib_expression*, grib_handle*, FILE*); static void add_dependency(grib_expression* e, grib_accessor* observer); static string get_name(grib_expression* e); static int native_type(grib_expression*,grib_handle*); @@ -58,12 +58,12 @@ typedef struct grib_expression_unop{ static grib_expression_class _grib_expression_class_unop = { - 0, /* super */ - "unop", /* name */ - sizeof(grib_expression_unop),/* size of instance */ + 0, /* super */ + "unop", /* name */ + sizeof(grib_expression_unop),/* size of instance */ 0, /* inited */ - 0, /* constructor */ - &destroy, /* destructor */ + 0, /* constructor */ + &destroy, /* destructor */ &print, &add_dependency, &native_type, diff --git a/src/grib_fieldset.cc b/src/grib_fieldset.cc index 72cb928c6..a37013844 100644 --- a/src/grib_fieldset.cc +++ b/src/grib_fieldset.cc @@ -55,7 +55,7 @@ static int grib_fieldset_set_order_by(grib_fieldset* set, grib_order_by* ob); /* --------------- grib_column functions ------------------*/ -int grib_fieldset_new_column(grib_fieldset* set, int id, char* key, int type) +static int grib_fieldset_new_column(grib_fieldset* set, int id, char* key, int type) { grib_column* column = NULL; grib_context* c; diff --git a/src/grib_iterator_class_lambert_conformal.cc b/src/grib_iterator_class_lambert_conformal.cc index fe261b5be..fa002c18b 100644 --- a/src/grib_iterator_class_lambert_conformal.cc +++ b/src/grib_iterator_class_lambert_conformal.cc @@ -295,7 +295,7 @@ static int init_oblate(const grib_handle* h, double ns; // ratio of angle between meridian double F; // flattening of ellipsoid - double rh; // height above ellipsoid + double rh; // height above ellipsoid double sin_po; // sin value double cos_po; // cos value double con; // temporary variable diff --git a/src/grib_trie.cc b/src/grib_trie.cc index c4e1d29e5..85f246e2d 100644 --- a/src/grib_trie.cc +++ b/src/grib_trie.cc @@ -437,11 +437,7 @@ void* grib_trie_insert_no_replace(grib_trie* t, const char* key, void* data) { grib_trie* last = t; const char* k = key; - - if (!t) { - Assert(!"grib_trie_insert_no_replace: grib_trie==NULL"); - return NULL; - } + Assert(t); while (*k && t) { last = t; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d4fc34dbf..40c1b2f2b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -99,7 +99,6 @@ if( HAVE_BUILD_TOOLS ) grib_calendar grib_md5 grib_cfNames - grib_ifsParam grib_packing_order filter_substr filter_contains @@ -107,7 +106,6 @@ if( HAVE_BUILD_TOOLS ) filter_is_one_of filter_is_in_list filter_transient_darray - grib_uerra grib_ecpoint grib_s2s grib_fire @@ -190,9 +188,11 @@ if( HAVE_BUILD_TOOLS ) grib_partial_message grib_true_imagery grib_headers_only + grib_uerra grib_unpack_subarray grib_count grib_clone_headers_only + grib_ifsParam wmo_read_bufr_from_file wmo_read_gts_from_file wmo_read_any_from_file @@ -276,6 +276,7 @@ if( HAVE_BUILD_TOOLS ) grib_ecc-1467 grib_ecc-1764 grib_ecc-1792 + grib_ecc-1907 grib_modelName grib_sub_hourly grib_set_bytes diff --git a/tests/bufr_filter_misc.sh b/tests/bufr_filter_misc.sh index f2021a3f5..accdae9b3 100755 --- a/tests/bufr_filter_misc.sh +++ b/tests/bufr_filter_misc.sh @@ -119,7 +119,7 @@ for statid in 1 3 7 ; do done #----------------------------------------------------------- -# Test: print attributes +# Test: print attributes #----------------------------------------------------------- cat > $fRules < $fRules < $fRules < $fRules < $fRules < $fRules < $fRules < $fRules < $fRules <> $fLog 1>> $fLog rm -f $fout #----------------------------------------------------------- -# Test: access subsets by condition +# Test: access subsets by condition #----------------------------------------------------------- cat > $fRules < $fRules < $fRules < $fRules < $fRules < $fRules < $fRules < $fRules < $fRules < $fRules <$fRules <$fRules < #include "eccodes.h" +static ProductKind get_product_kind(const char* p) +{ + if (strcmp(p, "GRIB") == 0) return PRODUCT_GRIB; + if (strcmp(p, "BUFR") == 0) return PRODUCT_BUFR; + if (strcmp(p, "METAR") == 0) return PRODUCT_METAR; + if (strcmp(p, "GTS") == 0) return PRODUCT_GTS; + return PRODUCT_ANY; +} + int main(int argc, char** argv) { int err = 0; codes_context* c = codes_context_get_default(); - assert(argc == 2); + assert(argc == 3); + + const ProductKind mode = get_product_kind( argv[1] ); + const char* filename = argv[2]; - char* filename = argv[1]; FILE* fp = fopen(filename, "rb"); assert(fp); - codes_handle* h = codes_handle_new_from_file(c, fp, PRODUCT_ANY, &err); + + codes_handle* h = codes_handle_new_from_file(c, fp, mode, &err); assert(h); assert(!err); diff --git a/tests/codes_dump_action_tree.sh b/tests/codes_dump_action_tree.sh index ad562c9e5..fbc2bbf24 100755 --- a/tests/codes_dump_action_tree.sh +++ b/tests/codes_dump_action_tree.sh @@ -10,5 +10,16 @@ . ./include.ctest.sh -input=$ECCODES_SAMPLES_PATH/GRIB2.tmpl -$EXEC ${test_dir}/codes_dump_action_tree "$input" +for f in GRIB1.tmpl GRIB2.tmpl sh_sfc_grib1.tmpl sh_sfc_grib2.tmpl; do + input=$ECCODES_SAMPLES_PATH/$f + $EXEC ${test_dir}/codes_dump_action_tree GRIB "$input" > /dev/null +done + +input=$ECCODES_SAMPLES_PATH/BUFR4.tmpl +$EXEC ${test_dir}/codes_dump_action_tree BUFR "$input" > /dev/null + +input=$data_dir/metar/metar.txt +$EXEC ${test_dir}/codes_dump_action_tree METAR "$input" > /dev/null + +input=$data_dir/gts/EGRR20150317121020_00493212.DAT +$EXEC ${test_dir}/codes_dump_action_tree GTS "$input" > /dev/null diff --git a/tests/codes_set_samples_path.cc b/tests/codes_set_samples_path.cc index dbcff4ed7..9204560d2 100644 --- a/tests/codes_set_samples_path.cc +++ b/tests/codes_set_samples_path.cc @@ -9,6 +9,7 @@ */ #include "grib_api_internal.h" +#include "eccodes.h" /* Windows always has a colon in pathnames e.g. C:\temp\file. So instead we use semi-colons as delimiter */ /* in order to have multiple definitions/samples directories */ @@ -32,6 +33,7 @@ int main(int argc, char** argv) sample_name = argv[1]; new_dir = argv[2]; /* The directory containing the given sample */ + codes_context_set_debug(c, -1); printf("Initial samples path = %s\n", grib_samples_path(c)); /* Should fail - default samples path does not include ifs_samples dirs */ @@ -40,7 +42,9 @@ int main(int argc, char** argv) snprintf(full_path, 2048, "%s%c%s", new_dir, ECC_PATH_DELIMITER_CHAR, grib_samples_path(c)); printf("Change samples_path to: %s\n", full_path); - grib_context_set_samples_path(c, full_path); + codes_context_set_samples_path(c, full_path); + + codes_context_set_debug(c, 0); h = grib_handle_new_from_samples(c, sample_name); Assert(h); diff --git a/tests/definitions.sh b/tests/definitions.sh index 3842fa973..f090c1265 100755 --- a/tests/definitions.sh +++ b/tests/definitions.sh @@ -16,7 +16,9 @@ tempOut=temp.$label.txt [ -z "$ECCODES_DEFINITION_PATH" ] || ECCODES_DEFINITION_PATH=`${tools_dir}/codes_info -d` -for file in `find ${ECCODES_DEFINITION_PATH}/ -name '*.def' -print | grep -v grib3/ | grep -v metar/ | grep -v taf/` +# Ignore symbolic links +# Ignore unsupported formats e.g., TAF, METAR +for file in `find ${ECCODES_DEFINITION_PATH}/ -name '*.def' -type f -print | grep -v grib3/ | grep -v metar/ | grep -v taf/` do ${bin_dir}/codes_parser $file > $REDIRECT done @@ -29,4 +31,5 @@ set -e [ $status -ne 0 ] grep -q "Parser: syntax error" $tempOut +# Clean up rm -f $tempOut diff --git a/tests/grib1_gds_not_present.sh b/tests/grib1_gds_not_present.sh index 36fffae56..9ce644cbf 100755 --- a/tests/grib1_gds_not_present.sh +++ b/tests/grib1_gds_not_present.sh @@ -17,7 +17,16 @@ tempGrib=temp.$label.grib input=$data_dir/reduced_latlon_surface.grib1 ${tools_dir}/grib_set -s gridDescriptionSectionPresent=0 $input $tempGrib +result=`${tools_dir}/grib_get -fp Ni,Nj $tempGrib` +[ "$result" = "not_found not_found" ] + ${tools_dir}/grib_dump $tempGrib > $REDIRECT 2>&1 +# ${tools_dir}/grib_get -n statistics $tempGrib + +max=`${tools_dir}/grib_get -F%.3f -p max $input` +min=`${tools_dir}/grib_get -F%.3f -p min $input` +[ "$max" = "12.597" ] +[ "$min" = "0.019" ] # Clean up rm -f $tempGrib diff --git a/tests/grib1to2.sh b/tests/grib1to2.sh index d050c32ff..46a73ecd6 100755 --- a/tests/grib1to2.sh +++ b/tests/grib1to2.sh @@ -116,6 +116,10 @@ sample_g1=$ECCODES_SAMPLES_PATH/GRIB1.tmpl output=temp.grib1to2.grib ECCODES_DEBUG=-1 ${tools_dir}/grib_set -s edition=2 $sample_g1 $output +# -G option +sample_g1=$ECCODES_SAMPLES_PATH/GRIB1.tmpl +${tools_dir}/grib_set -G -s edition=2 $sample_g1 $temp2 + # Clean up rm -f $output diff --git a/tests/grib2_wave_spectra.sh b/tests/grib2_wave_spectra.sh index ea465b04b..336b6341a 100755 --- a/tests/grib2_wave_spectra.sh +++ b/tests/grib2_wave_spectra.sh @@ -15,6 +15,9 @@ temp=temp.$label tempGribA=temp.$label.A.grib tempGribB=temp.$label.B.grib tempSample=temp.$label.tmpl +tempRef=temp.$label.ref +tempOut=temp.$label.txt + sample2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl latest=`${tools_dir}/grib_get -p tablesVersionLatest $sample2` @@ -23,9 +26,23 @@ latest=`${tools_dir}/grib_get -p tablesVersionLatest $sample2` ${tools_dir}/grib_set -s tablesVersion=$latest,productDefinitionTemplateNumber=99 $sample2 $tempSample ${tools_dir}/grib_set -s numberOfWaveDirections=3,numberOfWaveFrequencies=3 $tempSample $temp +# ECC-1906 +# -------- +${tools_dir}/grib_set -s productDefinitionTemplateNumber=99,numberOfWaveDirections=5 $sample2 $tempGribA +echo 'print "[numberOfWaveDirections=] [scaledValuesOfWaveDirections=!0]";' | ${tools_dir}/grib_filter - $tempGribA > $tempOut +cat > $tempRef <$outfile 2>&1 +status=$? +set -e +[ $status -eq 1 ] +grep -q "Invalid absolute error" $outfile + # ---------------------------------------- # ECC-355: -R with "all" option @@ -175,6 +182,12 @@ ${tools_dir}/grib_compare -b $BLACKLIST -R all=2 $temp1 $temp2 cp ${data_dir}/tigge_cf_ecmwf.grib2 $temp1 ${tools_dir}/grib_compare -w typeOfLevel=surface ${data_dir}/tigge_cf_ecmwf.grib2 $temp1 + +# ---------------------------------------- +# Use -T switch +# ---------------------------------------- +${tools_dir}/grib_compare -T5 ${data_dir}/tigge_cf_ecmwf.grib2 ${data_dir}/tigge_cf_ecmwf.grib2 + # ---------------------------------------- # Summary mode (-f) # ---------------------------------------- @@ -280,20 +293,48 @@ status=$? set -e [ $status -eq 1 ] +# ---------------------------------------- +# Through index using -S and -E +# ---------------------------------------- +tempIndex1=temp.$label.1.idx +tempIndex2=temp.$label.2.idx +${tools_dir}/grib_index_build -o $tempIndex1 -N -k time,date $data_dir/tigge_ecmwf.grib2 +${tools_dir}/grib_index_build -o $tempIndex2 -N -k time,date $data_dir/tigge_cf_ecmwf.grib2 +set +e +${tools_dir}/grib_compare -S 4 -E 5 $tempIndex1 $tempIndex2 +status=$? +set -e +[ $status -ne 0 ] +# Key unpackedValues +#------------------- +${tools_dir}/grib_set -s scaleValuesBy=1.01 $ECCODES_SAMPLES_PATH/sh_ml_grib2.tmpl $temp1 +${tools_dir}/grib_compare -c unpackedValues -A 1.86 $ECCODES_SAMPLES_PATH/sh_ml_grib2.tmpl $temp1 + + +# ----------------- # Failing cases # ----------------- set +e -${tools_dir}/grib_compare -H -c data:n $temp1 $temp2 +${tools_dir}/grib_compare -Rxxxx $temp1 $temp2 > $outfile 2>&1 status=$? set -e [ $status -eq 1 ] +grep "Invalid argument" $outfile set +e -${tools_dir}/grib_compare -a $temp1 $temp2 +${tools_dir}/grib_compare -H -c data:n $temp1 $temp2 > $outfile 2>&1 status=$? set -e [ $status -eq 1 ] +grep -q "options are incompatible" $outfile + +set +e +${tools_dir}/grib_compare -a $temp1 $temp2 > $outfile 2>&1 +status=$? +set -e +[ $status -eq 1 ] +grep -q "a option requires -c option" $outfile echo GRIB > $temp1 diff --git a/tests/grib_dump_samples.sh b/tests/grib_dump_samples.sh index ba4f7d870..740750ba2 100755 --- a/tests/grib_dump_samples.sh +++ b/tests/grib_dump_samples.sh @@ -61,5 +61,10 @@ for s in $g2_samples; do grib_check_key_equals $sf "edition,packingType" "2 grid_ccsds" done +# Test dump_bits +sample_polar="$ECCODES_SAMPLES_PATH/polar_stereographic_pl_grib2.tmpl" +${tools_dir}/grib_dump $sample_polar > $temp +grep -q "resolutionAndComponentFlags" $temp +# Clean up rm -f $temp diff --git a/tests/grib_ecc-1907.sh b/tests/grib_ecc-1907.sh new file mode 100755 index 000000000..e24cca742 --- /dev/null +++ b/tests/grib_ecc-1907.sh @@ -0,0 +1,60 @@ +#!/bin/sh +# (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. +# + +. ./include.ctest.sh + +label="grib_ecc-1907_test" +tempGrib1=temp.$label.grib1 +tempGrib2=temp.$label.grib2 +tempFilt=temp.$label.filt +tempLog=temp.$label.log +tempOut=temp.$label.txt +tempRef=temp.$label.ref + +sample_grib1=$ECCODES_SAMPLES_PATH/GRIB1.tmpl + +cat >$tempFilt< $tempOut ${tools_dir}/grib_ls -l 40.44,353.56 $tempGrib +# Error conditions +# ---------------- +set +e +${tools_dir}/grib_get_data -s Latin1=5000,Latin2=-5000 $tempGrib > $tempOut 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Cannot have equal latitudes for standard parallels on opposite sides of equator" $tempOut + + +set +e +${tools_dir}/grib_get_data -s Ni=8 $tempGrib > $tempOut 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Wrong number of points" $tempOut + + + # Clean up rm -f $tempFilt $tempGrib $tempOut diff --git a/tests/grib_grid_mercator.sh b/tests/grib_grid_mercator.sh index 825262b29..2be01a3fb 100755 --- a/tests/grib_grid_mercator.sh +++ b/tests/grib_grid_mercator.sh @@ -32,11 +32,30 @@ cat > $tempFilt < $tempOut # Nearest function ${tools_dir}/grib_ls -l 19,-97,1 $input > $tempOut grep -q "Point chosen #1 index=618" $tempOut +# Error conditions +# ---------------- +input=${data_dir}/mercator.grib2 +set +e +${tools_dir}/grib_get_data -s latitudeOfFirstGridPointInDegrees=90 $input > $tempOut 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Transformation cannot be computed at the poles" $tempOut + +input=${data_dir}/mercator.grib2 +set +e +${tools_dir}/grib_get_data -s Ni=1 $input > $tempOut 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Wrong number of points" $tempOut + + # Clean up rm -f $tempFilt $tempOut diff --git a/tests/grib_grid_polar_stereographic.sh b/tests/grib_grid_polar_stereographic.sh index b426b34fe..e0f27cbdb 100755 --- a/tests/grib_grid_polar_stereographic.sh +++ b/tests/grib_grid_polar_stereographic.sh @@ -29,6 +29,24 @@ ${tools_dir}/grib_ls -l 60,0 $input # Scanning mode ${tools_dir}/grib_get_data -s iScansNegatively=1 $input > $tempOut +# Failing case +# ------------- +${tools_dir}/grib_set -s shapeOfTheEarth=2 $input $tempGrib # oblate earth +set +e +${tools_dir}/grib_get_data $tempGrib > $tempOut 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Only supported for spherical earth" $tempOut + +# Bad geography +set +e +${tools_dir}/grib_get_data -s Nx=1 $input > $tempOut 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Wrong number of points" $tempOut + # Clean up rm -f $tempFilt $tempGrib $tempOut diff --git a/tests/grib_grid_space_view.sh b/tests/grib_grid_space_view.sh index 03407053d..ff00db519 100755 --- a/tests/grib_grid_space_view.sh +++ b/tests/grib_grid_space_view.sh @@ -50,6 +50,14 @@ ${tools_dir}/grib_get_data $tempGrib2 > $tempOut ${tools_dir}/grib_ls -l 50,0 $tempGrib2 # Invalid cases +# -------------- +set +e +${tools_dir}/grib_get_data -s Nx=1 $tempGrib2 > $tempOut 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Wrong number of points" $tempOut + set +e ${tools_dir}/grib_get_data -sNr=missing $tempGrib2 > $tempOut 2>&1 status=$? @@ -64,6 +72,22 @@ set -e [ $status -ne 0 ] grep -q "must be greater than zero" $tempOut + +set +e +${tools_dir}/grib_get_data -s latitudeOfSubSatellitePoint=66 $tempGrib2 > $tempOut 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "satellite must be located in the equator plane" $tempOut + + +set +e +${tools_dir}/grib_get_data -s dx=0 $tempGrib2 > $tempOut 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Keys dx and dy must be greater than zero" $tempOut + rm -f $tempGrib2 $tempOut # ----------- diff --git a/tests/grib_iterator.sh b/tests/grib_iterator.sh index 240107ee7..2601838ff 100755 --- a/tests/grib_iterator.sh +++ b/tests/grib_iterator.sh @@ -153,6 +153,22 @@ input=$ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib2.tmpl ECCODES_DEBUG=1 ${tools_dir}/grib_get_data $input > $tempText 2>&1 grep "global num points=6114" $tempText +# Bad -s +set +e +${tools_dir}/grib_get_data -s blah=999 $data_dir/sample.grib2 > $tempText 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Key/value not found" $tempText + +# Bad -p +set +e +${tools_dir}/grib_get_data -f -p values $data_dir/sample.grib2 > $tempText 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Passed array is too small" $tempText + # Clean up rm -f $tempText $tempGrib diff --git a/tests/grib_lam_bf.cc b/tests/grib_lam_bf.cc index c7170a192..7a575e68c 100644 --- a/tests/grib_lam_bf.cc +++ b/tests/grib_lam_bf.cc @@ -860,7 +860,7 @@ int main(int argc, char* argv[]) geometry_len = 128; GRIB_CHECK(grib_get_string(h, "gridType", geometry, &geometry_len), 0); if (strcmp(geometry, grids[igrid])) { - printf("Geometry is incorrect\n"); + fprintf(stderr, "Geometry is incorrect\n"); return 1; } diff --git a/tests/grib_step.sh b/tests/grib_step.sh index 0e0ddebda..9fc7f9abe 100755 --- a/tests/grib_step.sh +++ b/tests/grib_step.sh @@ -128,7 +128,7 @@ grib_check_key_equals $temp typeOfTimeIncrement 2 ${tools_dir}/grib_set -s stepType=avg,typeOfTimeIncrement=255 $grib2_sample $temp grib_check_key_equals $temp stepType avg ${tools_dir}/grib_set -s stepType=avg $grib2_sample $temp -grib_check_key_equals $temp typeOfTimeIncrement 3 +grib_check_key_equals $temp typeOfTimeIncrement 2 # default is 2 # Decode/Encode stepRange as an int and double ${tools_dir}/grib_set -s stepType=accum,stepRange=23-28 $grib2_sample $temp diff --git a/tests/grib_threads_ecc-604-encode.cc b/tests/grib_threads_ecc-604-encode.cc index 0f2e37560..33a767206 100644 --- a/tests/grib_threads_ecc-604-encode.cc +++ b/tests/grib_threads_ecc-604-encode.cc @@ -26,19 +26,24 @@ int opt_write = 0; /* If 1 write handle to file */ static int encode_values(grib_handle* h, char* output_file) { - double* values; - const size_t DIM = 1000; - size_t size = DIM * DIM; - size_t i = 0; - values = (double*)malloc(size * sizeof(double)); - for (i = 0; i < size; ++i) { + double* values = NULL; + long numberOfDataPoints = 0; + GRIB_CHECK(grib_get_long(h, "numberOfDataPoints", &numberOfDataPoints), 0); + size_t size = numberOfDataPoints; + + values = (double*)malloc(size * sizeof(double)); + for (size_t i = 0; i < size; ++i) { double v = i; - if (i % DIM == 0) v = 0; + if (i % size == 0) v = 0; values[i] = v; } GRIB_CHECK(grib_set_long(h, "bitsPerValue", 16), 0); GRIB_CHECK(grib_set_double_array(h, "values", values, size), 0); free(values); + if (opt_dump) { + FILE* devnull = fopen("/dev/null", "w"); + grib_dump_content(h, devnull, "wmo", 0, NULL); + } return GRIB_SUCCESS; } @@ -62,6 +67,7 @@ int main(int argc, char** argv) char* mode; 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, "Options:\n\t-d: do a dump\n\t-c: clone\n"); return 1; } @@ -144,7 +150,12 @@ void do_encode(void* ptr) hs = grib_handle_new_from_samples(0, INPUT_FILE); 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) { snprintf(output_file, 50, "output/output_file_%zu-%zu.grib", data->number, i); encode_values(h, output_file); @@ -152,7 +163,8 @@ void do_encode(void* ptr) else { encode_values(h, NULL); } - grib_handle_delete(h); + if (opt_clone) + grib_handle_delete(h); } ltime = time(NULL); diff --git a/tests/grib_to_netcdf.sh b/tests/grib_to_netcdf.sh index 5e1aaf015..2baf0b352 100755 --- a/tests/grib_to_netcdf.sh +++ b/tests/grib_to_netcdf.sh @@ -104,8 +104,23 @@ echo "Test shuffle and deflate ..." if [ $have_netcdf4 -eq 1 ]; then input=${data_dir}/sst_globus0083.grib ${tools_dir}/grib_to_netcdf -s -d9 -k4 -o $tempNetcdf $input + + set +e + ${tools_dir}/grib_to_netcdf -s -o $tempNetcdf $input > $tempText 2>&1 + status=$? + set -e + [ $status -ne 0 ] + grep -q "Invalid shuffle option. Deflate option needed" $tempText + + set +e + ${tools_dir}/grib_to_netcdf -s -dy -o $tempNetcdf $input > $tempText 2>&1 + status=$? + set -e + [ $status -ne 0 ] + grep -q "Invalid number" $tempText fi + echo "Test ECC-1060 ..." # ---------------------- sample2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl @@ -117,7 +132,8 @@ ${tools_dir}/grib_to_netcdf -o $tempNetcdf $tempGrib ECCODES_DEBUG=-1 ${tools_dir}/grib_to_netcdf -o $tempNetcdf $tempGrib -# The -u option +echo "Test -u option ..." +# ---------------------- input=${data_dir}/sample.grib2 ${tools_dir}/grib_to_netcdf -u time -o $tempNetcdf $input @@ -147,6 +163,25 @@ ${tools_dir}/grib_to_netcdf -o $tempNetcdf $tempDir > $tempText grep -q "Processing input file .*/subdir/regular_latlon_surface.grib2" $tempText rm -rf $tempDir +echo "Test non-numeric dates ..." +# ------------------------------------ +sample1=$ECCODES_SAMPLES_PATH/GRIB1.tmpl +${tools_dir}/grib_set -s class=ei,type=em,yearOfCentury=255,month=3,day=20 $sample1 $tempGrib +grib_check_key_equals $tempGrib 'dataDate:s' 'mar-20' +${tools_dir}/grib_to_netcdf -o $tempNetcdf $tempGrib + + +echo "Test -S option..." +# ------------------------------------ +input=${data_dir}/high_level_api.grib2 +${tools_dir}/grib_to_netcdf -o $tempNetcdf -S param $input + +echo "Test -I option..." +# ------------------------------------ +input=${data_dir}/high_level_api.grib2 +${tools_dir}/grib_to_netcdf -o $tempNetcdf -S method $input + + echo "Enable/Disable Checks ..." # --------------------------------- rm -f $tempNetcdf @@ -172,6 +207,16 @@ set -e grep -q "not on a regular lat/lon grid or on a regular Gaussian grid" $tempText +echo "No output ..." +# -------------------------- +set +e +${tools_dir}/grib_to_netcdf $input > $tempText 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "No output file" $tempText + + # ECC-1783: No error message when input file has invalid fields input=$data_dir/bad.grib set +e @@ -201,6 +246,24 @@ set -e [ $status -ne 0 ] grep -q "Invalid reference date" $tempText +# Bad -k option +input=$data_dir/sample.grib2 +set +e +${tools_dir}/grib_to_netcdf -k hallo -o $tempNetcdf $input > $tempText 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Invalid value" $tempText + +# Bad -d option +input=$data_dir/sample.grib2 +set +e +${tools_dir}/grib_to_netcdf -d 999 -o $tempNetcdf $input > $tempText 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Invalid deflate option" $tempText + # Validity time check export GRIB_TO_NETCDF_CHECKVALIDTIME=0 diff --git a/tests/grib_util_set_spec.cc b/tests/grib_util_set_spec.cc index e47672868..095eb7135 100644 --- a/tests/grib_util_set_spec.cc +++ b/tests/grib_util_set_spec.cc @@ -357,25 +357,24 @@ static void test_grid_complex_spatial_differencing(int remove_local_def, int edi } #endif -static void usage(const char* prog) -{ - fprintf(stderr, "%s: [-p packingType] [-r] [-e edition] in.grib out.grib\n", prog); - fprintf(stderr, "-p packingType: one of grid_jpeg, grid_ccsds, grid_second_order or grid_simple\n"); - fprintf(stderr, "-r remove local definition\n"); - fprintf(stderr, "-e edition: 1 or 2\n"); - exit(1); -} +// static void usage(const char* prog) +// { +// fprintf(stderr, "%s: [-p packingType] [-r] [-e edition] in.grib out.grib\n", prog); +// fprintf(stderr, "-p packingType: one of grid_jpeg, grid_ccsds, grid_second_order or grid_simple\n"); +// fprintf(stderr, "-r remove local definition\n"); +// fprintf(stderr, "-e edition: 1 or 2\n"); +// exit(1); +// } int main(int argc, char* argv[]) { int i = 0, remove_local_def = 0; int edition = 0; char* packingType = NULL; - const char* prog = argv[0]; char* infile_name = NULL; char* outfile_name = NULL; - if (argc == 1 || argc > 8) usage(prog); + if (argc == 1 || argc > 8) return 1;// see usage for (i = 1; i < argc; i++) { if (strcmp(argv[i], "-p") == 0) { diff --git a/tests/gts_compare.sh b/tests/gts_compare.sh index 678d8b571..c4c217b8d 100755 --- a/tests/gts_compare.sh +++ b/tests/gts_compare.sh @@ -31,6 +31,8 @@ echo "Test: comparing the same files" >> $fLog echo "file: $gts_file" >> $fLog ${tools_dir}/gts_compare $gts_file $gts_file +${tools_dir}/gts_compare -v -c totalLength $gts_file $gts_file > /dev/null + #---------------------------------------------------- # Test: comparing with skip #---------------------------------------------------- @@ -69,6 +71,7 @@ set -e [ $status -eq 1 ] # Add correct blocklist ${tools_dir}/gts_compare -b GG $gts_file $fGtsTmp +${tools_dir}/gts_compare -b CCCC,GG $gts_file $fGtsTmp #---------------------------------------------------- # Compare using -c @@ -82,13 +85,13 @@ ${tools_dir}/gts_compare -c theMessage $temp1 $temp2 ${tools_dir}/gts_compare -c theMessage -a $temp1 $temp2 set +e -${tools_dir}/gts_compare -c ls:n $temp1 $temp2 +${tools_dir}/gts_compare -c ls:n $temp1 $temp2 > /dev/null status=$? set -e [ $status -eq 1 ] set +e -${tools_dir}/gts_compare -c ls:n -a $temp1 $temp2 +${tools_dir}/gts_compare -c ls:n -a $temp1 $temp2 > /dev/null status=$? set -e [ $status -eq 1 ] diff --git a/tests/read_any.sh b/tests/read_any.sh index f8d1a0ba1..c8972cc03 100755 --- a/tests/read_any.sh +++ b/tests/read_any.sh @@ -13,12 +13,6 @@ infile=${data_dir}/mixed.grib outfile=${data_dir}/read_any.out -#if [ ! -f ${infile} ] -#then -# echo no data to test -# exit 0 -#fi - $EXEC $test_dir/read_any $infile > ${outfile} diff ${outfile} ${data_dir}/read_any.ok @@ -26,10 +20,13 @@ diff ${outfile} ${data_dir}/read_any.ok rm -f ${outfile} count=`${tools_dir}/grib_count ${data_dir}/pad.grib` - if [ $count != 6 ]; then - echo grib_io problem + echo "Error: grib_io problem" exit 1 fi ${tools_dir}/grib_count -v ${data_dir}/pad.grib >/dev/null + +## +$EXEC $test_dir/read_any $ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib1.tmpl +$EXEC $test_dir/read_any $ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib2.tmpl diff --git a/tests/unit_tests.cc b/tests/unit_tests.cc index d1575301a..16e00394c 100644 --- a/tests/unit_tests.cc +++ b/tests/unit_tests.cc @@ -224,8 +224,7 @@ static void test_assertion_catching() printf("Running %s ...\n", __func__); char empty[] = ""; - char** list = 0; - int i = 0; + char** list = NULL; Assert(assertion_caught == 0); codes_set_codes_assertion_failed_proc(&my_assertion_proc); @@ -233,13 +232,14 @@ static void test_assertion_catching() list = string_split(empty, " "); Assert(assertion_caught == 1); + Assert( list == NULL ); /* Restore everything */ codes_set_codes_assertion_failed_proc(NULL); assertion_caught = 0; - for (i = 0; list[i] != NULL; ++i) - free(list[i]); + // for (i = 0; list[i] != NULL; ++i) + // free(list[i]); free(list); } @@ -264,6 +264,16 @@ static void test_logging_proc() Assert(logging_caught == 0); } +static void my_print_proc(const grib_context* c, void* descriptor, const char* mesg) +{ +} +static void test_print_proc() +{ + grib_context* context = grib_context_get_default(); + grib_context_set_print_proc(context, my_print_proc); + grib_context_set_print_proc(context, NULL); +} + static void test_concept_condition_strings() { printf("Running %s ...\n", __func__); @@ -272,6 +282,7 @@ static void test_concept_condition_strings() char result[1024] = {0,}; grib_context* context = NULL; grib_handle* h = grib_handle_new_from_samples(context, "GRIB2"); + if (!h) return; err = get_concept_condition_string(h, "typeOfLevel", NULL, result); Assert(!err); @@ -501,6 +512,13 @@ static void test_parse_keyval_string() free( (void*)values3[0].name ); } +static void test_time_conversions() +{ + printf("Running %s ...\n", __func__); + long result = convert_to_minutes(120, 13); // 120s = 2mins + Assert(result == 2); +} + static void test_dates() { printf("Running %s ...\n", __func__); @@ -752,6 +770,7 @@ void test_codes_context_set_debug() grib_context_set_debug(context, -1); grib_handle* h = grib_handle_new_from_samples(context, "GRIB2"); + if (!h) return; err = grib_set_long(h, "paramId", 167); Assert(!err); @@ -767,9 +786,54 @@ void test_codes_context_set_debug() grib_context_set_debug(context, 0); } +void test_codes_is_feature_enabled() +{ + printf("Running %s ...\n", __func__); + const char* features[] = { + "AEC", + "MEMFS", + "JPG", + "PNG", + "ECCODES_THREADS", + "ECCODES_OMP_THREADS", + "NETCDF", + "FORTRAN", + "GEOGRAPHY", + NULL}; + for (int i = 0; features[i]; ++i) { + const char* f = features[i]; + printf("\tFeature %s enabled?\t%d\n", f, codes_is_feature_enabled(f)); + } + Assert( 0 == codes_is_feature_enabled("total rubbish") ); +} + +void test_codes_get_features() +{ + printf("Running %s ...\n", __func__); + + size_t len = 512; + char* features = (char*)calloc(len, sizeof(char)); + int err = codes_get_features(features, &len, CODES_FEATURES_ALL); + Assert(!err); + printf("\tFeatures are: '%s'\n", features); + + len = 512; + err = codes_get_features(features, &len, CODES_FEATURES_ENABLED); + printf("\tEnabled features are: '%s'\n", features); + + len = 512; + err = codes_get_features(features, &len, CODES_FEATURES_DISABLED); + printf("\tDisabled features are: '%s'\n", features); + + free(features); +} + int main(int argc, char** argv) { printf("Doing unit tests. ecCodes version = %ld\n", grib_get_api_version()); + printf("codes_print_api_version gives: "); + codes_print_api_version(stdout); + printf("\n"); test_codes_context_set_debug(); test_codes_get_error_message(); @@ -783,7 +847,9 @@ int main(int argc, char** argv) test_scale_factor_scaled_values(); test_dates(); + test_time_conversions(); test_logging_proc(); + test_print_proc(); test_grib_binary_search(); test_parse_keyval_string(); @@ -827,6 +893,8 @@ int main(int argc, char** argv) test_grib2_select_PDTN(); test_grib2_choose_PDTN(); + test_codes_is_feature_enabled(); + test_codes_get_features(); return 0; } diff --git a/tests/utils.sh b/tests/utils.sh index a1de94279..8f78e2b44 100644 --- a/tests/utils.sh +++ b/tests/utils.sh @@ -49,3 +49,35 @@ grib_check_key_is_scalar() result=$(echo "print '|[$a_key]|';" | ${tools_dir}/grib_filter - $a_file) [ "$result" = "|$a_val|" ] } + +# This ensures setting the keys via grib_filter (similar to the API, one key at a time) +# works the same way as grib_set. The resultant GRIB outputs are compared +# E.g., +# grib_encode_via_set_and_filter $label key1=val1,key2=val2,key3=val3 $ECCODES_SAMPLES_PATH/GRIB2.tmpl +# +grib_encode_via_set_and_filter() +{ + _label=$1 # For generating temp files + _kvals=$2 # key1=val1,key2=val2 + _input=$3 # Must be a GRIB file + + temp_encode_filt=temp.encode.$_label.filt + temp_encode_gribA=temp.encode.$_label.A.grib + temp_encode_gribB=temp.encode.$_label.B.grib + + for kv in $(echo $_kvals | tr ',' ' '); do + k=$(echo $kv | awk -F= '{print $1}') + v=$(echo $kv | awk -F= '{print $2}') + if [[ "$v" =~ ^[A-z] ]]; then + echo "set $k = \"$v\" ;" >> $temp_encode_filt + else + echo "set $k = $v ;" >> $temp_encode_filt + fi + done + echo "write;" >> $temp_encode_filt + # cat $temp_encode_filt + ${tools_dir}/grib_filter -o $temp_encode_gribA $temp_encode_filt $_input + ${tools_dir}/grib_set -s $_kvals $_input $temp_encode_gribB + ${tools_dir}/grib_compare $temp_encode_gribA $temp_encode_gribB + rm -f $temp_encode_filt $temp_encode_gribB $temp_encode_gribA +} diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index d4b256770..923848fe8 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -96,6 +96,14 @@ else() endif() ######################################## +configure_file( codes_config.in codes_config @ONLY ) +install( FILES ${CMAKE_CURRENT_BINARY_DIR}/codes_config + DESTINATION ${INSTALL_BIN_DIR} + PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ + GROUP_EXECUTE GROUP_READ + WORLD_EXECUTE WORLD_READ ) + + # BUFR compare script install( FILES ${CMAKE_CURRENT_SOURCE_DIR}/bufr_compare_dir DESTINATION ${INSTALL_BIN_DIR} diff --git a/tools/bufr_compare.cc b/tools/bufr_compare.cc index 92e268e77..26ebad36a 100644 --- a/tools/bufr_compare.cc +++ b/tools/bufr_compare.cc @@ -49,17 +49,6 @@ const char* tool_name = "bufr_compare"; const char* tool_online_doc = "https://confluence.ecmwf.int/display/ECC/bufr_compare"; const char* tool_usage = "[options] bufr_file1 bufr_file2"; -GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b) -{ - if (*a != *b) - return 1; - while ((*a != 0 && *b != 0) && *(a) == *(b)) { - a++; - b++; - } - return (*a == 0 && *b == 0) ? 0 : 1; -} - typedef double (*compare_double_proc)(const double*, const double*, const double*); typedef struct grib_error grib_error; @@ -657,7 +646,7 @@ static int strings_are_different(grib_handle* h1, grib_handle* h2, const char* k const char* s1, const char* s2, size_t slen1, size_t slen2) { - if (grib_inline_strcmp(s1, s2) == 0) { + if (strcmp(s1, s2) == 0) { return 0; } /* Strings are different. Now check if strings are 'missing'. diff --git a/tools/codes_config.in b/tools/codes_config.in new file mode 100755 index 000000000..cd5d9c726 --- /dev/null +++ b/tools/codes_config.in @@ -0,0 +1,131 @@ +#!/usr/bin/env bash + +ECCODES_VERSION_STR="@eccodes_VERSION_STR@" +ECCODES_MAJOR_VERSION=@eccodes_VERSION_MAJOR@ +ECCODES_MINOR_VERSION=@eccodes_VERSION_MINOR@ +ECCODES_PATCH_VERSION=@eccodes_VERSION_PATCH@ +# ECCODES_VERSION="$ECCODES_MAJOR_VERSION.$ECCODES_MINOR_VERSION.$ECCODES_PATCH_VERSION" + +ECCODES_GIT_SHA1="@eccodes_GIT_SHA1@" + +################################################################# +# Commands +################################################################# +usage() +{ + echo "Usage: $0 [--version] [--info] [--git]" + exit $1 +} + +version() +{ + echo "${ECCODES_VERSION_STR}" +} + +print_feature() +{ + if [ -z "$1" ]; then + echo "OFF" + elif [[ $1 =~ (true|TRUE|ON|1) ]]; then + echo "ON" + else + echo "OFF" + fi +} + + +info() +{ + echo "ecCodes version (${ECCODES_VERSION_STR}), git-sha1 ${ECCODES_GIT_SHA1}" + echo "" + echo "Build:" + echo " build type : @CMAKE_BUILD_TYPE@" + echo " timestamp : @EC_BUILD_TIMESTAMP@" + echo " op. system : @CMAKE_SYSTEM@ (@EC_OS_NAME@.@EC_OS_BITS@)" + echo " processor : @CMAKE_SYSTEM_PROCESSOR@" + echo " sources : @PROJECT_SOURCE_DIR@" + echo " c++ compiler : @CMAKE_CXX_COMPILER_ID@ @CMAKE_CXX_COMPILER_VERSION@" + echo " flags : @CMAKE_CXX_FLAGS@" +# echo " fortran compiler: @CMAKE_Fortran_COMPILER_ID@ @CMAKE_Fortran_COMPILER_VERSION@" +# echo " flags : @ECCODES_Fortran_FLAGS@" + echo "" + echo "Features:" + echo " AEC : $(print_feature @HAVE_AEC@)" + echo " MEMFS : $(print_feature @HAVE_MEMFS@)" + echo " NETCDF : $(print_feature @HAVE_NETCDF@)" + echo " JPG : $(print_feature @HAVE_JPEG@)" + echo " PNG : $(print_feature @HAVE_PNG@)" + echo "" + # echo "Dependencies: " + # if [ -n "@ECCODES_HAVE_ECKIT@" ]; then + # echo " eckit version (@eckit_VERSION@), git-sha1 $(short_gitsha1 @eckit_GIT_SHA1@)" + # else + # echo " None" + # fi +} + +gitsha1() +{ + echo "${ECCODES_GIT_SHA1}" +} + +short_gitsha1() +{ + if [ -z "$1" ]; then + echo "unknown" + else + echo $1 | head -c 13 + fi +} + +################################################################# +# Parse command-line +################################################################# + +if test $# -eq 0; then + info + # usage 1 +fi + +while test $# -gt 0; do + + # Split --option=value in $opt="--option" and $val="value" + + opt="" + val="" + + case "$1" in + --*=*) + opt=`echo "$1" | sed 's/=.*//'` + val=`echo "$1" | sed 's/--[_a-zA-Z0-9]*=//'` + ;; + --*) + opt=$1 + ;; + *) + break + ;; + esac + + # Parse options + case "$opt" in + --version) + version + ;; + --git) + gitsha1 + ;; + --info) + info + ;; + --) + shift + break + ;; + *) + echo "unknown option: $opt" + usage 1 + ;; + esac + shift +done diff --git a/tools/codes_info.cc b/tools/codes_info.cc index a73dcde14..e6841e511 100644 --- a/tools/codes_info.cc +++ b/tools/codes_info.cc @@ -40,7 +40,13 @@ static void print_debug_info(grib_context* context) #ifdef HAVE_AEC aec = 1; #endif - grib_context_log(context, GRIB_LOG_DEBUG, "Git SHA1: %s", grib_get_git_sha1()); + const char* git_branch = grib_get_git_branch(); + const char* git_sha1 = grib_get_git_sha1(); + if (strlen(git_branch) > 0) + grib_context_log(context, GRIB_LOG_DEBUG, "Git branch: %s", git_branch); + if (strlen(git_sha1) > 0) + grib_context_log(context, GRIB_LOG_DEBUG, "Git SHA1: %s", git_sha1); + grib_context_log(context, GRIB_LOG_DEBUG, "Build date: %s", codes_get_build_date()); grib_context_log(context, GRIB_LOG_DEBUG, "Features:"); grib_context_log(context, GRIB_LOG_DEBUG, " HAVE_AEC=%d", aec); diff --git a/tools/grib_compare.cc b/tools/grib_compare.cc index 5138ea762..4e984ac1c 100644 --- a/tools/grib_compare.cc +++ b/tools/grib_compare.cc @@ -367,8 +367,8 @@ int grib_tool_init(grib_runtime_options* options) options->tolerance_count = MAX_KEYS; ret = parse_keyval_string(tool_name, sarg, 1, GRIB_TYPE_DOUBLE, options->tolerance, &(options->tolerance_count)); if (ret == GRIB_INVALID_ARGUMENT) { + fprintf(stderr, "%s: Invalid argument for -R\n",tool_name); usage(); - exit(1); } } diff --git a/tools/grib_dump.cc b/tools/grib_dump.cc index dcdd47b50..bcc2def10 100644 --- a/tools/grib_dump.cc +++ b/tools/grib_dump.cc @@ -153,6 +153,7 @@ int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* fi * are more index files */ options->fail = 0; options->skip_all = 1; /* ECC-1516 */ + file->handle_count = 1; // Suppress error "No messages found in ..." } return 0; diff --git a/tools/grib_to_netcdf.cc b/tools/grib_to_netcdf.cc index 920942e66..14c07790f 100644 --- a/tools/grib_to_netcdf.cc +++ b/tools/grib_to_netcdf.cc @@ -83,6 +83,11 @@ typedef struct parameter parameter; static const char* get_value(const request*, const char* name, int n); static bool parsedate(const char* name, long* julian, long* second, bool* isjul); +void usage_and_exit(void) +{ + usage(); // this calls exit(1) +} + static bool eq_string(const char* l, const char* r) { if (l && r) @@ -3957,7 +3962,6 @@ struct KindValue /* The 64-bit offset kind */ { "2", NC_FORMAT_64BIT }, { "64-bit-offset", NC_FORMAT_64BIT }, - { "64-bit offset", NC_FORMAT_64BIT }, /* NetCDF-4 HDF5 format */ { "3", NC_FORMAT_NETCDF4 }, @@ -4073,9 +4077,13 @@ int grib_tool_init(grib_runtime_options* options) } } if (kvalue->name == NULL) { - fprintf(stderr, "Invalid format: %s", kind_name); - usage(); - exit(1); + fprintf(stderr, "Invalid value for -k option: %s\n", kind_name); + fprintf(stderr, "Please use one of:\n"); + for (kvalue = legalkinds; kvalue->name; kvalue++) { + if (is_number(kvalue->name)) + fprintf(stderr, "\t%s\n", kvalue->name); + } + usage_and_exit(); } } @@ -4084,16 +4092,14 @@ int grib_tool_init(grib_runtime_options* options) char* theArg = grib_options_get_option("d:"); if (!is_number(theArg) || atol(theArg) < 0 || atol(theArg) > 9) { fprintf(stderr, "Invalid deflate option: %s (must be 0 to 9)\n", theArg); - usage(); - exit(1); + usage_and_exit(); } set_value(user_r, "deflate", theArg); deflate_option = 1; } else { fprintf(stderr, "Invalid deflate option for non netCDF-4 output formats\n"); - usage(); - exit(1); + usage_and_exit(); } } else { @@ -4105,8 +4111,7 @@ int grib_tool_init(grib_runtime_options* options) set_value(user_r, "shuffle", "true"); else { fprintf(stderr, "Invalid shuffle option. Deflate option needed.\n"); - usage(); - exit(1); + usage_and_exit(); } } else @@ -4116,8 +4121,7 @@ int grib_tool_init(grib_runtime_options* options) char* theArg = grib_options_get_option("R:"); if (!is_number(theArg)) { fprintf(stderr, "Invalid reference date: %s\n", theArg); - usage(); - exit(1); + usage_and_exit(); } set_value(user_r, "referencedate", theArg); } @@ -4294,8 +4298,8 @@ int grib_tool_finalise_action(grib_runtime_options* options) int creation_mode = NC_CLOBBER; if (options->outfile == NULL || options->outfile->name == NULL) { - usage(); - exit(1); + grib_context_log(ctx, GRIB_LOG_ERROR, "No output file. Exiting!"); + usage_and_exit(); } if (fs->count == 0) { diff --git a/tools/grib_tools.cc b/tools/grib_tools.cc index 7b83cd293..2c0598b0b 100644 --- a/tools/grib_tools.cc +++ b/tools/grib_tools.cc @@ -168,16 +168,16 @@ int grib_tool(int argc, char** argv) grib_process_runtime_options(c, argc, argv, &global_options); grib_tool_init(&global_options); - if (global_options.dump_filename) { - dump_file = fopen(global_options.dump_filename, "w"); - if (!dump_file) { - perror(global_options.dump_filename); - exit(1); - } - } - else { - dump_file = stdout; - } + + Assert(global_options.dump_filename == NULL); + dump_file = stdout; + // if (global_options.dump_filename) { + // dump_file = fopen(global_options.dump_filename, "w"); + // if (!dump_file) { + // perror(global_options.dump_filename); + // exit(1); + // } + // } /* ECC-926: Currently only GRIB and BUFR indexing work. Disable the through_index if GTS etc */ if ((global_options.mode == MODE_GRIB || global_options.mode == MODE_BUFR) && diff --git a/tools/gts_compare.cc b/tools/gts_compare.cc index bd98965b4..4ceab0f9f 100644 --- a/tools/gts_compare.cc +++ b/tools/gts_compare.cc @@ -17,8 +17,6 @@ grib_option grib_options[] = { { "d", 0, "Write different messages on files\n", 0, 1, 0 }, { "T:", 0, 0, 1, 0, "T" }, /* GTS */ { "c:", 0, 0, 0, 1, 0 }, - { "S:", "start", "First field to be processed.\n", 0, 1, 0 }, - { "E:", "end", "Last field to be processed.\n", 0, 1, 0 }, { "a", 0, "-c option modifier. The keys listed with the option -c will be added to the list of keys compared without -c.\n", 0, 1, 0 }, /*{"R:",0,0,0,1,0},*/ /*{"A:",0,0,0,1,0},*/ @@ -87,9 +85,6 @@ static int write_count = 0; grib_handle* global_handle = NULL; int counter = 0; -int start = -1; -int end = -1; - static void write_message(grib_handle* h, const char* str) { @@ -155,11 +150,6 @@ int grib_tool_init(grib_runtime_options* options) grib_context* context = grib_context_get_default(); options->strict = 1; - if (grib_options_on("S:")) - start = atoi(grib_options_get_option("S:")); - - if (grib_options_on("E:")) - end = atoi(grib_options_get_option("E:")); if (grib_options_on("f")) force = 1; @@ -537,10 +527,6 @@ static int compare_values(const grib_runtime_options* options, grib_handle* h1, return err2; break; - case GRIB_TYPE_DOUBLE: - Assert(!"GTS cannot contain keys of type DOUBLE"); - break; - case GRIB_TYPE_BYTES: // We do not want to compare the message itself return 0;