diff --git a/definitions/grib2/cfName.def b/definitions/grib2/cfName.def index 178b08b2c..baa301453 100644 --- a/definitions/grib2/cfName.def +++ b/definitions/grib2/cfName.def @@ -246,3 +246,11 @@ scaledValueOfFirstFixedSurface = 0 ; scaleFactorOfFirstFixedSurface = 0 ; } +#Top net solar radiation +'toa_net_upward_shortwave_flux' = { + discipline = 0 ; + parameterCategory = 4 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 8 ; + typeOfStatisticalProcessing = 1 ; +} diff --git a/definitions/grib2/cfVarName.def b/definitions/grib2/cfVarName.def index d49fe291b..db13384c3 100644 --- a/definitions/grib2/cfVarName.def +++ b/definitions/grib2/cfVarName.def @@ -205,6 +205,22 @@ parameterCategory = 2 ; parameterNumber = 32 ; } +#Total column cloud liquid water +'tclw' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 69 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + } +#Total column cloud ice water +'tciw' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 70 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + } #Surface solar radiation downwards 'ssrd' = { discipline = 0 ; @@ -221,6 +237,14 @@ typeOfStatisticalProcessing = 1 ; typeOfFirstFixedSurface = 1 ; } +#Top net solar radiation +'tsr' = { + discipline = 0 ; + parameterCategory = 4 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 8 ; + typeOfStatisticalProcessing = 1 ; + } #Eastward turbulent surface stress 'ewss' = { discipline = 0 ; @@ -475,6 +499,16 @@ typeOfFirstFixedSurface = 169 ; typeOfSecondFixedSurface = 255 ; } +#2 metre specific humidity +'sh2' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 0 ; + typeOfFirstFixedSurface = 103 ; + typeOfSecondFixedSurface = 255 ; + scaledValueOfFirstFixedSurface = 2 ; + scaleFactorOfFirstFixedSurface = 0 ; + } #Ammonium aerosol mass mixing ratio 'aermr18' = { discipline = 0 ; @@ -943,6 +977,33 @@ parameterNumber = 20 ; typeOfStatisticalProcessing = 0 ; } +#Time integral of rain flux +'tirf' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 65 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 255 ; + typeOfStatisticalProcessing = 1 ; + } +#Time integral of surface eastward momentum flux +'tisemf' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 17 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 255 ; + typeOfStatisticalProcessing = 1 ; + } +#Time integral of surface northward momentum flux +'tisnmf' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 18 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 255 ; + typeOfStatisticalProcessing = 1 ; + } #Cross sectional area of flow in channel 'chcross' = { discipline = 1 ; @@ -1047,6 +1108,14 @@ parameterCategory = 0 ; parameterNumber = 9 ; } +#Total column graupel +'tcolg' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 74 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + } #2 metre relative humidity 'r2' = { discipline = 0 ; diff --git a/definitions/grib2/localConcepts/ecmf/cfName.def b/definitions/grib2/localConcepts/ecmf/cfName.def index 7d854277a..1b4449d4a 100644 --- a/definitions/grib2/localConcepts/ecmf/cfName.def +++ b/definitions/grib2/localConcepts/ecmf/cfName.def @@ -109,12 +109,6 @@ parameterCategory = 128 ; parameterNumber = 174 ; } -#Top net solar radiation -'toa_net_upward_shortwave_flux' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 178 ; - } #Evaporation 'lwe_thickness_of_water_evaporation_amount' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/ecmf/cfName.legacy.def b/definitions/grib2/localConcepts/ecmf/cfName.legacy.def index 1596928bf..41d1e2f0c 100644 --- a/definitions/grib2/localConcepts/ecmf/cfName.legacy.def +++ b/definitions/grib2/localConcepts/ecmf/cfName.legacy.def @@ -40,3 +40,9 @@ parameterCategory = 151 ; parameterNumber = 163 ; } +#Top net solar radiation +'toa_net_upward_shortwave_flux' = { + discipline = 192 ; + parameterCategory = 128 ; + parameterNumber = 178 ; +} diff --git a/definitions/grib2/localConcepts/ecmf/cfVarName.def b/definitions/grib2/localConcepts/ecmf/cfVarName.def index 5a4b2ab9b..5e7319ba0 100644 --- a/definitions/grib2/localConcepts/ecmf/cfVarName.def +++ b/definitions/grib2/localConcepts/ecmf/cfVarName.def @@ -395,18 +395,6 @@ parameterCategory = 128 ; parameterNumber = 74 ; } -#Total column cloud liquid water -'tclw' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 78 ; - } -#Total column cloud ice water -'tciw' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 79 ; - } #Experimental product 'p80.128' = { discipline = 192 ; @@ -830,12 +818,6 @@ parameterCategory = 128 ; parameterNumber = 174 ; } -#Top net solar radiation -'tsr' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 178 ; - } #Evaporation 'e' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/ecmf/cfVarName.legacy.def b/definitions/grib2/localConcepts/ecmf/cfVarName.legacy.def index 40cabda6c..51377ca9d 100644 --- a/definitions/grib2/localConcepts/ecmf/cfVarName.legacy.def +++ b/definitions/grib2/localConcepts/ecmf/cfVarName.legacy.def @@ -118,3 +118,21 @@ parameterCategory = 131 ; parameterNumber = 88 ; } +#Total column cloud liquid water +'tclw' = { + discipline = 192 ; + parameterCategory = 128 ; + parameterNumber = 78 ; +} +#Total column cloud ice water +'tciw' = { + discipline = 192 ; + parameterCategory = 128 ; + parameterNumber = 79 ; +} +#Top net solar radiation +'tsr' = { + discipline = 192 ; + parameterCategory = 128 ; + parameterNumber = 178 ; +} diff --git a/definitions/grib2/localConcepts/ecmf/name.def b/definitions/grib2/localConcepts/ecmf/name.def index 53a15879c..9d32b62a1 100644 --- a/definitions/grib2/localConcepts/ecmf/name.def +++ b/definitions/grib2/localConcepts/ecmf/name.def @@ -395,18 +395,6 @@ parameterCategory = 128 ; parameterNumber = 74 ; } -#Total column cloud liquid water -'Total column cloud liquid water' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 78 ; - } -#Total column cloud ice water -'Total column cloud ice water' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 79 ; - } #Experimental product 'Experimental product' = { discipline = 192 ; @@ -830,12 +818,6 @@ parameterCategory = 128 ; parameterNumber = 174 ; } -#Top net solar radiation -'Top net solar radiation' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 178 ; - } #Evaporation 'Evaporation' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/ecmf/name.legacy.def b/definitions/grib2/localConcepts/ecmf/name.legacy.def index 76b0150ad..2bc9c38da 100644 --- a/definitions/grib2/localConcepts/ecmf/name.legacy.def +++ b/definitions/grib2/localConcepts/ecmf/name.legacy.def @@ -118,3 +118,21 @@ parameterCategory = 131 ; parameterNumber = 88 ; } +#Total column cloud liquid water +'Total column cloud liquid water' = { + discipline = 192 ; + parameterCategory = 128 ; + parameterNumber = 78 ; +} +#Total column cloud ice water +'Total column cloud ice water' = { + discipline = 192 ; + parameterCategory = 128 ; + parameterNumber = 79 ; +} +#Top net solar radiation +'Top net solar radiation' = { + discipline = 192 ; + parameterCategory = 128 ; + parameterNumber = 178 ; +} diff --git a/definitions/grib2/localConcepts/ecmf/paramId.def b/definitions/grib2/localConcepts/ecmf/paramId.def index 2b80038ea..41f6cde73 100644 --- a/definitions/grib2/localConcepts/ecmf/paramId.def +++ b/definitions/grib2/localConcepts/ecmf/paramId.def @@ -395,18 +395,6 @@ parameterCategory = 128 ; parameterNumber = 74 ; } -#Total column cloud liquid water -'78' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 78 ; - } -#Total column cloud ice water -'79' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 79 ; - } #Experimental product '80' = { discipline = 192 ; @@ -830,12 +818,6 @@ parameterCategory = 128 ; parameterNumber = 174 ; } -#Top net solar radiation -'178' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 178 ; - } #Evaporation '182' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/ecmf/paramId.legacy.def b/definitions/grib2/localConcepts/ecmf/paramId.legacy.def index 541691902..c20d87664 100644 --- a/definitions/grib2/localConcepts/ecmf/paramId.legacy.def +++ b/definitions/grib2/localConcepts/ecmf/paramId.legacy.def @@ -118,3 +118,21 @@ parameterCategory = 131 ; parameterNumber = 88 ; } +#Total column cloud liquid water +'78' = { + discipline = 192 ; + parameterCategory = 128 ; + parameterNumber = 78 ; +} +#Total column cloud ice water +'79' = { + discipline = 192 ; + parameterCategory = 128 ; + parameterNumber = 79 ; +} +#Top net solar radiation +'178' = { + discipline = 192 ; + parameterCategory = 128 ; + parameterNumber = 178 ; +} diff --git a/definitions/grib2/localConcepts/ecmf/shortName.def b/definitions/grib2/localConcepts/ecmf/shortName.def index 78b8e5e70..2bcedea79 100644 --- a/definitions/grib2/localConcepts/ecmf/shortName.def +++ b/definitions/grib2/localConcepts/ecmf/shortName.def @@ -395,18 +395,6 @@ parameterCategory = 128 ; parameterNumber = 74 ; } -#Total column cloud liquid water -'tclw' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 78 ; - } -#Total column cloud ice water -'tciw' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 79 ; - } #Experimental product '~' = { discipline = 192 ; @@ -830,12 +818,6 @@ parameterCategory = 128 ; parameterNumber = 174 ; } -#Top net solar radiation -'tsr' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 178 ; - } #Evaporation 'e' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/ecmf/shortName.legacy.def b/definitions/grib2/localConcepts/ecmf/shortName.legacy.def index 866775017..cad6d54bb 100644 --- a/definitions/grib2/localConcepts/ecmf/shortName.legacy.def +++ b/definitions/grib2/localConcepts/ecmf/shortName.legacy.def @@ -118,3 +118,21 @@ parameterCategory = 131 ; parameterNumber = 88 ; } +#Total column cloud liquid water +'tclw' = { + discipline = 192 ; + parameterCategory = 128 ; + parameterNumber = 78 ; +} +#Total column cloud ice water +'tciw' = { + discipline = 192 ; + parameterCategory = 128 ; + parameterNumber = 79 ; +} +#Top net solar radiation +'tsr' = { + discipline = 192 ; + parameterCategory = 128 ; + parameterNumber = 178 ; +} diff --git a/definitions/grib2/localConcepts/ecmf/units.def b/definitions/grib2/localConcepts/ecmf/units.def index c5ffc55af..50d064ad2 100644 --- a/definitions/grib2/localConcepts/ecmf/units.def +++ b/definitions/grib2/localConcepts/ecmf/units.def @@ -395,18 +395,6 @@ parameterCategory = 128 ; parameterNumber = 74 ; } -#Total column cloud liquid water -'kg m**-2' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 78 ; - } -#Total column cloud ice water -'kg m**-2' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 79 ; - } #Experimental product '~' = { discipline = 192 ; @@ -830,12 +818,6 @@ parameterCategory = 128 ; parameterNumber = 174 ; } -#Top net solar radiation -'J m**-2' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 178 ; - } #Evaporation 'm of water equivalent' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/ecmf/units.legacy.def b/definitions/grib2/localConcepts/ecmf/units.legacy.def index 74dcf7491..e49265144 100644 --- a/definitions/grib2/localConcepts/ecmf/units.legacy.def +++ b/definitions/grib2/localConcepts/ecmf/units.legacy.def @@ -118,3 +118,21 @@ parameterCategory = 131 ; parameterNumber = 88 ; } +#Total column cloud liquid water +'kg m**-2' = { + discipline = 192 ; + parameterCategory = 128 ; + parameterNumber = 78 ; +} +#Total column cloud ice water +'kg m**-2' = { + discipline = 192 ; + parameterCategory = 128 ; + parameterNumber = 79 ; +} +#Top net solar radiation +'J m**-2' = { + discipline = 192 ; + parameterCategory = 128 ; + parameterNumber = 178 ; +} diff --git a/definitions/grib2/localConcepts/egrr/cfVarName.def b/definitions/grib2/localConcepts/egrr/cfVarName.def index 9c5652a10..99a9945ed 100644 --- a/definitions/grib2/localConcepts/egrr/cfVarName.def +++ b/definitions/grib2/localConcepts/egrr/cfVarName.def @@ -72,3 +72,13 @@ scaledValueOfFirstFixedSurface = 15 ; scaleFactorOfFirstFixedSurface = 1 ; } +#2 metre specific humidity +'sh2' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 0 ; + typeOfFirstFixedSurface = 103 ; + typeOfSecondFixedSurface = 255 ; + scaledValueOfFirstFixedSurface = 15 ; + scaleFactorOfFirstFixedSurface = 1 ; + } diff --git a/definitions/grib2/localConcepts/egrr/name.def b/definitions/grib2/localConcepts/egrr/name.def index e61e1854a..f1ce0156a 100644 --- a/definitions/grib2/localConcepts/egrr/name.def +++ b/definitions/grib2/localConcepts/egrr/name.def @@ -72,3 +72,13 @@ scaleFactorOfFirstFixedSurface = 1 ; typeOfFirstFixedSurface = 103 ; } +#2 metre specific humidity +'2 metre specific humidity' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 0 ; + typeOfFirstFixedSurface = 103 ; + typeOfSecondFixedSurface = 255 ; + scaledValueOfFirstFixedSurface = 15 ; + scaleFactorOfFirstFixedSurface = 1 ; + } diff --git a/definitions/grib2/localConcepts/egrr/paramId.def b/definitions/grib2/localConcepts/egrr/paramId.def index 8d0d49251..561ef8625 100644 --- a/definitions/grib2/localConcepts/egrr/paramId.def +++ b/definitions/grib2/localConcepts/egrr/paramId.def @@ -72,3 +72,13 @@ scaledValueOfFirstFixedSurface = 15 ; scaleFactorOfFirstFixedSurface = 1 ; } +#2 metre specific humidity +'174096' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 0 ; + typeOfFirstFixedSurface = 103 ; + typeOfSecondFixedSurface = 255 ; + scaledValueOfFirstFixedSurface = 15 ; + scaleFactorOfFirstFixedSurface = 1 ; + } diff --git a/definitions/grib2/localConcepts/egrr/shortName.def b/definitions/grib2/localConcepts/egrr/shortName.def index 82a54ee55..3a824a001 100644 --- a/definitions/grib2/localConcepts/egrr/shortName.def +++ b/definitions/grib2/localConcepts/egrr/shortName.def @@ -72,3 +72,13 @@ scaledValueOfFirstFixedSurface = 15 ; scaleFactorOfFirstFixedSurface = 1 ; } +#2 metre specific humidity +'2sh' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 0 ; + typeOfFirstFixedSurface = 103 ; + typeOfSecondFixedSurface = 255 ; + scaledValueOfFirstFixedSurface = 15 ; + scaleFactorOfFirstFixedSurface = 1 ; + } diff --git a/definitions/grib2/localConcepts/egrr/units.def b/definitions/grib2/localConcepts/egrr/units.def index ee4c1a8d8..8e1c3f3ad 100644 --- a/definitions/grib2/localConcepts/egrr/units.def +++ b/definitions/grib2/localConcepts/egrr/units.def @@ -72,3 +72,13 @@ scaleFactorOfFirstFixedSurface = 1 ; typeOfFirstFixedSurface = 103 ; } +#2 metre specific humidity +'kg kg**-1' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 0 ; + typeOfFirstFixedSurface = 103 ; + typeOfSecondFixedSurface = 255 ; + scaledValueOfFirstFixedSurface = 15 ; + scaleFactorOfFirstFixedSurface = 1 ; + } diff --git a/definitions/grib2/name.def b/definitions/grib2/name.def index ee12edea1..4fd562ccc 100644 --- a/definitions/grib2/name.def +++ b/definitions/grib2/name.def @@ -205,6 +205,22 @@ parameterCategory = 2 ; parameterNumber = 32 ; } +#Total column cloud liquid water +'Total column cloud liquid water' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 69 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + } +#Total column cloud ice water +'Total column cloud ice water' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 70 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + } #Surface solar radiation downwards 'Surface solar radiation downwards' = { discipline = 0 ; @@ -221,6 +237,14 @@ typeOfStatisticalProcessing = 1 ; typeOfFirstFixedSurface = 1 ; } +#Top net solar radiation +'Top net solar radiation' = { + discipline = 0 ; + parameterCategory = 4 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 8 ; + typeOfStatisticalProcessing = 1 ; + } #Eastward turbulent surface stress 'Eastward turbulent surface stress' = { discipline = 0 ; @@ -475,6 +499,16 @@ typeOfSecondFixedSurface = 255 ; scaleFactorOfFirstFixedSurface = 2 ; } +#2 metre specific humidity +'2 metre specific humidity' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 0 ; + typeOfFirstFixedSurface = 103 ; + typeOfSecondFixedSurface = 255 ; + scaledValueOfFirstFixedSurface = 2 ; + scaleFactorOfFirstFixedSurface = 0 ; + } #Ammonium aerosol mass mixing ratio 'Ammonium aerosol mass mixing ratio' = { discipline = 0 ; @@ -943,6 +977,33 @@ parameterNumber = 20 ; typeOfStatisticalProcessing = 0 ; } +#Time integral of rain flux +'Time integral of rain flux' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 65 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 255 ; + typeOfStatisticalProcessing = 1 ; + } +#Time integral of surface eastward momentum flux +'Time integral of surface eastward momentum flux' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 17 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 255 ; + typeOfStatisticalProcessing = 1 ; + } +#Time integral of surface northward momentum flux +'Time integral of surface northward momentum flux' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 18 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 255 ; + typeOfStatisticalProcessing = 1 ; + } #Cross sectional area of flow in channel 'Cross sectional area of flow in channel' = { discipline = 1 ; @@ -1047,6 +1108,14 @@ parameterCategory = 0 ; parameterNumber = 9 ; } +#Total column graupel +'Total column graupel' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 74 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + } #2 metre relative humidity '2 metre relative humidity' = { discipline = 0 ; diff --git a/definitions/grib2/paramId.def b/definitions/grib2/paramId.def index 54d02e744..ad2830698 100644 --- a/definitions/grib2/paramId.def +++ b/definitions/grib2/paramId.def @@ -205,6 +205,22 @@ parameterCategory = 2 ; parameterNumber = 32 ; } +#Total column cloud liquid water +'78' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 69 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + } +#Total column cloud ice water +'79' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 70 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + } #Surface solar radiation downwards '169' = { discipline = 0 ; @@ -221,6 +237,14 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 1 ; } +#Top net solar radiation +'178' = { + discipline = 0 ; + parameterCategory = 4 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 8 ; + typeOfStatisticalProcessing = 1 ; + } #Eastward turbulent surface stress '180' = { discipline = 0 ; @@ -475,6 +499,16 @@ typeOfFirstFixedSurface = 169 ; scaledValueOfFirstFixedSurface = 1 ; } +#2 metre specific humidity +'174096' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 0 ; + typeOfFirstFixedSurface = 103 ; + typeOfSecondFixedSurface = 255 ; + scaledValueOfFirstFixedSurface = 2 ; + scaleFactorOfFirstFixedSurface = 0 ; + } #Ammonium aerosol mass mixing ratio '210249' = { discipline = 0 ; @@ -943,6 +977,33 @@ parameterNumber = 20 ; typeOfStatisticalProcessing = 0 ; } +#Time integral of rain flux +'235015' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 65 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 255 ; + typeOfStatisticalProcessing = 1 ; + } +#Time integral of surface eastward momentum flux +'235017' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 17 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 255 ; + typeOfStatisticalProcessing = 1 ; + } +#Time integral of surface northward momentum flux +'235018' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 18 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 255 ; + typeOfStatisticalProcessing = 1 ; + } #Cross sectional area of flow in channel '240011' = { discipline = 1 ; @@ -1047,6 +1108,14 @@ parameterCategory = 0 ; parameterNumber = 9 ; } +#Total column graupel +'260001' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 74 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + } #2 metre relative humidity '260242' = { discipline = 0 ; diff --git a/definitions/grib2/parameters.def b/definitions/grib2/parameters.def index 03e3399ad..066b49feb 100644 --- a/definitions/grib2/parameters.def +++ b/definitions/grib2/parameters.def @@ -1,9 +1,7 @@ # (C) Copyright 2005- ECMWF. transient dummyc=0: hidden; -constant conceptsMasterDir="grib2" : hidden; -constant conceptsLocalDirAll="grib2/localConcepts/[centre:s]" : hidden; -constant conceptsLocalDirECMF="grib2/localConcepts/ecmf" : hidden; + concept paramIdLegacyECMF(defaultParameter,"paramId.legacy.def",conceptsMasterDir,conceptsLocalDirECMF): long_type,no_copy,hidden; concept paramIdECMF (paramIdLegacyECMF,"paramId.def",conceptsMasterDir,conceptsLocalDirECMF): long_type,no_copy; diff --git a/definitions/grib2/section.1.def b/definitions/grib2/section.1.def index d44489622..72415c998 100644 --- a/definitions/grib2/section.1.def +++ b/definitions/grib2/section.1.def @@ -132,3 +132,7 @@ concept is_uerra(zero) { '1' = {productionStatusOfProcessedData=8;} '0' = {dummy=1;} } + +constant conceptsMasterDir="grib2" : hidden; +constant conceptsLocalDirAll="grib2/localConcepts/[centre:s]" : hidden; +constant conceptsLocalDirECMF="grib2/localConcepts/ecmf" : hidden; diff --git a/definitions/grib2/shortName.def b/definitions/grib2/shortName.def index 2ea6258c0..03f15f5fb 100644 --- a/definitions/grib2/shortName.def +++ b/definitions/grib2/shortName.def @@ -205,6 +205,22 @@ parameterCategory = 2 ; parameterNumber = 32 ; } +#Total column cloud liquid water +'tclw' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 69 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + } +#Total column cloud ice water +'tciw' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 70 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + } #Surface solar radiation downwards 'ssrd' = { discipline = 0 ; @@ -221,6 +237,14 @@ typeOfStatisticalProcessing = 1 ; typeOfFirstFixedSurface = 1 ; } +#Top net solar radiation +'tsr' = { + discipline = 0 ; + parameterCategory = 4 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 8 ; + typeOfStatisticalProcessing = 1 ; + } #Eastward turbulent surface stress 'ewss' = { discipline = 0 ; @@ -475,6 +499,16 @@ scaleFactorOfFirstFixedSurface = 2 ; typeOfFirstFixedSurface = 169 ; } +#2 metre specific humidity +'2sh' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 0 ; + typeOfFirstFixedSurface = 103 ; + typeOfSecondFixedSurface = 255 ; + scaledValueOfFirstFixedSurface = 2 ; + scaleFactorOfFirstFixedSurface = 0 ; + } #Ammonium aerosol mass mixing ratio 'aermr18' = { discipline = 0 ; @@ -943,6 +977,33 @@ parameterNumber = 20 ; typeOfStatisticalProcessing = 0 ; } +#Time integral of rain flux +'tirf' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 65 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 255 ; + typeOfStatisticalProcessing = 1 ; + } +#Time integral of surface eastward momentum flux +'tisemf' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 17 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 255 ; + typeOfStatisticalProcessing = 1 ; + } +#Time integral of surface northward momentum flux +'tisnmf' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 18 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 255 ; + typeOfStatisticalProcessing = 1 ; + } #Cross sectional area of flow in channel 'chcross' = { discipline = 1 ; @@ -1047,6 +1108,14 @@ parameterCategory = 0 ; parameterNumber = 9 ; } +#Total column graupel +'tcolg' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 74 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + } #2 metre relative humidity '2r' = { discipline = 0 ; diff --git a/definitions/grib2/template.4.horizontal.def b/definitions/grib2/template.4.horizontal.def index d3739c0b1..616800f8f 100755 --- a/definitions/grib2/template.4.horizontal.def +++ b/definitions/grib2/template.4.horizontal.def @@ -24,7 +24,7 @@ unsigned[4] scaledValueOfSecondFixedSurface = missing() : can_be_missing,dump,no transient pressureUnits="hPa"; -concept_nofail vertical.typeOfLevel (unknown,"typeOfLevelConcept.def",conceptsMasterDir,conceptsLocalDirAll); +concept_nofail vertical.typeOfLevel (unknown,"typeOfLevelConcept.def",conceptsLocalDirAll,conceptsMasterDir); alias levelType=typeOfFirstFixedSurface; diff --git a/definitions/grib2/units.def b/definitions/grib2/units.def index 0b3df9b97..1c93fb69f 100644 --- a/definitions/grib2/units.def +++ b/definitions/grib2/units.def @@ -205,6 +205,22 @@ parameterCategory = 2 ; parameterNumber = 32 ; } +#Total column cloud liquid water +'kg m**-2' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 69 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + } +#Total column cloud ice water +'kg m**-2' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 70 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + } #Surface solar radiation downwards 'J m**-2' = { discipline = 0 ; @@ -221,6 +237,14 @@ typeOfStatisticalProcessing = 1 ; typeOfFirstFixedSurface = 1 ; } +#Top net solar radiation +'J m**-2' = { + discipline = 0 ; + parameterCategory = 4 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 8 ; + typeOfStatisticalProcessing = 1 ; + } #Eastward turbulent surface stress 'N m**-2 s' = { discipline = 0 ; @@ -475,6 +499,16 @@ typeOfSecondFixedSurface = 255 ; scaleFactorOfFirstFixedSurface = 2 ; } +#2 metre specific humidity +'kg kg**-1' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 0 ; + typeOfFirstFixedSurface = 103 ; + typeOfSecondFixedSurface = 255 ; + scaledValueOfFirstFixedSurface = 2 ; + scaleFactorOfFirstFixedSurface = 0 ; + } #Ammonium aerosol mass mixing ratio 'kg kg**-1' = { discipline = 0 ; @@ -943,6 +977,33 @@ parameterNumber = 20 ; typeOfStatisticalProcessing = 0 ; } +#Time integral of rain flux +'kg m**-2' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 65 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 255 ; + typeOfStatisticalProcessing = 1 ; + } +#Time integral of surface eastward momentum flux +'N m**-2 s' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 17 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 255 ; + typeOfStatisticalProcessing = 1 ; + } +#Time integral of surface northward momentum flux +'N m**-2 s' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 18 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 255 ; + typeOfStatisticalProcessing = 1 ; + } #Cross sectional area of flow in channel 'm**2' = { discipline = 1 ; @@ -1047,6 +1108,14 @@ parameterCategory = 0 ; parameterNumber = 9 ; } +#Total column graupel +'kg m**-2' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 74 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + } #2 metre relative humidity '%' = { discipline = 0 ; diff --git a/doxygen/eccodes.dox b/doxygen/eccodes.dox index 52f02c647..21508cbd3 100644 --- a/doxygen/eccodes.dox +++ b/doxygen/eccodes.dox @@ -12,7 +12,7 @@ set of tools for decoding and encoding messages in the following formats: A useful set of command line tools provide quick access to the messages. C, Fortran 90 and Python interfaces provide access to the main %ecCodes functionality. -%ecCodes is an evolution of GRIB-API. It is designed to provide the user with a simple set of +%ecCodes is an evolution of GRIB-API. It is designed to provide the user with a simple set of functions to access data from several formats with a key/value approach. For GRIB encoding and decoding, the GRIB-API functionality is provided fully in %ecCodes with the same user interface and behaviour. diff --git a/examples/C/include.ctest.sh.in b/examples/C/include.ctest.sh.in index 4e725db65..854e025f0 100644 --- a/examples/C/include.ctest.sh.in +++ b/examples/C/include.ctest.sh.in @@ -1,6 +1,7 @@ # examples/C include file for CMake set -eax +echo "Script: $0" proj_dir=@PROJECT_SOURCE_DIR@ data_dir=@PROJECT_BINARY_DIR@/data diff --git a/examples/F90/include.ctest.sh.in b/examples/F90/include.ctest.sh.in index 510ec17aa..822714cd1 100644 --- a/examples/F90/include.ctest.sh.in +++ b/examples/F90/include.ctest.sh.in @@ -1,6 +1,7 @@ # examples/F90 include file for CMake set -eax +echo "Script: $0" proj_dir=@PROJECT_SOURCE_DIR@ data_dir=@PROJECT_BINARY_DIR@/data diff --git a/html/index.html b/html/index.html index 8e906592e..f0fc3aee9 100644 --- a/html/index.html +++ b/html/index.html @@ -87,7 +87,7 @@ Overview
  • WMO GTS abbreviated header (only decoding in this release).
  • A useful set of command line tools provide quick access to the messages. C, Fortran 90 and Python interfaces provide access to the main ecCodes functionality.

    -

    ecCodes is an evolution of GRIB-API. It is designed to provide the user with a simple set of functions to access data from several formats with a key/value approach.

    +

    ecCodes is an evolution of GRIB-API. It is designed to provide the user with a simple set of functions to access data from several formats with a key/value approach.

    For GRIB encoding and decoding, the GRIB-API functionality is provided fully in ecCodes with the same user interface and behaviour. Interfaces for C, Fortran 90 and Python are all maintained as in GRIB-API. However, the GRIB-API Fortran 77 interface is no longer available.

    In addition, a new set of functions with the prefix "codes_" is provided to operate on all the supported message formats. These functions have the same interface and behaviour as the "grib_" functions.

    A selection of GRIB-API tools has been included in ecCodes (ecCodes GRIB tools), while new tools are available for the BUFR (ecCodes BUFR tools) and GTS formats. The new tools have been developed to be as similar as possible to the existing GRIB-API tools maintaining, where possible, the same options and behaviour. A significant difference compared with GRIB-API tools is that bufr_dump produces output in JSON format which can be used in many web based applications.

    diff --git a/src/eccodes.c b/src/eccodes.c index fb56decc3..a7d351f0b 100644 --- a/src/eccodes.c +++ b/src/eccodes.c @@ -96,7 +96,7 @@ int codes_fieldset_count(grib_fieldset* set) /* Indexing */ /******************************************************************************/ -grib_index* codes_index_new_from_file(grib_context* c, char* filename, const char* keys, int* err) +grib_index* codes_index_new_from_file(grib_context* c, const char* filename, const char* keys, int* err) { return grib_index_new_from_file(c, filename, keys, err); } @@ -140,7 +140,7 @@ int codes_index_select_double(grib_index* index, const char* key, double value) { return grib_index_select_double(index, key, value); } -int codes_index_select_string(grib_index* index, const char* key, char* value) +int codes_index_select_string(grib_index* index, const char* key, const char* value) { return grib_index_select_string(index, key, value); } diff --git a/src/eccodes.h b/src/eccodes.h index a310dbbfb..cff69f0db 100644 --- a/src/eccodes.h +++ b/src/eccodes.h @@ -214,7 +214,7 @@ typedef struct grib_index codes_index; * @param err : 0 if OK, integer value on error * @return the newly created index */ -codes_index* codes_index_new_from_file(codes_context* c, char* filename, const char* keys, int* err); +codes_index* codes_index_new_from_file(codes_context* c, const char* filename, const char* keys, int* err); /** * Create a new index based on a set of keys. @@ -320,7 +320,7 @@ int codes_index_select_double(codes_index* index, const char* key, double value) * @param value : value of the key to select * @return 0 if OK, integer value on error */ -int codes_index_select_string(codes_index* index, const char* key, char* value); +int codes_index_select_string(codes_index* index, const char* key, const char* value); /** * Create a new handle from an index after having selected the key values. @@ -1253,6 +1253,7 @@ int codes_points_get_values(codes_handle* h, codes_points* points, double* val); #define CODES_UTIL_PACKING_TYPE_GRID_SIMPLE_MATRIX GRIB_UTIL_PACKING_TYPE_GRID_SIMPLE_MATRIX #define CODES_UTIL_PACKING_TYPE_GRID_SECOND_ORDER GRIB_UTIL_PACKING_TYPE_GRID_SECOND_ORDER #define CODES_UTIL_PACKING_TYPE_CCSDS GRIB_UTIL_PACKING_TYPE_CCSDS +#define CODES_UTIL_PACKING_TYPE_IEEE GRIB_UTIL_PACKING_TYPE_IEEE #define CODES_UTIL_PACKING_SAME_AS_INPUT GRIB_UTIL_PACKING_SAME_AS_INPUT #define CODES_UTIL_PACKING_USE_PROVIDED GRIB_UTIL_PACKING_USE_PROVIDED diff --git a/src/grib_accessor_class_bufr_extract_area_subsets.c b/src/grib_accessor_class_bufr_extract_area_subsets.c index 6de896c93..b3bdec849 100644 --- a/src/grib_accessor_class_bufr_extract_area_subsets.c +++ b/src/grib_accessor_class_bufr_extract_area_subsets.c @@ -313,6 +313,7 @@ static int select_area(grib_accessor* a) if (nsubsets != 0) { subsets_ar = grib_iarray_get_array(subsets); ret = grib_set_long_array(h, self->extractSubsetList, subsets_ar, nsubsets); + grib_context_free(c, subsets_ar); if (ret) return ret; diff --git a/src/grib_accessor_class_bufr_extract_datetime_subsets.c b/src/grib_accessor_class_bufr_extract_datetime_subsets.c index a8dd2ffb0..b4e9642e3 100644 --- a/src/grib_accessor_class_bufr_extract_datetime_subsets.c +++ b/src/grib_accessor_class_bufr_extract_datetime_subsets.c @@ -443,6 +443,7 @@ static int select_datetime(grib_accessor* a) if (nsubsets != 0) { subsets_ar = grib_iarray_get_array(subsets); ret = grib_set_long_array(h, self->extractSubsetList, subsets_ar, nsubsets); + grib_context_free(c, subsets_ar); if (ret) return ret; diff --git a/src/grib_accessor_class_bufr_simple_thinning.c b/src/grib_accessor_class_bufr_simple_thinning.c index 4eb40a384..0cd62f2f4 100644 --- a/src/grib_accessor_class_bufr_simple_thinning.c +++ b/src/grib_accessor_class_bufr_simple_thinning.c @@ -207,6 +207,7 @@ static int apply_thinning(grib_accessor* a) if (nsubsets != 0) { subsets_ar = grib_iarray_get_array(subsets); ret = grib_set_long_array(h, self->extractSubsetList, subsets_ar, nsubsets); + grib_context_free(c, subsets_ar); if (ret) return ret; @@ -218,6 +219,7 @@ static int apply_thinning(grib_accessor* a) if (ret) return ret; } + grib_iarray_delete(subsets); } else { return GRIB_NOT_IMPLEMENTED; diff --git a/src/grib_accessor_class_expanded_descriptors.c b/src/grib_accessor_class_expanded_descriptors.c index 62b917d02..14e320ff8 100644 --- a/src/grib_accessor_class_expanded_descriptors.c +++ b/src/grib_accessor_class_expanded_descriptors.c @@ -265,11 +265,11 @@ static void __expand(grib_accessor* a, bufr_descriptors_array* unexpanded, bufr_ *err = grib_get_size(hand, self->sequence, &size); grib_bufr_descriptor_delete(u); if (*err) - return; + goto cleanup; v = (long*)grib_context_malloc_clear(c, sizeof(long) * size); *err = grib_get_long_array(hand, self->sequence, v, &size); if (*err) - return; + goto cleanup; inner_unexpanded = grib_bufr_descriptors_array_new(c, DESC_SIZE_INIT, DESC_SIZE_INCR); for (i = 0; i < size; i++) { @@ -518,8 +518,8 @@ static void __expand(grib_accessor* a, bufr_descriptors_array* unexpanded, bufr_ printf("\t"); printf("expanding <== %d-%.2d-%.3d (size=%ld)\n\n", us->F, us->X, us->Y, size); #endif - if (us) - grib_bufr_descriptor_delete(us); +cleanup: + if (us) grib_bufr_descriptor_delete(us); } static bufr_descriptors_array* do_expand(grib_accessor* a, bufr_descriptors_array* unexpanded, change_coding_params* ccp, int* err) @@ -552,8 +552,10 @@ static bufr_descriptors_array* do_expand(grib_accessor* a, bufr_descriptors_arra #endif while (unexpanded->n) { __expand(a, unexpanded, expanded, ccp, err); - if (*err) + if (*err) { + grib_bufr_descriptors_array_delete(expanded); return NULL; + } } #if MYDEBUG { @@ -689,8 +691,11 @@ static int expand(grib_accessor* a) ccp.associatedFieldWidth = 0; ccp.newStringWidth = 0; self->expanded = do_expand(a, unexpanded, &ccp, &err); - if (err) + if (err) { + grib_bufr_descriptors_array_delete(unexpanded); + grib_bufr_descriptors_array_delete(unexpanded_copy); return err; + } grib_context_expanded_descriptors_list_push(c, key, self->expanded, unexpanded_copy); grib_bufr_descriptors_array_delete(unexpanded); @@ -809,6 +814,7 @@ static int value_count(grib_accessor* a, long* rlen) err = expand(a); if (err) { grib_context_log(a->context, GRIB_LOG_ERROR, "%s unable to compute size", a->name); + grib_bufr_descriptors_array_delete(self->expanded); return err; } *rlen = BUFR_DESCRIPTORS_ARRAY_USED_SIZE(self->expanded); diff --git a/src/grib_api.h b/src/grib_api.h index 44b0e7ebd..75589cb79 100644 --- a/src/grib_api.h +++ b/src/grib_api.h @@ -266,21 +266,25 @@ typedef struct grib_index grib_index; * @return the newly created index */ grib_index* grib_index_new_from_file(grib_context* c, - char* filename, const char* keys, int* err); + const char* filename, const char* keys, int* err); /** * Create a new index based on a set of keys. * * @param c : context (NULL for default context) * @param keys : comma separated list of keys for the index. - * The type of the key can be explicitly declared appending :l for long, - * (or alternatively :i) - * :d for double, :s for string to the key name. If the type is not + * The type of the key can be explicitly declared appending ":l" for long, + * (or alternatively ":i"), ":d" for double, ":s" for string to the key name. If the type is not * declared explicitly, the native type is assumed. * @param err : 0 if OK, integer value on error * @return the newly created index */ grib_index* grib_index_new(grib_context* c, const char* keys, int* err); +/* EXPERIMENTAL */ +int codes_index_set_product_kind(grib_index* index, ProductKind product_kind); +int codes_index_set_unpack_bufr(grib_index* index, int unpack); + + /** * Indexes the file given in argument in the index given in argument. * @@ -374,7 +378,7 @@ int grib_index_select_double(grib_index* index, const char* key, double value); * @param value : value of the key to select * @return 0 if OK, integer value on error */ -int grib_index_select_string(grib_index* index, const char* key, char* value); +int grib_index_select_string(grib_index* index, const char* key, const char* value); /** * Create a new handle from an index after having selected the key values. @@ -1522,6 +1526,7 @@ typedef struct grib_util_grid_spec2 #define GRIB_UTIL_PACKING_TYPE_GRID_SIMPLE_MATRIX 6 #define GRIB_UTIL_PACKING_TYPE_GRID_SECOND_ORDER 7 #define GRIB_UTIL_PACKING_TYPE_CCSDS 8 +#define GRIB_UTIL_PACKING_TYPE_IEEE 9 #define GRIB_UTIL_PACKING_SAME_AS_INPUT 0 #define GRIB_UTIL_PACKING_USE_PROVIDED 1 diff --git a/src/grib_api_internal.h b/src/grib_api_internal.h index 05ddfd81a..d9f4d3b87 100644 --- a/src/grib_api_internal.h +++ b/src/grib_api_internal.h @@ -1393,6 +1393,8 @@ struct grib_index grib_field_list* current; grib_file* files; int count; + ProductKind product_kind; + int unpack_bufr; /* Only meaningful for product_kind of BUFR */ }; /* header compute */ diff --git a/src/grib_api_prototypes.h b/src/grib_api_prototypes.h index 12ce195ee..129df97dd 100644 --- a/src/grib_api_prototypes.h +++ b/src/grib_api_prototypes.h @@ -717,7 +717,7 @@ int grib_write_short(FILE* fh, short val); int grib_write_long(FILE* fh, long val); int grib_write_unsigned_long(FILE* fh, unsigned long val); int grib_write_string(FILE* fh, const char* s); -int grib_write_identifier(FILE* fh); +int grib_write_identifier(FILE* fh, const char* id); int grib_write_null_marker(FILE* fh); int grib_write_not_null_marker(FILE* fh); char* grib_read_string(grib_context* c, FILE* fh, int* err); @@ -728,18 +728,16 @@ int grib_index_write(grib_index* index, const char* filename); grib_index* grib_index_read(grib_context* c, const char* filename, int* err); int grib_index_search_same(grib_index* index, grib_handle* h); int grib_index_add_file(grib_index* index, const char* filename); -grib_handle* new_message_from_file(int message_type, grib_context* c, FILE* f, int* error); int _codes_index_add_file(grib_index* index, const char* filename, int message_type); int grib_index_add_file(grib_index* index, const char* filename); -grib_index* grib_index_new_from_file(grib_context* c, char* filename, const char* keys, int* err); +grib_index* grib_index_new_from_file(grib_context* c, const char* filename, const char* keys, int* err); int grib_index_get_size(const grib_index* index, const char* key, size_t* size); int grib_index_get_string(const grib_index* index, const char* key, char** values, size_t* size); int grib_index_get_long(const grib_index* index, const char* key, long* values, size_t* size); int grib_index_get_double(const grib_index* index, const char* key, double* values, size_t* size); int grib_index_select_long(grib_index* index, const char* skey, long value); int grib_index_select_double(grib_index* index, const char* skey, double value); -int grib_index_select_string(grib_index* index, const char* skey, char* value); -grib_handle* grib_index_get_handle(grib_field* field, int* err); +int grib_index_select_string(grib_index* index, const char* skey, const char* value); grib_handle* codes_index_get_handle(grib_field* field, int message_type, int* err); int grib_index_dump_file(FILE* fout, const char* filename); void grib_index_dump(FILE* fout, grib_index* index); @@ -748,6 +746,9 @@ grib_handle* grib_handle_new_from_index(grib_index* index, int* err); grib_handle* codes_new_from_index(grib_index* index, int message_type, int* err); void grib_index_rewind(grib_index* index); int grib_index_search(grib_index* index, grib_index_key* keys); +int codes_index_set_product_kind(grib_index* index, ProductKind product_kind); +int codes_index_set_unpack_bufr(grib_index* index, int unpack); +int is_index_file(const char* filename); /* grib_accessor_class_number_of_points_gaussian.c */ @@ -1478,7 +1479,6 @@ int grib2_is_PDTN_ChemicalDistFunc(long productDefinitionTemplateNumber); int grib2_is_PDTN_Aerosol(long productDefinitionTemplateNumber); int grib2_is_PDTN_AerosolOptical(long productDefinitionTemplateNumber); int grib2_select_PDTN(int is_eps, int is_instant, int is_chemical, int is_chemical_distfn, int is_aerosol, int is_aerosol_optical); -int is_grib_index_file(const char* filename); size_t sum_of_pl_array(const long* pl, size_t plsize); int grib_is_earth_oblate(grib_handle* h); int grib_util_grib_data_quality_check(grib_handle* h, double min_val, double max_val); diff --git a/src/grib_bits.c b/src/grib_bits.c index fa21c2ba7..f3b770307 100644 --- a/src/grib_bits.c +++ b/src/grib_bits.c @@ -30,6 +30,12 @@ long GRIB_MASK = -1; /* Mask of sword bits */ ((b) == max_nbits ? GRIB_MASK : (~(GRIB_MASK << (b)) << (max_nbits - ((q) + (b))))) +#define VALUE_SIZE_T(p, q, b) \ + (((b) == max_nbits_size_t ? GRIB_MASK : ~(GRIB_MASK << (b))) & ((p) >> (max_nbits_size_t - ((q) + (b))))) + +#define MASKVALUE_SIZE_T(q, b) \ + ((b) == max_nbits_size_t ? GRIB_MASK : (~(GRIB_MASK << (b)) << (max_nbits_size_t - ((q) + (b))))) + static const unsigned long dmasks[] = { 0xFF, 0xFE, diff --git a/src/grib_bits_fast_big_endian.c b/src/grib_bits_fast_big_endian.c index 0f1a14cc9..af852d105 100644 --- a/src/grib_bits_fast_big_endian.c +++ b/src/grib_bits_fast_big_endian.c @@ -114,7 +114,6 @@ char* grib_decode_string(const unsigned char* bitStream, long* bitOffset, size_t return string; } - unsigned long grib_decode_unsigned_long(const unsigned char* p, long* bitp, long nbits) { long countOfLeftmostBits = 0, leftmostBits = 0; @@ -146,6 +145,37 @@ unsigned long grib_decode_unsigned_long(const unsigned char* p, long* bitp, long return val; } +size_t grib_decode_size_t(const unsigned char* p, long* bitp, long nbits) +{ + long countOfLeftmostBits = 0, leftmostBits = 0; + long startBit = *bitp; + long remainingBits = nbits; + long* pp = (long*)p; + size_t val = 0; + + if (startBit >= max_nbits_size_t) { + pp += startBit / max_nbits_size_t; + startBit %= max_nbits_size_t; + } + + countOfLeftmostBits = startBit + remainingBits; + if (countOfLeftmostBits > max_nbits_size_t) { + countOfLeftmostBits = max_nbits_size_t - startBit; + remainingBits -= countOfLeftmostBits; + leftmostBits = (VALUE_SIZE_T(*pp, startBit, countOfLeftmostBits)) << remainingBits; + startBit = 0; + pp++; + } + else + leftmostBits = 0; + + val = leftmostBits + (VALUE_SIZE_T(*pp, startBit, remainingBits)); + + *bitp += nbits; + + return val; +} + int grib_encode_unsigned_long(unsigned char* p, unsigned long val, long* bitp, long nbits) { long* destination = (long*)p; @@ -185,6 +215,46 @@ int grib_encode_unsigned_longb(unsigned char* p, unsigned long val, long* bitp, return grib_encode_unsigned_long(p, val, bitp, nbits); } +int grib_encode_size_t(unsigned char* p, size_t val, long* bitp, long nbits) +{ + long* destination = (long*)p; + long countOfLeftmostBits = 0, nextWord = 0, startBit = 0, remainingBits = 0, rightmostBits = 0; + + startBit = *bitp; + remainingBits = nbits; + + if (startBit >= max_nbits_size_t) { + nextWord = startBit / max_nbits_size_t; + startBit %= max_nbits_size_t; + } + else + nextWord = 0; + + countOfLeftmostBits = startBit + remainingBits; + if (countOfLeftmostBits > max_nbits_size_t) { + countOfLeftmostBits = max_nbits_size_t - startBit; + startBit = max_nbits_size_t - remainingBits; + remainingBits -= countOfLeftmostBits; + destination[nextWord] = + ((destination[nextWord] >> countOfLeftmostBits) << countOfLeftmostBits) + (VALUE_SIZE_T(val, startBit, countOfLeftmostBits)); + startBit = 0; + nextWord++; + } + + rightmostBits = VALUE_SIZE_T(val, max_nbits_size_t - remainingBits, remainingBits); + destination[nextWord] = + (destination[nextWord] & ~MASKVALUE_SIZE_T(startBit, remainingBits)) + (rightmostBits << max_nbits_size_t - (remainingBits + startBit)); + + *bitp += nbits; + return GRIB_SUCCESS; +} + +int grib_encode_size_tb(unsigned char* p, size_t val, long* bitp, long nbits) +{ + return grib_encode_size_t(p, val, bitp, nbits); +} + + #if VECTOR #include "grib_bits_fast_big_endian_vector.c" /* Experimental */ #elif OMP diff --git a/src/grib_expression_class_sub_string.c b/src/grib_expression_class_sub_string.c index 1b437fa05..688c663a9 100644 --- a/src/grib_expression_class_sub_string.c +++ b/src/grib_expression_class_sub_string.c @@ -116,14 +116,17 @@ grib_expression* new_sub_string_expression(grib_context* c, const char* value, s if (length == 0) { grib_context_log(c, GRIB_LOG_ERROR, "Invalid substring: length must be > 0"); + grib_context_free_persistent(c, e); return NULL; } if (start > slen) { /* to catch a -ve number passed to start */ grib_context_log(c, GRIB_LOG_ERROR, "Invalid substring: start=%lu", start); + grib_context_free_persistent(c, e); return NULL; } if (start + length > slen) { grib_context_log(c, GRIB_LOG_ERROR, "Invalid substring: start(=%lu)+length(=%lu) > length('%s'))", start, length, value); + grib_context_free_persistent(c, e); return NULL; } diff --git a/src/grib_handle.c b/src/grib_handle.c index 92b82cac4..3a740eca2 100644 --- a/src/grib_handle.c +++ b/src/grib_handle.c @@ -1440,7 +1440,14 @@ grib_action* grib_action_from_filter(const char* filter) grib_action* a = NULL; grib_context* context = grib_context_get_default(); a = grib_parse_file(context, filter); - context->grib_reader = NULL; + + if (context->grib_reader && context->grib_reader->first) { + grib_context_free_persistent(context, context->grib_reader->first->filename); + grib_context_free_persistent(context, context->grib_reader->first); + grib_context_free_persistent(context, context->grib_reader); + } + + context->grib_reader = NULL; return a; } diff --git a/src/grib_index.c b/src/grib_index.c index 4fd0cb2cc..8acb3080c 100644 --- a/src/grib_index.c +++ b/src/grib_index.c @@ -366,9 +366,9 @@ int grib_write_string(FILE* fh, const char* s) return GRIB_SUCCESS; } -int grib_write_identifier(FILE* fh) +int grib_write_identifier(FILE* fh, const char* ID) { - return grib_write_string(fh, "GRBIDX1"); + return grib_write_string(fh, ID); } int grib_write_null_marker(FILE* fh) @@ -557,6 +557,8 @@ grib_index* grib_index_new(grib_context* c, const char* key, int* err) return NULL; } index->context = c; + index->product_kind = PRODUCT_GRIB; + index->unpack_bufr = 0; while ((key = get_key(&p, &type)) != NULL) { keys = grib_index_new_key(c, keys, key, type, err); @@ -835,6 +837,7 @@ int grib_index_write(grib_index* index, const char* filename) int err = 0; FILE* fh; grib_file* files; + char* identifier = NULL; fh = fopen(filename, "w"); if (!fh) { @@ -844,7 +847,10 @@ int grib_index_write(grib_index* index, const char* filename) return GRIB_IO_PROBLEM; } - err = grib_write_identifier(fh); + if (index->product_kind == PRODUCT_GRIB) identifier = "GRBIDX1"; + if (index->product_kind == PRODUCT_BUFR) identifier = "BFRIDX1"; + Assert(identifier); + err = grib_write_identifier(fh, identifier); if (err) { grib_context_log(index->context, (GRIB_LOG_ERROR) | (GRIB_LOG_PERROR), "Unable to write in file %s", filename); @@ -905,6 +911,7 @@ grib_index* grib_index_read(grib_context* c, const char* filename, int* err) char* identifier = NULL; int max = 0; FILE* fh = NULL; + ProductKind product_kind = PRODUCT_GRIB; if (!c) c = grib_context_get_default(); @@ -923,6 +930,8 @@ grib_index* grib_index_read(grib_context* c, const char* filename, int* err) fclose(fh); return NULL; } + + if (strcmp(identifier, "BFRIDX1")==0) product_kind = PRODUCT_BUFR; grib_context_free(c, identifier); *err = grib_read_uchar(fh, &marker); @@ -967,6 +976,7 @@ grib_index* grib_index_read(grib_context* c, const char* filename, int* err) index = (grib_index*)grib_context_malloc_clear(c, sizeof(grib_index)); index->context = c; + index->product_kind = product_kind; index->keys = grib_read_index_keys(c, fh, err); if (*err) @@ -1046,16 +1056,21 @@ int grib_index_search_same(grib_index* index, grib_handle* h) int grib_index_add_file(grib_index* index, const char* filename) { - return _codes_index_add_file(index, filename, CODES_GRIB); + int message_type = 0; + if (index->product_kind == PRODUCT_GRIB) message_type = CODES_GRIB; + else if (index->product_kind == PRODUCT_BUFR) message_type = CODES_BUFR; + else return GRIB_INVALID_ARGUMENT; + + return _codes_index_add_file(index, filename, message_type); } -grib_handle* new_message_from_file(int message_type, grib_context* c, FILE* f, int* error) +static grib_handle* new_message_from_file(int message_type, grib_context* c, FILE* f, int* error) { if (message_type == CODES_GRIB) return grib_new_from_file(c, f, 0, error); /* headers_only=0 */ if (message_type == CODES_BUFR) return bufr_new_from_file(c, f, error); - Assert(0); + Assert(!"new_message_from_file: invalid message type"); return NULL; } @@ -1120,6 +1135,15 @@ int _codes_index_add_file(grib_index* index, const char* filename, int message_t field_tree = index->fields; index_key->value[0] = 0; message_count++; + + if (index->product_kind == PRODUCT_BUFR && index->unpack_bufr) { + err = grib_set_long(h, "unpack", 1); + if (err) { + grib_context_log(c, GRIB_LOG_ERROR, "unable to unpack BUFR to create index. \"%s\": %s", + index_key->name, grib_get_error_message(err)); + return err; + } + } while (index_key) { if (index_key->type == GRIB_TYPE_UNDEFINED) { @@ -1222,7 +1246,7 @@ int _codes_index_add_file(grib_index* index, const char* filename, int message_t field_tree->field = field; grib_handle_delete(h); - } + }/*foreach message*/ grib_file_close(file->name, 0, &err); @@ -1400,7 +1424,7 @@ int grib_index_add_file(grib_index* index, const char* filename) } #endif -grib_index* grib_index_new_from_file(grib_context* c, char* filename, const char* keys, int* err) +grib_index* grib_index_new_from_file(grib_context* c, const char* filename, const char* keys, int* err) { grib_index* index = NULL; @@ -1576,7 +1600,7 @@ int grib_index_select_double(grib_index* index, const char* skey, double value) return 0; } -int grib_index_select_string(grib_index* index, const char* skey, char* value) +int grib_index_select_string(grib_index* index, const char* skey, const char* value) { grib_index_key* key = NULL; int err = GRIB_NOT_FOUND; @@ -1608,15 +1632,10 @@ int grib_index_select_string(grib_index* index, const char* skey, char* value) return 0; } -grib_handle* grib_index_get_handle(grib_field* field, int* err) -{ - return codes_index_get_handle(field, CODES_GRIB, err); -} - grib_handle* codes_index_get_handle(grib_field* field, int message_type, int* err) { grib_handle* h = NULL; - typedef grib_handle* (*message_new_proc)(grib_context*, FILE*, int, int*); + typedef grib_handle* (*message_new_proc)(grib_context*, FILE*, int*); message_new_proc message_new = NULL; if (!field->file) { @@ -1631,18 +1650,19 @@ grib_handle* codes_index_get_handle(grib_field* field, int message_type, int* er return NULL; switch (message_type) { case CODES_GRIB: - message_new = grib_new_from_file; + message_new = codes_grib_handle_new_from_file; break; case CODES_BUFR: - Assert(!"_codes_index_add_file for BUFR: not yet implemented"); - /* message_new=bufr_new_from_file; */ + message_new = codes_bufr_handle_new_from_file; break; default: - Assert(0); + grib_context_log(grib_context_get_default(), GRIB_LOG_ERROR, "codes_index_get_handle: invalid message type"); + *err = GRIB_INTERNAL_ERROR; + return NULL; } fseeko(field->file->handle, field->offset, SEEK_SET); - h = message_new(0, field->file->handle, 0, err); + h = message_new(0, field->file->handle, err); if (*err != GRIB_SUCCESS) return NULL; @@ -1830,7 +1850,12 @@ char* grib_get_field_file(grib_index* index, off_t* offset) grib_handle* grib_handle_new_from_index(grib_index* index, int* err) { - return codes_new_from_index(index, CODES_GRIB, err); + ProductKind pkind = index->product_kind; + if (pkind == PRODUCT_GRIB) + return codes_new_from_index(index, CODES_GRIB, err); + if (pkind == PRODUCT_BUFR) + return codes_new_from_index(index, CODES_BUFR, err); + return NULL; } grib_handle* codes_new_from_index(grib_index* index, int message_type, int* err) @@ -1932,3 +1957,60 @@ int grib_index_search(grib_index* index, grib_index_key* keys) grib_index_rewind(index); return 0; } + +int codes_index_set_product_kind(grib_index* index, ProductKind product_kind) +{ + if (!index) + return GRIB_INVALID_ARGUMENT; + + if (product_kind == PRODUCT_GRIB || product_kind == PRODUCT_BUFR) { + index->product_kind = product_kind; + } else { + return GRIB_INVALID_ARGUMENT; + } + return GRIB_SUCCESS; +} + +int codes_index_set_unpack_bufr(grib_index* index, int unpack) +{ + if (!index) + return GRIB_INVALID_ARGUMENT; + if (index->product_kind != PRODUCT_BUFR) + return GRIB_INVALID_ARGUMENT; + index->unpack_bufr = unpack; + return GRIB_SUCCESS; +} + +/* Return 1 if the file is an index file. 0 otherwise */ +int is_index_file(const char* filename) +{ + FILE* fh; + char buf[8] = {0,}; + /* Only read the first 6 characters of identifier. Exclude version */ + const size_t numChars = 6; + const char* id_grib = "GRBIDX"; + const char* id_bufr = "BFRIDX"; + int ret = 0; + size_t size = 0; + + fh = fopen(filename, "r"); + if (!fh) + return 0; + + size = fread(buf, 1, 1, fh); + if (size != 1) { + fclose(fh); + return 0; + } + size = fread(buf, numChars, 1, fh); + if (size != 1) { + fclose(fh); + return 0; + } + + ret = (strcmp(buf, id_grib)==0 || strcmp(buf, id_bufr)==0); + + fclose(fh); + + return ret; +} diff --git a/src/grib_parse_utils.c b/src/grib_parse_utils.c index 0b74b16ef..802783d02 100644 --- a/src/grib_parse_utils.c +++ b/src/grib_parse_utils.c @@ -351,6 +351,7 @@ int grib_accessors_list_print(grib_handle* h, grib_accessors_list* al, const cha *newline = 1; cols = 0; } + grib_context_free(h->context, cvals[i]); } } grib_context_free(h->context, cvals); @@ -485,6 +486,7 @@ int grib_recompose_print(grib_handle* h, grib_accessor* observer, const char* un case ']': loc[mode] = 0; mode = -1; + if (al) grib_accessors_list_delete(h->context, al); al = grib_find_accessors_list(h, loc); /* This allocates memory */ if (!al) { if (!fail) { @@ -731,7 +733,8 @@ static int parse(grib_context* gc, const char* filename) parse_file = 0; if (err) - grib_context_log(gc, GRIB_LOG_ERROR, "Parsing error %d > %s\n", err, filename); + grib_context_log(gc, GRIB_LOG_ERROR, "Parsing error: %s, file: %s\n", + grib_get_error_message(err), filename); GRIB_MUTEX_UNLOCK(&mutex_parse); return err; diff --git a/src/grib_util.c b/src/grib_util.c index 9e76d22f4..8366d5531 100644 --- a/src/grib_util.c +++ b/src/grib_util.c @@ -974,9 +974,13 @@ grib_handle* grib_util_set_spec2(grib_handle* h, if (strcmp(input_packing_type, "grid_ccsds") && !strcmp(input_packing_type, "grid_simple")) SET_STRING_VALUE("packingType", "grid_ccsds"); break; + case GRIB_UTIL_PACKING_TYPE_IEEE: + if (strcmp(input_packing_type, "grid_ieee") && !strcmp(input_packing_type, "grid_simple")) + SET_STRING_VALUE("packingType", "grid_ieee"); + break; case GRIB_UTIL_PACKING_TYPE_GRID_SECOND_ORDER: /* we delay the set of grid_second_order because we don't want - to do it on a field with bitsPerValue=0 */ + to do it on a field with bitsPerValue=0 */ setSecondOrder = 1; break; default: @@ -1255,18 +1259,17 @@ grib_handle* grib_util_set_spec2(grib_handle* h, COPY_SPEC_LONG(Ni); /* same as Nx */ COPY_SPEC_LONG(Nj); /* same as Ny */ /* TODO - * pass in extra keys e.g. Dx, Dy, standardParallel and centralLongitude - */ + * pass in extra keys e.g. Dx, Dy, standardParallel and centralLongitude + */ /* - COPY_SPEC_LONG(DxInMetres); - COPY_SPEC_LONG(DyInMetres); - - COPY_SPEC_LONG(xDirectionGridLengthInMillimetres); - COPY_SPEC_LONG(yDirectionGridLengthInMillimetres); - COPY_SPEC_LONG(standardParallelInMicrodegrees); - COPY_SPEC_LONG(centralLongitudeInMicrodegrees); - */ + COPY_SPEC_LONG(DxInMetres); + COPY_SPEC_LONG(DyInMetres); + COPY_SPEC_LONG(xDirectionGridLengthInMillimetres); + COPY_SPEC_LONG(yDirectionGridLengthInMillimetres); + COPY_SPEC_LONG(standardParallelInMicrodegrees); + COPY_SPEC_LONG(centralLongitudeInMicrodegrees); + */ break; case GRIB_UTIL_GRID_SPEC_UNSTRUCTURED: @@ -1274,8 +1277,8 @@ grib_handle* grib_util_set_spec2(grib_handle* h, if (spec->missingValue) COPY_SPEC_DOUBLE(missingValue); /* - * TODO: Other keys - */ + * TODO: Other keys + */ break; case GRIB_UTIL_GRID_SPEC_LAMBERT_CONFORMAL: COPY_SPEC_LONG(bitmapPresent); @@ -1287,14 +1290,14 @@ grib_handle* grib_util_set_spec2(grib_handle* h, COPY_SPEC_LONG(Nj); /* same as Ny */ /* - * Note: DxInMetres and DyInMetres - * should be 'double' and not integer. WMO GRIB2 uses millimetres! - * TODO: - * Add other keys like Latin1, LoV etc + * Note: DxInMetres and DyInMetres + * should be 'double' and not integer. WMO GRIB2 uses millimetres! + * TODO: + * Add other keys like Latin1, LoV etc - *err = GRIB_NOT_IMPLEMENTED; - goto cleanup; - */ + *err = GRIB_NOT_IMPLEMENTED; + goto cleanup; + */ break; case GRIB_UTIL_GRID_SPEC_REDUCED_GG: @@ -1388,23 +1391,27 @@ grib_handle* grib_util_set_spec2(grib_handle* h, break; case GRIB_UTIL_PACKING_TYPE_JPEG: /* Have to delay JPEG packing: - * Reason 1: It is not available in GRIB1 and so we have to wait until we change edition - * Reason 2: It has to be done AFTER we set the data values - */ + * Reason 1: It is not available in GRIB1 and so we have to wait until we change edition + * Reason 2: It has to be done AFTER we set the data values + */ if (strcmp(input_packing_type, "grid_jpeg") && !strcmp(input_packing_type, "grid_simple")) setJpegPacking = 1; break; case GRIB_UTIL_PACKING_TYPE_CCSDS: /* Have to delay CCSDS packing: - * Reason 1: It is not available in GRIB1 and so we have to wait until we change edition - * Reason 2: It has to be done AFTER we set the data values - */ + * Reason 1: It is not available in GRIB1 and so we have to wait until we change edition + * Reason 2: It has to be done AFTER we set the data values + */ if (strcmp(input_packing_type, "grid_ccsds") && !strcmp(input_packing_type, "grid_simple")) setCcsdsPacking = 1; break; + case GRIB_UTIL_PACKING_TYPE_IEEE: + if (strcmp(input_packing_type, "grid_ieee") && !strcmp(input_packing_type, "grid_simple")) + SET_STRING_VALUE("packingType", "grid_ieee"); + break; case GRIB_UTIL_PACKING_TYPE_GRID_SECOND_ORDER: /* we delay the set of grid_second_order because we don't want - to do it on a field with bitsPerValue=0 */ + to do it on a field with bitsPerValue=0 */ setSecondOrder = 1; break; default: @@ -1588,14 +1595,14 @@ grib_handle* grib_util_set_spec2(grib_handle* h, /* grib_write_message(outh,"h.grib","w"); */ /* if the field is empty GRIBEX is packing as simple*/ - /* if (!strcmp(input_packing_type,"grid_simple_matrix")) { - long numberOfValues; - grib_get_long(outh,"numberOfValues",&numberOfValues); - if (numberOfValues==0) { - slen=11; - grib_set_string(outh,"packingType","grid_simple",&slen); - } - } */ + /* if (!strcmp(input_packing_type,"grid_simple_matrix")) { + long numberOfValues; + grib_get_long(outh,"numberOfValues",&numberOfValues); + if (numberOfValues==0) { + slen=11; + grib_set_string(outh,"packingType","grid_simple",&slen); + } + } */ if (grib1_high_resolution_fix) { /* GRIB-863: must set increments to MISSING */ @@ -1917,7 +1924,7 @@ int parse_keyval_string(const char* grib_tool, grib_values values[], int* count) { char* p = NULL; - int i = 0; + int i = 0; if (arg == NULL) { *count = 0; return GRIB_SUCCESS; @@ -2133,36 +2140,6 @@ int grib2_select_PDTN(int is_eps, int is_instant, } } -int is_grib_index_file(const char* filename) -{ - FILE* fh; - char buf[8] = {0,}; - const char* str = "GRBIDX"; - int ret = 0; - size_t size = 0; - - fh = fopen(filename, "r"); - if (!fh) - return 0; - - size = fread(buf, 1, 1, fh); - if (size != 1) { - fclose(fh); - return 0; - } - size = fread(buf, 6, 1, fh); - if (size != 1) { - fclose(fh); - return 0; - } - - ret = !strcmp(buf, str); - - fclose(fh); - - return ret; -} - size_t sum_of_pl_array(const long* pl, size_t plsize) { long i, count = 0; @@ -2191,7 +2168,7 @@ int grib_util_grib_data_quality_check(grib_handle* h, double min_val, double max int is_error = 1; char description[1024] = {0,}; char step[32] = "unknown"; - size_t len = 32; + size_t len = 32; /* * If grib_data_quality_checks == 1, limits failure results in an error * If grib_data_quality_checks == 2, limits failure results in a warning diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index cc2c0fb0f..96170b788 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -48,9 +48,12 @@ endforeach() ################################################# # These tests do not require any data downloads list(APPEND tests_no_data_reqd + unit_tests + julian + grib_dump_samples + bufr_dump_samples definitions grib_calendar - unit_tests grib_md5 filter_substr grib_uerra @@ -59,8 +62,6 @@ list(APPEND tests_no_data_reqd grib_ecc-967 grib_ecc-1065 grib_ecc-1053 - julian - bufr_dump_samples bufr_json_samples bufr_ecc-359 bufr_ecc-517 diff --git a/tests/bufr_dump_subset.sh b/tests/bufr_dump_subset.sh index 2de26de46..ccac94980 100755 --- a/tests/bufr_dump_subset.sh +++ b/tests/bufr_dump_subset.sh @@ -61,7 +61,7 @@ bufr_files=`cat ${data_dir}/bufr/bufr_data_files.txt` for file in ${bufr_files} do # Every file has at least one subset - ${tools_dir}/bufr_dump -S1 ${data_dir}/bufr/$file >/dev/null + ${tools_dir}/bufr_dump -wcount=1 -S1 ${data_dir}/bufr/$file >/dev/null done # Check strict option with 'where' clause diff --git a/tests/grib_decimalPrecision.sh b/tests/grib_decimalPrecision.sh index ff6c91e91..b159eae0d 100755 --- a/tests/grib_decimalPrecision.sh +++ b/tests/grib_decimalPrecision.sh @@ -36,4 +36,13 @@ export ECCODES_FAIL_IF_LOG_MESSAGE=1 ${tools_dir}/grib_set -r -s decimalScaleFactor=0 $infile $temp ${tools_dir}/grib_set -r -s decimalScaleFactor=1 $infile $temp +# Constant field with bitsPerValue=0 and decimalScaleFactor!=0 +sample1=$ECCODES_SAMPLES_PATH/GRIB1.tmpl +sample2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl +${tools_dir}/grib_set -s decimalScaleFactor=3 $sample1 $temp +grib_check_key_equals $temp min,max,const,decimalScaleFactor,referenceValue '47485.4 47485.4 1 3 47485.4' +${tools_dir}/grib_set -s decimalScaleFactor=3 $sample2 $temp +grib_check_key_equals $temp min,max,const,decimalScaleFactor,referenceValue '1 1 1 3 1' + + rm -f $temp diff --git a/tests/grib_dump.sh b/tests/grib_dump.sh index 6ef2994c1..8e539f14c 100755 --- a/tests/grib_dump.sh +++ b/tests/grib_dump.sh @@ -12,6 +12,9 @@ REDIRECT=/dev/null +label="grib_dump_test" +temp=temp.$label.txt + if [ $HAVE_MEMFS -eq 1 ]; then unset ECCODES_DEFINITION_PATH unset ECCODES_SAMPLES_PATH @@ -76,3 +79,23 @@ for file in $files; do ${tools_dir}/grib_dump -O ${data_dir}/$file 2> $REDIRECT > $REDIRECT fi done + + +# Test for dumping a section +if [ $HAVE_JPEG -eq 0 ]; then + # No JPEG decoding enabled so dumping section 7 will issue errors + # but dumping non-data sections should work + file=${data_dir}/jpeg.grib2 + ${tools_dir}/grib_dump -O -p section_3,section_4 $file > $temp 2>&1 + set +e + # Look for the word ERROR in output. We should not find any + grep -q 'ERROR ' $temp + if [ $? -eq 0 ]; then + echo "grib_dump on $file: found string ERROR in grib_dump output!" + cat $temp + exit 1 + fi + set -e +fi + +rm -f $temp diff --git a/tests/grib_dump_samples.sh b/tests/grib_dump_samples.sh new file mode 100755 index 000000000..98ec8de41 --- /dev/null +++ b/tests/grib_dump_samples.sh @@ -0,0 +1,34 @@ +#!/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.sh + +# Define a common label for all the tmp files +label="grib_dump_samples_test" +temp=${label}".temp" + +# Test selected sample GRIB files +samples=" + GRIB1.tmpl + GRIB2.tmpl + sh_ml_grib1.tmpl + sh_ml_grib2.tmpl + reduced_gg_pl_48_grib1.tmpl + reduced_gg_pl_48_grib2.tmpl + regular_ll_sfc_grib1.tmpl + regular_ll_sfc_grib2.tmpl +" +for file in $samples; do + sf="$ECCODES_SAMPLES_PATH/$file" + ${tools_dir}/grib_dump -O $sf >/dev/null +done + + +rm -f $temp diff --git a/tests/grib_tigge_conversions.sh b/tests/grib_tigge_conversions.sh index 6e8519363..e63f1da40 100755 --- a/tests/grib_tigge_conversions.sh +++ b/tests/grib_tigge_conversions.sh @@ -16,7 +16,7 @@ REDIRECT=/dev/null -dir="${data_dir}/tigge/" +dir="${data_dir}/tigge" temp1="temp.grib1_" temp2="temp.grib2_" diff --git a/tests/grib_util_set_spec.c b/tests/grib_util_set_spec.c index fdcccb01a..805fbec69 100644 --- a/tests/grib_util_set_spec.c +++ b/tests/grib_util_set_spec.c @@ -28,6 +28,8 @@ static int get_packing_type_code(const char* packingType) result = GRIB_UTIL_PACKING_TYPE_GRID_SIMPLE; else if (STR_EQUAL(packingType, "grid_second_order")) result = GRIB_UTIL_PACKING_TYPE_GRID_SECOND_ORDER; + else if (STR_EQUAL(packingType, "grid_ieee")) + result = GRIB_UTIL_PACKING_TYPE_IEEE; return result; } diff --git a/tests/include.ctest.sh.in b/tests/include.ctest.sh.in index 7c8bd867e..80483107a 100644 --- a/tests/include.ctest.sh.in +++ b/tests/include.ctest.sh.in @@ -2,6 +2,7 @@ set -ea # For CMake set -x +echo "Script: $0" proj_dir=@PROJECT_SOURCE_DIR@ build_dir=@PROJECT_BINARY_DIR@ diff --git a/tests/lsan-leap42.supp b/tests/lsan-leap42.supp index c58d0a921..d11c22254 100644 --- a/tests/lsan-leap42.supp +++ b/tests/lsan-leap42.supp @@ -1,8 +1,3 @@ -leak:tools/grib_filter.c -leak:tools/bufr_filter.c -leak:tools/bufr_dump.c -leak:tools/bufr_compare.c -leak:tools/gts_filter.c -leak:src/action_class_rename.c -leak:tools/grib_to_netcdf.c +leak:process_elements leak:tests/bufr_ecc-517.c +leak:src/action_class_rename.c diff --git a/tools/bufr_compare.c b/tools/bufr_compare.c index 0babb11cd..0768d37c5 100644 --- a/tools/bufr_compare.c +++ b/tools/bufr_compare.c @@ -236,14 +236,14 @@ static int counter = 0; static int start = -1; static int end = -1; -const char* grib_tool_description = +const char* tool_description = "Compare BUFR messages contained in two files." "\n\tIf some differences are found it fails returning an error code." "\n\tFloating-point values are compared exactly by default, different tolerance can be defined see -P -A -R." "\n\tDefault behaviour: absolute error=0, bit-by-bit compare, same order in files."; -const char* grib_tool_name = "bufr_compare"; -const char* grib_tool_usage = "[options] bufr_file1 bufr_file2"; +const char* tool_name = "bufr_compare"; +const char* tool_usage = "[options] bufr_file1 bufr_file2"; int grib_options_count = sizeof(grib_options) / sizeof(grib_option); @@ -326,7 +326,7 @@ int grib_tool_init(grib_runtime_options* options) } /* Check 1st file is not a directory */ - exit_if_input_is_directory(grib_tool_name, options->infile_extra->name); + exit_if_input_is_directory(tool_name, options->infile_extra->name); if (grib_options_on("r")) { char* filename[1]; @@ -388,7 +388,7 @@ int grib_tool_init(grib_runtime_options* options) if (grib_options_on("R:")) { char* sarg = grib_options_get_option("R:"); options->tolerance_count = MAX_KEYS; - ret = parse_keyval_string(grib_tool_name, sarg, 1, GRIB_TYPE_DOUBLE, options->tolerance, &(options->tolerance_count)); + ret = parse_keyval_string(tool_name, sarg, 1, GRIB_TYPE_DOUBLE, options->tolerance, &(options->tolerance_count)); if (ret == GRIB_INVALID_ARGUMENT) { usage(); exit(1); @@ -426,7 +426,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file) { - exit_if_input_is_directory(grib_tool_name, file->name); + exit_if_input_is_directory(tool_name, file->name); return 0; } diff --git a/tools/bufr_copy.c b/tools/bufr_copy.c index 56edaa81a..cc8dedc19 100644 --- a/tools/bufr_copy.c +++ b/tools/bufr_copy.c @@ -15,12 +15,12 @@ #include "grib_tools.h" -const char* grib_tool_description = +const char* tool_description = "Copies the content of BUFR files printing" " values of some keys." "\n\tIf the name of the output_bufr_file contains a key enclosed in square brackets, its value will be used."; -const char* grib_tool_name = "bufr_copy"; -const char* grib_tool_usage = "[options] bufr_file bufr_file ... output_bufr_file"; +const char* tool_name = "bufr_copy"; +const char* tool_usage = "[options] bufr_file bufr_file ... output_bufr_file"; grib_option grib_options[] = { /* {id, args, help}, on, command_line, value */ @@ -90,7 +90,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file) { - exit_if_input_is_directory(grib_tool_name, file->name); + exit_if_input_is_directory(tool_name, file->name); return 0; } diff --git a/tools/bufr_dump.c b/tools/bufr_dump.c index 35cd43183..b438b6b52 100644 --- a/tools/bufr_dump.c +++ b/tools/bufr_dump.c @@ -62,9 +62,9 @@ grib_option grib_options[] = { /* {"x",0,0,0,1,0} */ }; -const char* grib_tool_description = "Dump the content of a BUFR file in different formats."; -const char* grib_tool_name = "bufr_dump"; -const char* grib_tool_usage = "[options] bufr_file bufr_file ..."; +const char* tool_description = "Dump the content of a BUFR file in different formats."; +const char* tool_name = "bufr_dump"; +const char* tool_usage = "[options] bufr_file bufr_file ..."; static int json = 0; static int dump_descriptors = 0; static char* json_option = 0; @@ -108,7 +108,7 @@ int grib_tool_init(grib_runtime_options* options) options->strict = 1; /* Must set here as bufr_dump has its own -S option */ if (opt > 1) { - printf("%s: simultaneous j/C/O options not allowed\n", grib_tool_name); + printf("%s: simultaneous j/C/O options not allowed\n", tool_name); exit(1); } @@ -116,7 +116,7 @@ int grib_tool_init(grib_runtime_options* options) options->dump_mode = "json"; json_option = grib_options_get_option("j:"); if (strlen(json_option) > 1 || (json_option[0] != 's' && json_option[0] != 'f' && json_option[0] != 'a')) { - printf("%s: Invalid JSON option %s\n", grib_tool_name, json_option); + printf("%s: Invalid JSON option %s\n", tool_name, json_option); exit(1); } json = 1; @@ -186,6 +186,32 @@ int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* fi { if (!options->current_infile->name) return 0; + + Assert(file); + exit_if_input_is_directory(tool_name, file->name); + + /* + * Dumping of index files + */ + if (is_index_file(options->current_infile->name)) { + int err = 0; + grib_context* c = grib_context_get_default(); + const char* filename = options->current_infile->name; + + err = grib_index_dump_file(stdout, filename); + if (err) { + grib_context_log(c, GRIB_LOG_ERROR, "%s: Could not dump index file \"%s\".\n%s\n", + tool_name, + filename, + grib_get_error_message(err)); + exit(1); + } + /* Since there are no BUFR messages, we have to stop tool exiting in case there + * are more index files */ + options->fail = 0; + return 0; + } + if (json) return 0; diff --git a/tools/bufr_filter.c b/tools/bufr_filter.c index 37db191d8..7d63a4e2f 100644 --- a/tools/bufr_filter.c +++ b/tools/bufr_filter.c @@ -30,12 +30,12 @@ grib_option grib_options[] = { { "7", 0, 0, 0, 1, 0 }, { "v", 0, 0, 0, 1, 0 } }; -const char* grib_tool_description = +const char* tool_description = "Apply the rules defined in rules_file to each BUFR " "message\n\tin the BUFR files provided as arguments.\n\t" "If you specify '-' (a single dash) for the rules_file, the rules will be read from standard input."; -const char* grib_tool_name = "bufr_filter"; -const char* grib_tool_usage = +const char* tool_name = "bufr_filter"; +const char* tool_usage = "[options] rules_file " "bufr_file bufr_file ..."; @@ -55,7 +55,9 @@ int grib_tool_init(grib_runtime_options* options) { options->action = grib_action_from_filter(options->infile_extra->name); if (!options->action) { - fprintf(stderr, "%s: error unable to create action\n", options->infile_extra->name); + const char* filt = options->infile_extra->name; + if (strcmp(filt, "-")==0) filt = "stdin"; + fprintf(stderr, "Error: %s: unable to create action\n", filt); exit(1); } @@ -75,7 +77,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file) { - exit_if_input_is_directory(grib_tool_name, file->name); + exit_if_input_is_directory(tool_name, file->name); return 0; } @@ -112,7 +114,7 @@ int grib_tool_finalise_action(grib_runtime_options* options) int err = 0; grib_file_close_all(&err); if (err != GRIB_SUCCESS) { - perror(grib_tool_name); + perror(tool_name); exit(err); } diff --git a/tools/bufr_get.c b/tools/bufr_get.c index 8e35a819d..73bfce41a 100644 --- a/tools/bufr_get.c +++ b/tools/bufr_get.c @@ -35,12 +35,12 @@ grib_option grib_options[] = { { "v", 0, 0, 1, 0, 0 } }; -const char* grib_tool_description = +const char* tool_description = "Get values of some header keys from a BUFR file." "\n\tIt is similar to bufr_ls, but fails returning an error code " "\n\twhen an error occurs (e.g. key not found)."; -const char* grib_tool_name = "bufr_get"; -const char* grib_tool_usage = "[options] file file ..."; +const char* tool_name = "bufr_get"; +const char* tool_usage = "[options] file file ..."; int grib_options_count = sizeof(grib_options) / sizeof(grib_option); @@ -71,7 +71,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file) { - exit_if_input_is_directory(grib_tool_name, file->name); + exit_if_input_is_directory(tool_name, file->name); return 0; } diff --git a/tools/bufr_index_build.c b/tools/bufr_index_build.c index 119727330..59d075568 100644 --- a/tools/bufr_index_build.c +++ b/tools/bufr_index_build.c @@ -15,11 +15,11 @@ #include "grib_tools.h" -const char* grib_tool_description = +const char* tool_description = "Build an index file for a set of input BUFR files.\n" "\tWarning: THIS TOOL IS NOT YET IMPLEMENTED"; -const char* grib_tool_name = "bufr_index_build"; -const char* grib_tool_usage = "[options] file file ... "; +const char* tool_name = "bufr_index_build"; +const char* tool_usage = "[options] file file ... "; grib_index* idx = NULL; char* keys; char* default_keys = "mars"; @@ -41,7 +41,7 @@ grib_option grib_options[] = { 0, 1, 0 } }; -int compress_index; +static int compress_index; int grib_options_count = sizeof(grib_options) / sizeof(grib_option); @@ -73,6 +73,8 @@ int grib_tool_init(grib_runtime_options* options) options->onlyfiles = 1; idx = grib_index_new(c, keys, &ret); + codes_index_set_product_kind(idx, PRODUCT_BUFR); + codes_index_set_unpack_bufr(idx, 1); if (!idx || ret) grib_context_log(c, GRIB_LOG_FATAL, @@ -84,8 +86,8 @@ int grib_tool_init(grib_runtime_options* options) int grib_tool_new_filename_action(grib_runtime_options* options, const char* file) { int ret = 0; - printf("--- %s: processing %s\n", grib_tool_name, file); - ret = _codes_index_add_file(idx, file, CODES_BUFR); + printf("--- %s: processing %s\n", tool_name, file); + ret = grib_index_add_file(idx, file); if (ret) { printf("error: %s\n", grib_get_error_message(ret)); exit(ret); @@ -122,7 +124,7 @@ int grib_tool_finalise_action(grib_runtime_options* options) grib_index_compress(idx); } printf("--- %s: keys included in the index file %s:\n", - grib_tool_name, options->outfile->name); + tool_name, options->outfile->name); printf("--- "); first = 1; the_keys = idx->keys; diff --git a/tools/bufr_ls.c b/tools/bufr_ls.c index 8ba250f49..52b98e3ec 100644 --- a/tools/bufr_ls.c +++ b/tools/bufr_ls.c @@ -37,12 +37,12 @@ grib_option grib_options[] = { { "v", 0, 0, 1, 0, 0 } }; -const char* grib_tool_description = +const char* tool_description = "List content of BUFR files printing values of " "some header keys.\n\tOnly scalar keys can be printed." "\n\tIt does not fail when a key is not found."; -const char* grib_tool_name = "bufr_ls"; -const char* grib_tool_usage = "[options] bufr_file bufr_file ..."; +const char* tool_name = "bufr_ls"; +const char* tool_usage = "[options] bufr_file bufr_file ..."; static int first_handle = 1; int grib_options_count = sizeof(grib_options) / sizeof(grib_option); @@ -84,7 +84,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file) { - exit_if_input_is_directory(grib_tool_name, file->name); + exit_if_input_is_directory(tool_name, file->name); return 0; } diff --git a/tools/bufr_set.c b/tools/bufr_set.c index abddf5dc5..caf0c0547 100644 --- a/tools/bufr_set.c +++ b/tools/bufr_set.c @@ -42,12 +42,12 @@ grib_option grib_options[] = { { "v", 0, 0, 0, 1, 0 } }; -const char* grib_tool_description = +const char* tool_description = "Sets key/value pairs in the input BUFR file and writes" "\n\teach message to the output_file." "\n\tIt fails when an error occurs (e.g. key not found)."; -const char* grib_tool_name = "bufr_set"; -const char* grib_tool_usage = "[options] file file ... output_file"; +const char* tool_name = "bufr_set"; +const char* tool_usage = "[options] file file ... output_file"; int grib_options_count = sizeof(grib_options) / sizeof(grib_option); @@ -166,7 +166,7 @@ int grib_tool_finalise_action(grib_runtime_options* options) int err = 0; grib_file_close_all(&err); if (err != GRIB_SUCCESS) { - perror(grib_tool_name); + perror(tool_name); exit(err); } diff --git a/tools/codes_count.c b/tools/codes_count.c index beb5763b9..ff92c59f4 100644 --- a/tools/codes_count.c +++ b/tools/codes_count.c @@ -11,7 +11,7 @@ #include "grib_api_internal.h" static int fail_on_error = 1; -static const char* tool_name = NULL; +static const char* toolname = NULL; static void usage(const char* prog) { @@ -81,15 +81,15 @@ int main(int argc, char* argv[]) unsigned long count_total = 0, count_curr = 0; int message_type = 0; /* GRIB, BUFR etc */ - tool_name = argv[0]; + toolname = argv[0]; if (argc < 2) - usage(tool_name); + usage(toolname); - if (strstr(tool_name, "grib_count")) + if (strstr(toolname, "grib_count")) message_type = CODES_GRIB; - if (strstr(tool_name, "bufr_count")) + if (strstr(toolname, "bufr_count")) message_type = CODES_BUFR; - if (strstr(tool_name, "gts_count")) + if (strstr(toolname, "gts_count")) message_type = CODES_GTS; count_total = 0; @@ -104,7 +104,7 @@ int main(int argc, char* argv[]) } filename = argv[i]; if (path_is_directory(filename)) { - fprintf(stderr, "%s: ERROR: \"%s\": Is a directory\n", tool_name, filename); + fprintf(stderr, "%s: ERROR: \"%s\": Is a directory\n", toolname, filename); continue; } diff --git a/tools/codes_info.c b/tools/codes_info.c index 4cfad50fc..4aa9184fa 100644 --- a/tools/codes_info.c +++ b/tools/codes_info.c @@ -87,6 +87,7 @@ int main(int argc, char* argv[]) if ((path = getenv("ECCODES_DEFINITION_PATH")) != NULL) { printf("Definition files path from environment variable"); printf(" ECCODES_DEFINITION_PATH=%s\n", path); + printf("Full definition files path=%s\n", context->grib_definition_files_path); } else if ((path = getenv("GRIB_DEFINITION_PATH")) != NULL) { printf("Definition files path from environment variable"); @@ -94,6 +95,7 @@ int main(int argc, char* argv[]) printf( "(This is for backward compatibility. " "It is recommended you use ECCODES_DEFINITION_PATH instead!)\n"); + printf("Full definition files path=%s\n", context->grib_definition_files_path); } else { printf("Default definition files path is used: %s\n", context->grib_definition_files_path); diff --git a/tools/deprecated/grib_convert.c b/tools/deprecated/grib_convert.c index 68f1fd80c..f6fd74e47 100644 --- a/tools/deprecated/grib_convert.c +++ b/tools/deprecated/grib_convert.c @@ -32,14 +32,14 @@ grib_option grib_options[]={ {"v",0,0,0,1,0} }; -char* grib_tool_description= +char* tool_description= "It converts grib messages applying the rules from a conversion_rules file." "\n\tThe rules are of the type \"keyname = value;\" and if blocks are allowed as" "\n\tif ( keyname1 == value1 || keyname2 != value2 && keyname3 == value3 ) {" "\n\t keyname4 = value4;" "\n\t}"; -char* grib_tool_name="grib_convert"; -char* grib_tool_usage="[options] conversion_rules " +char* tool_name="grib_convert"; +char* tool_usage="[options] conversion_rules " "grib_file grib_file ... output_grib_file"; int grib_options_count=sizeof(grib_options)/sizeof(grib_option); diff --git a/tools/deprecated/grib_debug.c b/tools/deprecated/grib_debug.c index bd0af3057..4794fb652 100644 --- a/tools/deprecated/grib_debug.c +++ b/tools/deprecated/grib_debug.c @@ -29,9 +29,9 @@ grib_option grib_options[]={ {"q",0,0,1,0,0} }; -char* grib_tool_description="Dump the content of a grib file in debug mode."; -char* grib_tool_name="grib_debug"; -char* grib_tool_usage="[options] grib_file grib_file ..."; +char* tool_description="Dump the content of a grib file in debug mode."; +char* tool_name="grib_debug"; +char* tool_usage="[options] grib_file grib_file ..."; int grib_options_count=sizeof(grib_options)/sizeof(grib_option); diff --git a/tools/deprecated/grib_keys.c b/tools/deprecated/grib_keys.c index d7b5e6482..f4229e6a3 100644 --- a/tools/deprecated/grib_keys.c +++ b/tools/deprecated/grib_keys.c @@ -29,10 +29,10 @@ grib_option grib_options[]={ {"a",0,0,0,1,0} }; -char* grib_tool_description="Lists the keys available for a type of grib (-T option) or \n" +char* tool_description="Lists the keys available for a type of grib (-T option) or \n" "\tin a grib message from a file (-F option)."; -char* grib_tool_name="grib_keys"; -char* grib_tool_usage="[options]"; +char* tool_name="grib_keys"; +char* tool_usage="[options]"; char name[1024]; int grib_options_count=sizeof(grib_options)/sizeof(grib_option); diff --git a/tools/deprecated/grib_points.c b/tools/deprecated/grib_points.c index 7e756df31..834f12a08 100644 --- a/tools/deprecated/grib_points.c +++ b/tools/deprecated/grib_points.c @@ -34,9 +34,9 @@ grib_option grib_options[]={ {"v",0,0,1,0,0} }; -char* grib_tool_description="Lat lon values list for given points list. "; -char* grib_tool_name="grib_points"; -char* grib_tool_usage="file_list_of_points grib_file grib_file ..."; +char* tool_description="Lat lon values list for given points list. "; +char* tool_name="grib_points"; +char* tool_usage="file_list_of_points grib_file grib_file ..."; int grib_options_count=sizeof(grib_options)/sizeof(grib_option); double lat=0; @@ -79,7 +79,7 @@ int grib_tool_init(grib_runtime_options* options) { } else if (*end1 == '1') { options->latlon_mode=1; } else { - printf("ERROR %s: wrong mode given in option -l\n",grib_tool_name); + printf("ERROR %s: wrong mode given in option -l\n",tool_name); exit(1); } } diff --git a/tools/grib_compare.c b/tools/grib_compare.c index dfefcdda0..9af9b8c9c 100644 --- a/tools/grib_compare.c +++ b/tools/grib_compare.c @@ -165,14 +165,14 @@ static int global_counter = 0; static int theStart = -1; static int theEnd = -1; -const char* grib_tool_description = +const char* tool_description = "Compare GRIB messages contained in two files." "\n\tIf some differences are found it fails returning an error code." "\n\tFloating-point values are compared exactly by default, different tolerance can be defined see -P -A -R." "\n\tDefault behaviour: absolute error=0, bit-by-bit compare, same order in files."; -const char* grib_tool_name = "grib_compare"; -const char* grib_tool_usage = "[options] grib_file1 grib_file2"; +const char* tool_name = "grib_compare"; +const char* tool_usage = "[options] grib_file1 grib_file2"; int grib_options_count = sizeof(grib_options) / sizeof(grib_option); @@ -319,7 +319,7 @@ int grib_tool_init(grib_runtime_options* options) if (grib_options_on("R:")) { char* sarg = grib_options_get_option("R:"); options->tolerance_count = MAX_KEYS; - ret = parse_keyval_string(grib_tool_name, sarg, 1, GRIB_TYPE_DOUBLE, options->tolerance, &(options->tolerance_count)); + ret = parse_keyval_string(tool_name, sarg, 1, GRIB_TYPE_DOUBLE, options->tolerance, &(options->tolerance_count)); if (ret == GRIB_INVALID_ARGUMENT) { usage(); exit(1); diff --git a/tools/grib_copy.c b/tools/grib_copy.c index ebed96068..974bb4550 100644 --- a/tools/grib_copy.c +++ b/tools/grib_copy.c @@ -15,12 +15,12 @@ #include "grib_tools.h" -const char* grib_tool_description = +const char* tool_description = "Copies the content of GRIB files printing" " values of some keys." "\n\tIf the name of the output_grib_file contains a key enclosed in square brackets, its value will be used."; -const char* grib_tool_name = "grib_copy"; -const char* grib_tool_usage = "[options] grib_file grib_file ... output_grib_file"; +const char* tool_name = "grib_copy"; +const char* tool_usage = "[options] grib_file grib_file ... output_grib_file"; grib_option grib_options[] = { /* {id, args, help}, on, command_line, value */ @@ -94,7 +94,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file) { - exit_if_input_is_directory(grib_tool_name, file->name); + exit_if_input_is_directory(tool_name, file->name); return 0; } @@ -145,7 +145,7 @@ int grib_tool_finalise_action(grib_runtime_options* options) int err = 0; grib_file_close_all(&err); if (err != GRIB_SUCCESS) { - perror(grib_tool_name); + perror(tool_name); exit(err); } /* if (options->outfile->file) diff --git a/tools/grib_dump.c b/tools/grib_dump.c index 9541e8908..dce8fba64 100644 --- a/tools/grib_dump.c +++ b/tools/grib_dump.c @@ -39,9 +39,9 @@ grib_option grib_options[] = { { "x", 0, 0, 0, 1, 0 } }; -const char* grib_tool_description = "Dump the content of a GRIB file in different formats."; -const char* grib_tool_name = "grib_dump"; -const char* grib_tool_usage = "[options] grib_file grib_file ..."; +const char* tool_description = "Dump the content of a GRIB file in different formats."; +const char* tool_name = "grib_dump"; +const char* tool_usage = "[options] grib_file grib_file ..."; static int json = 0; static int first_handle = 1; static int dump_keys = 0; @@ -69,7 +69,7 @@ int grib_tool_init(grib_runtime_options* options) options->dump_mode = "default"; if (opt > 1) { - printf("%s: simultaneous j/O/D options not allowed\n", grib_tool_name); + printf("%s: simultaneous j/O/D options not allowed\n", tool_name); exit(1); } @@ -129,35 +129,34 @@ int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* fi if (json) return 0; - exit_if_input_is_directory(grib_tool_name, file->name); + Assert(file); + exit_if_input_is_directory(tool_name, file->name); sprintf(tmp, "FILE: %s ", options->current_infile->name); if (!grib_options_on("C")) fprintf(stdout, "***** %s\n", tmp); /* - * In debug dump mode, allow dumping of GRIB index files + * Dumping of index files */ - if (strcmp(options->dump_mode, "debug") == 0) { - if (is_grib_index_file(options->current_infile->name)) { - int err = 0; - grib_context* c = grib_context_get_default(); - const char* filename = options->current_infile->name; + if (is_index_file(options->current_infile->name)) { + int err = 0; + grib_context* c = grib_context_get_default(); + const char* filename = options->current_infile->name; - err = grib_index_dump_file(stdout, filename); - if (err) { - grib_context_log(c, GRIB_LOG_ERROR, "%s: Could not dump index file \"%s\".\n%s\n", - grib_tool_name, - filename, - grib_get_error_message(err)); - exit(1); - } - /* Since there are no GRIB messages, we have to stop tool exiting in case there - * are more index files - */ - options->fail = 0; + err = grib_index_dump_file(stdout, filename); + if (err) { + grib_context_log(c, GRIB_LOG_ERROR, "%s: Could not dump index file \"%s\".\n%s\n", + tool_name, + filename, + grib_get_error_message(err)); + exit(1); } + /* Since there are no GRIB messages, we have to stop tool exiting in case there + * are more index files */ + options->fail = 0; } + return 0; } diff --git a/tools/grib_filter.c b/tools/grib_filter.c index 839ab3795..6fd0d6233 100644 --- a/tools/grib_filter.c +++ b/tools/grib_filter.c @@ -26,12 +26,12 @@ grib_option grib_options[] = { { "7", 0, 0, 0, 1, 0 }, { "v", 0, 0, 0, 1, 0 } }; -const char* grib_tool_description = +const char* tool_description = "Apply the rules defined in rules_file to each GRIB " "message\n\tin the GRIB files provided as arguments.\n\t" "If you specify '-' (a single dash) for the rules_file, the rules will be read from standard input."; -const char* grib_tool_name = "grib_filter"; -const char* grib_tool_usage = +const char* tool_name = "grib_filter"; +const char* tool_usage = "[options] rules_file " "grib_file grib_file ..."; @@ -51,7 +51,9 @@ int grib_tool_init(grib_runtime_options* options) { options->action = grib_action_from_filter(options->infile_extra->name); if (!options->action) { - fprintf(stderr, "%s: error unable to create action\n", options->infile_extra->name); + const char* filt = options->infile_extra->name; + if (strcmp(filt, "-")==0) filt = "stdin"; + fprintf(stderr, "Error: %s: unable to create action\n", filt); exit(1); } @@ -68,7 +70,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file) { - exit_if_input_is_directory(grib_tool_name, file->name); + exit_if_input_is_directory(tool_name, file->name); return 0; } @@ -105,7 +107,7 @@ int grib_tool_finalise_action(grib_runtime_options* options) int err = 0; grib_file_close_all(&err); if (err != GRIB_SUCCESS) { - perror(grib_tool_name); + perror(tool_name); exit(err); } diff --git a/tools/grib_get.c b/tools/grib_get.c index c82240c37..5c9340a6b 100644 --- a/tools/grib_get.c +++ b/tools/grib_get.c @@ -35,12 +35,12 @@ grib_option grib_options[] = { { "i:", 0, 0, 0, 1, 0 } }; -const char* grib_tool_description = +const char* tool_description = "Get values of some keys from a GRIB file." "\n\tIt is similar to grib_ls, but fails returning an error code " "\n\twhen an error occurs (e.g. key not found)."; -const char* grib_tool_name = "grib_get"; -const char* grib_tool_usage = "[options] grib_file grib_file ..."; +const char* tool_name = "grib_get"; +const char* tool_usage = "[options] grib_file grib_file ..."; int grib_options_count = sizeof(grib_options) / sizeof(grib_option); static double lat = 0; @@ -75,7 +75,7 @@ int grib_tool_init(grib_runtime_options* options) if (options->latlon) { lat = strtod(options->latlon, &theEnd); if (*theEnd != ',') { - fprintf(stderr, "Error %s: wrong latitude value. Please use 'latitude,longitude'\n",grib_tool_name); + fprintf(stderr, "Error %s: wrong latitude value. Please use 'latitude,longitude'\n",tool_name); exit(1); } lon = strtod(++theEnd, &end1); @@ -95,7 +95,7 @@ int grib_tool_init(grib_runtime_options* options) options->latlon_mode = 1; } else { - fprintf(stderr, "Error %s: wrong mode given in option -l\n", grib_tool_name); + fprintf(stderr, "Error %s: wrong mode given in option -l\n", tool_name); exit(1); } } @@ -162,7 +162,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file) { - exit_if_input_is_directory(grib_tool_name, file->name); + exit_if_input_is_directory(tool_name, file->name); if (nearest) grib_nearest_delete(nearest); nearest = NULL; diff --git a/tools/grib_get_data.c b/tools/grib_get_data.c index 9a042d32b..61db62751 100644 --- a/tools/grib_get_data.c +++ b/tools/grib_get_data.c @@ -39,11 +39,11 @@ grib_option grib_options[] = { { "V", 0, 0, 0, 1, 0 } }; -const char* grib_tool_description = +const char* tool_description = "Print a latitude, longitude, data values list.\n" "\tNote: Rotated grids are first unrotated"; -const char* grib_tool_name = "grib_get_data"; -const char* grib_tool_usage = "[options] grib_file grib_file ..."; +const char* tool_name = "grib_get_data"; +const char* tool_usage = "[options] grib_file grib_file ..."; extern FILE* dump_file; @@ -71,7 +71,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file) { - exit_if_input_is_directory(grib_tool_name, file->name); + exit_if_input_is_directory(tool_name, file->name); return 0; } diff --git a/tools/grib_histogram.c b/tools/grib_histogram.c index 9d6c8a585..a3bd610d1 100644 --- a/tools/grib_histogram.c +++ b/tools/grib_histogram.c @@ -19,9 +19,9 @@ grib_option grib_options[] = { }; int grib_options_count = sizeof(grib_options) / sizeof(grib_option); -const char* grib_tool_description = "Histogram of GRIB files"; -const char* grib_tool_name = "grib_histogram"; -const char* grib_tool_usage = "[options] grib_file grib_file ..."; +const char* tool_description = "Histogram of GRIB files"; +const char* tool_name = "grib_histogram"; +const char* tool_usage = "[options] grib_file grib_file ..."; int main(int argc, char* argv[]) { @@ -45,7 +45,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file) { - exit_if_input_is_directory(grib_tool_name, file->name); + exit_if_input_is_directory(tool_name, file->name); return 0; } diff --git a/tools/grib_index_build.c b/tools/grib_index_build.c index 96ffc9e4b..37df60244 100644 --- a/tools/grib_index_build.c +++ b/tools/grib_index_build.c @@ -15,9 +15,9 @@ #include "grib_tools.h" -const char* grib_tool_description = "Build an index file for a set of input GRIB files."; -const char* grib_tool_name = "grib_index_build"; -const char* grib_tool_usage = "[options] grib_file grib_file ... "; +const char* tool_description = "Build an index file for a set of input GRIB files."; +const char* tool_name = "grib_index_build"; +const char* tool_usage = "[options] grib_file grib_file ... "; static grib_index* idx = NULL; static char* keys; static char* default_keys = "mars"; @@ -83,7 +83,7 @@ int grib_tool_init(grib_runtime_options* options) int grib_tool_new_filename_action(grib_runtime_options* options, const char* file) { int ret = 0; - printf("--- %s: processing %s\n", grib_tool_name, file); + printf("--- %s: processing %s\n", tool_name, file); ret = grib_index_add_file(idx, file); if (ret) { printf("error: %s\n", grib_get_error_message(ret)); @@ -121,7 +121,7 @@ int grib_tool_finalise_action(grib_runtime_options* options) grib_index_compress(idx); } printf("--- %s: keys included in the index file %s:\n", - grib_tool_name, options->outfile->name); + tool_name, options->outfile->name); printf("--- "); first = 1; the_keys = idx->keys; diff --git a/tools/grib_ls.c b/tools/grib_ls.c index c307e8ed1..a78ef103e 100644 --- a/tools/grib_ls.c +++ b/tools/grib_ls.c @@ -42,11 +42,11 @@ grib_option grib_options[] = { { "x", 0, 0, 0, 1, 0 } }; -const char* grib_tool_description = +const char* tool_description = "List content of GRIB files printing values of " "some keys.\n\tIt does not fail when a key is not found."; -const char* grib_tool_name = "grib_ls"; -const char* grib_tool_usage = "[options] grib_file grib_file ..."; +const char* tool_name = "grib_ls"; +const char* tool_usage = "[options] grib_file grib_file ..."; static char* new_handle = ""; int grib_options_count = sizeof(grib_options) / sizeof(grib_option); @@ -100,7 +100,7 @@ int grib_tool_init(grib_runtime_options* options) if (options->latlon) { lat = strtod(options->latlon, &theEnd); if (*theEnd != ',') { - fprintf(stderr, "Error %s: wrong latitude value. Please use 'latitude,longitude'\n",grib_tool_name); + fprintf(stderr, "Error %s: wrong latitude value. Please use 'latitude,longitude'\n",tool_name); exit(1); } lon = strtod(++theEnd, &end1); @@ -120,7 +120,7 @@ int grib_tool_init(grib_runtime_options* options) options->latlon_mode = 1; } else { - fprintf(stderr, "Error %s: wrong mode given in option -l\n", grib_tool_name); + fprintf(stderr, "Error %s: wrong mode given in option -l\n", tool_name); exit(1); } } @@ -208,7 +208,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* file) { - exit_if_input_is_directory(grib_tool_name, file->name); + exit_if_input_is_directory(tool_name, file->name); if (nearest) grib_nearest_delete(nearest); nearest = NULL; diff --git a/tools/grib_merge.c b/tools/grib_merge.c index d97bf359d..16ee48c0f 100644 --- a/tools/grib_merge.c +++ b/tools/grib_merge.c @@ -34,9 +34,9 @@ int key_values_size = MAX_KEY_VALUES; * tool to identify the fields to be merged */ static const char* md5Key = "md5Product"; -const char* grib_tool_description = "Merge two fields with identical parameters and different geographical area"; -const char* grib_tool_name = "grib_merge"; -const char* grib_tool_usage = "[options] file file ... output_file"; +const char* tool_description = "Merge two fields with identical parameters and different geographical area"; +const char* tool_name = "grib_merge"; +const char* tool_usage = "[options] file file ... output_file"; grib_option grib_options[] = { /* {id, args, help}, on, command_line, value */ @@ -318,6 +318,16 @@ static grib_handle* merge(grib_handle* h1, grib_handle* h2) grib_set_double_array(h, "values", v, n); + grib_context_free(h->context, v); + grib_context_free(h->context, v1); + grib_context_free(h->context, v2); + grib_context_free(h->context, lat); + grib_context_free(h->context, lat1); + grib_context_free(h->context, lat2); + grib_context_free(h->context, lon); + grib_context_free(h->context, lon1); + grib_context_free(h->context, lon2); + return h; } diff --git a/tools/grib_options.c b/tools/grib_options.c index 09c4f1cf6..b47503175 100644 --- a/tools/grib_options.c +++ b/tools/grib_options.c @@ -118,9 +118,9 @@ static int grib_options_help_count = sizeof(grib_options_help_list) / sizeof(gri void usage(void) { int i = 0; - printf("\nNAME \t%s\n\n", grib_tool_name); - printf("DESCRIPTION\n\t%s\n\n", grib_tool_description); - printf("USAGE \n\t%s %s\n\n", grib_tool_name, grib_tool_usage); + printf("\nNAME \t%s\n\n", tool_name); + printf("DESCRIPTION\n\t%s\n\n", tool_description); + printf("USAGE \n\t%s %s\n\n", tool_name, tool_usage); printf("OPTIONS\n"); for (i = 0; i < grib_options_count; i++) { if (grib_options[i].command_line) @@ -333,7 +333,7 @@ int grib_process_runtime_options(grib_context* context, int argc, char** argv, g } options->requested_print_keys_count = MAX_KEYS; - ret = parse_keyval_string(grib_tool_name, karg, 0, GRIB_TYPE_UNDEFINED, + ret = parse_keyval_string(tool_name, karg, 0, GRIB_TYPE_UNDEFINED, options->requested_print_keys, &(options->requested_print_keys_count)); if (ret == GRIB_INVALID_ARGUMENT) usage(); @@ -360,7 +360,7 @@ int grib_process_runtime_options(grib_context* context, int argc, char** argv, g if (grib_options_on("s:")) { sarg = grib_options_get_option("s:"); options->set_values_count = MAX_KEYS; - ret = parse_keyval_string(grib_tool_name, sarg, 1, GRIB_TYPE_UNDEFINED, options->set_values, &(options->set_values_count)); + ret = parse_keyval_string(tool_name, sarg, 1, GRIB_TYPE_UNDEFINED, options->set_values, &(options->set_values_count)); if (ret == GRIB_INVALID_ARGUMENT) usage(); } @@ -368,7 +368,7 @@ int grib_process_runtime_options(grib_context* context, int argc, char** argv, g if (grib_options_on("b:")) { barg = grib_options_get_option("b:"); options->set_values_count = MAX_KEYS; - ret = parse_keyval_string(grib_tool_name, barg, 0, GRIB_TYPE_STRING, options->set_values, &(options->set_values_count)); + ret = parse_keyval_string(tool_name, barg, 0, GRIB_TYPE_STRING, options->set_values, &(options->set_values_count)); if (ret == GRIB_INVALID_ARGUMENT) usage(); } @@ -376,7 +376,7 @@ int grib_process_runtime_options(grib_context* context, int argc, char** argv, g if (grib_options_on("c:")) { sarg = grib_options_get_option("c:"); options->compare_count = MAX_KEYS; - ret = parse_keyval_string(grib_tool_name, sarg, 0, GRIB_TYPE_UNDEFINED, options->compare, + ret = parse_keyval_string(tool_name, sarg, 0, GRIB_TYPE_UNDEFINED, options->compare, &(options->compare_count)); if (ret == GRIB_INVALID_ARGUMENT) usage(); @@ -392,7 +392,7 @@ int grib_process_runtime_options(grib_context* context, int argc, char** argv, g warg = grib_options_get_option("w:"); options->constraints_count = MAX_KEYS; - ret = parse_keyval_string(grib_tool_name, warg, 1, GRIB_TYPE_UNDEFINED, + ret = parse_keyval_string(tool_name, warg, 1, GRIB_TYPE_UNDEFINED, options->constraints, &(options->constraints_count)); if (ret == GRIB_INVALID_ARGUMENT) usage(); @@ -458,9 +458,9 @@ char* grib_options_get_args(char* id) void usage_doxygen(void) { int i = 0; - printf("/*! \\page %s %s\n", grib_tool_name, grib_tool_name); - printf("\\section DESCRIPTION \n %s\n\n", grib_tool_description); - printf("\\section USAGE \n %s \n %s\n\n", grib_tool_name, grib_tool_usage); + printf("/*! \\page %s %s\n", tool_name, tool_name); + printf("\\section DESCRIPTION \n %s\n\n", tool_description); + printf("\\section USAGE \n %s \n %s\n\n", tool_name, tool_usage); printf("\\section OPTIONS \n"); for (i = 0; i < grib_options_count; i++) { if (grib_options[i].command_line) { @@ -477,9 +477,9 @@ void usage_doxygen(void) #if 0 void usage_doxygen(void) { int i=0; - printf("/*! \\page %s %s\n",grib_tool_name,grib_tool_name); - printf("\\section DESCRIPTION \n%s\n\n",grib_tool_description); - printf("\\section USAGE \n%s \n%s\n\n",grib_tool_name,grib_tool_usage); + printf("/*! \\page %s %s\n",tool_name,tool_name); + printf("\\section DESCRIPTION \n%s\n\n",tool_description); + printf("\\section USAGE \n%s \n%s\n\n",tool_name,tool_usage); printf("\\section OPTIONS\n"); printf("\n"); for (i=0;i #endif -const char* grib_tool_description = +const char* tool_description = "Convert a GRIB file to netCDF format." "\n\tNote: The GRIB geometry should be a regular lat/lon grid or a regular Gaussian grid" "\n\t(the key \"typeOfGrid\" should be \"regular_ll\" or \"regular_gg\")"; -const char* grib_tool_name = "grib_to_netcdf"; -const char* grib_tool_usage = "[options] grib_file grib_file ... "; +const char* tool_name = "grib_to_netcdf"; +const char* tool_usage = "[options] grib_file grib_file ... "; static char argvString[2048] = {0,}; /*=====================================================================*/ @@ -2143,9 +2143,9 @@ static nc_type translate_nctype(const char* name) static void check_err(const char* function, const int stat, const int line) { if (stat != NC_NOERR) { - /* (void) fprintf(stderr, "line %d of %s: %s\n", line, grib_tool_name, nc_strerror(stat)); */ + /* (void) fprintf(stderr, "line %d of %s: %s\n", line, tool_name, nc_strerror(stat)); */ (void)fprintf(stderr, "\n%s ERROR: line %d, %s: %s\n", - grib_tool_name, line, function, nc_strerror(stat)); + tool_name, line, function, nc_strerror(stat)); if (stat == NC_EVARSIZE) { (void)fprintf(stderr, "\nCannot create netCDF classic format, dataset is too large!\n" @@ -3062,7 +3062,7 @@ static int define_netcdf_dimensions(hypercube* h, fieldset* fs, int ncid, datase dims[i] = n - i - 1; for (i = 0; i < subsetcnt; ++i) { - printf("%s: Defining variable '%s'.\n", grib_tool_name, subsets[i].att.name); + printf("%s: Defining variable '%s'.\n", tool_name, subsets[i].att.name); stat = nc_def_var(ncid, subsets[i].att.name, subsets[i].att.nctype, n, dims, &var_id); check_err("nc_def_var", stat, __LINE__); @@ -3351,7 +3351,7 @@ static void print_ignored_keys(FILE* f, request* data) int i = 0; while ((ignore = get_value(data, "ignore", i)) != NULL) { if (i == 0) { - fprintf(f, "%s: Ignoring key(s): %s", grib_tool_name, ignore); + fprintf(f, "%s: Ignoring key(s): %s", tool_name, ignore); } else { fprintf(f, ", %s", ignore); @@ -3861,25 +3861,25 @@ static int get_creation_mode(int option_kind) int creation_mode = NC_CLOBBER; switch (option_kind) { case NC_FORMAT_CLASSIC: - printf("%s: Creating classic file format.\n", grib_tool_name); + printf("%s: Creating classic file format.\n", tool_name); break; case NC_FORMAT_64BIT: creation_mode |= NC_64BIT_OFFSET; - printf("%s: Creating large (64 bit) file format.\n", grib_tool_name); + printf("%s: Creating large (64 bit) file format.\n", tool_name); break; #ifdef NC_NETCDF4 case NC_FORMAT_NETCDF4: creation_mode |= NC_NETCDF4; - printf("%s: Creating netCDF-4/HDF5 format.\n", grib_tool_name); + printf("%s: Creating netCDF-4/HDF5 format.\n", tool_name); break; case NC_FORMAT_NETCDF4_CLASSIC: creation_mode |= NC_NETCDF4 | NC_CLASSIC_MODEL; - printf("%s: Creating netCDF-4 classic model file format.\n", grib_tool_name); + printf("%s: Creating netCDF-4 classic model file format.\n", tool_name); break; #else case NC_FORMAT_NETCDF4: case NC_FORMAT_NETCDF4_CLASSIC: - grib_context_log(ctx, GRIB_LOG_ERROR, "%s not built with netcdf4, cannot create netCDF-4 files.", grib_tool_name); + grib_context_log(ctx, GRIB_LOG_ERROR, "%s not built with netcdf4, cannot create netCDF-4 files.", tool_name); exit(1); break; #endif @@ -3993,7 +3993,7 @@ int grib_tool_init(grib_runtime_options* options) data_r = empty_request(0); user_r = empty_request(0); - printf("%s: Version ", grib_tool_name); + printf("%s: Version ", tool_name); grib_print_api_version(stdout); printf("\n"); @@ -4128,7 +4128,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil grib_handle* h = NULL; grib_file* file = NULL; - printf("%s: Processing input file '%s'.\n", grib_tool_name, filename); + printf("%s: Processing input file '%s'.\n", tool_name, filename); file = grib_file_open(filename, "r", &e); if (!file || !file->handle) @@ -4280,7 +4280,7 @@ int grib_tool_finalise_action(grib_runtime_options* options) return -1; } - printf("%s: Found %d GRIB field%s in %d file%s.\n", grib_tool_name, fs->count, fs->count > 1 ? "s" : "", files, files > 1 ? "s" : ""); + printf("%s: Found %d GRIB field%s in %d file%s.\n", tool_name, fs->count, fs->count > 1 ? "s" : "", files, files > 1 ? "s" : ""); if (ctx->debug) { grib_context_log(ctx, GRIB_LOG_INFO, "Request representing %d fields ", fs->count); @@ -4304,8 +4304,8 @@ int grib_tool_finalise_action(grib_runtime_options* options) /* Create netcdf file */ - printf("%s: Creating netCDF file '%s'\n", grib_tool_name, options->outfile->name); - printf("%s: NetCDF library version: %s\n", grib_tool_name, nc_inq_libvers()); + printf("%s: Creating netCDF file '%s'\n", tool_name, options->outfile->name); + printf("%s: NetCDF library version: %s\n", tool_name, nc_inq_libvers()); creation_mode = get_creation_mode(option_kind); stat = nc_create(options->outfile->name, creation_mode, &ncid); @@ -4354,7 +4354,7 @@ int grib_tool_finalise_action(grib_runtime_options* options) free_subsets(subsets, count); free_nc_options(); - printf("%s: Done.\n", grib_tool_name); + printf("%s: Done.\n", tool_name); return 0; } diff --git a/tools/grib_tools.c b/tools/grib_tools.c index 2f2023596..8a5a4142a 100644 --- a/tools/grib_tools.c +++ b/tools/grib_tools.c @@ -180,8 +180,8 @@ int grib_tool(int argc, char** argv) /* ECC-926: Currently only GRIB indexing works. Disable the through_index if BUFR, GTS etc */ if (global_options.mode == MODE_GRIB && - is_grib_index_file(global_options.infile->name) && - (global_options.infile_extra && is_grib_index_file(global_options.infile_extra->name))) { + is_index_file(global_options.infile->name) && + (global_options.infile_extra && is_index_file(global_options.infile_extra->name))) { global_options.through_index = 1; return grib_tool_index(&global_options); } @@ -1352,10 +1352,10 @@ void grib_tools_write_message(grib_runtime_options* options, grib_handle* h) } #endif } -int exit_if_input_is_directory(const char* tool_name, const char* filename) +int exit_if_input_is_directory(const char* toolname, const char* filename) { if (path_is_directory(filename)) { - fprintf(stderr, "%s: ERROR: \"%s\": Is a directory\n", tool_name, filename); + fprintf(stderr, "%s: ERROR: \"%s\": Is a directory\n", toolname, filename); exit(1); } return 0; diff --git a/tools/grib_tools.h b/tools/grib_tools.h index 7690b648f..f16ec8b96 100644 --- a/tools/grib_tools.h +++ b/tools/grib_tools.h @@ -174,9 +174,9 @@ typedef struct grib_runtime_options extern grib_option grib_options[]; extern int grib_options_count; -extern const char* grib_tool_name; -extern const char* grib_tool_description; -extern const char* grib_tool_usage; +extern const char* tool_name; +extern const char* tool_description; +extern const char* tool_usage; extern FILE* dump_file; @@ -206,6 +206,6 @@ int grib_process_runtime_options(grib_context* c, int argc, char** argv, grib_ru void grib_tools_write_message(grib_runtime_options* options, grib_handle* h); int grib_tool_new_filename_action(grib_runtime_options* options, const char* file); int grib_no_handle_action(grib_runtime_options* options, int err); -int exit_if_input_is_directory(const char* tool_name, const char* filename); +int exit_if_input_is_directory(const char* toolname, const char* filename); #endif diff --git a/tools/gts_compare.c b/tools/gts_compare.c index 024a80e96..a4fcd0caf 100644 --- a/tools/gts_compare.c +++ b/tools/gts_compare.c @@ -131,13 +131,13 @@ int counter = 0; int start = -1; int end = -1; -const char* grib_tool_description = +const char* tool_description = "Compare GTS messages contained in two files." "\n\tIf some differences are found it fails returning an error code." "\n\tDefault behaviour: bit-by-bit compare, same order in files."; -const char* grib_tool_name = "gts_compare"; -const char* grib_tool_usage = +const char* tool_name = "gts_compare"; +const char* tool_usage = "[options] " "file file"; diff --git a/tools/gts_copy.c b/tools/gts_copy.c index fdc870b9c..2edc55bd5 100644 --- a/tools/gts_copy.c +++ b/tools/gts_copy.c @@ -10,11 +10,11 @@ #include "grib_tools.h" -const char* grib_tool_description = +const char* tool_description = "Copies the content of GTS files printing" " values of some keys."; -const char* grib_tool_name = "gts_copy"; -const char* grib_tool_usage = "[options] file file ... output_file"; +const char* tool_name = "gts_copy"; +const char* tool_usage = "[options] file file ... output_file"; grib_option grib_options[] = { /* {id, args, help}, on, command_line, value */ diff --git a/tools/gts_dump.c b/tools/gts_dump.c index eb8a02094..13b302c80 100644 --- a/tools/gts_dump.c +++ b/tools/gts_dump.c @@ -33,9 +33,9 @@ grib_option grib_options[] = { { "x", 0, 0, 0, 1, 0 } }; -const char* grib_tool_description = "Dump the content of a GTS file in different formats."; -const char* grib_tool_name = "gts_dump"; -const char* grib_tool_usage = "[options] file file ..."; +const char* tool_description = "Dump the content of a GTS file in different formats."; +const char* tool_name = "gts_dump"; +const char* tool_usage = "[options] file file ..."; int grib_options_count = sizeof(grib_options) / sizeof(grib_option); @@ -62,7 +62,7 @@ int grib_tool_init(grib_runtime_options* options) if (opt > 1) { - printf("%s: simultaneous O/D options not allowed\n", grib_tool_name); + printf("%s: simultaneous O/D options not allowed\n", tool_name); exit(1); } diff --git a/tools/gts_filter.c b/tools/gts_filter.c index 8a4dd9537..8c5223e79 100644 --- a/tools/gts_filter.c +++ b/tools/gts_filter.c @@ -26,12 +26,12 @@ grib_option grib_options[] = { { "7", 0, 0, 0, 1, 0 }, { "v", 0, 0, 0, 1, 0 } }; -const char* grib_tool_description = +const char* tool_description = "Apply the rules defined in rules_file to each GTS " "message\n\tin the GTS files provided as arguments.\n\t" "If you specify '-' (a single dash) for the rules_file, the rules will be read from standard input."; -const char* grib_tool_name = "gts_filter"; -const char* grib_tool_usage = +const char* tool_name = "gts_filter"; +const char* tool_usage = "[options] rules_file " "file file ..."; int fail = 0; diff --git a/tools/gts_get.c b/tools/gts_get.c index 14f91c6a4..e7a1db6fd 100644 --- a/tools/gts_get.c +++ b/tools/gts_get.c @@ -28,12 +28,12 @@ grib_option grib_options[] = { { "v", 0, 0, 1, 0, 0 } }; -const char* grib_tool_description = +const char* tool_description = "Get values of some keys from a GTS file." "\n\tIt is similar to gts_ls, but fails returning an error code " "\n\twhen an error occurs (e.g. key not found)."; -const char* grib_tool_name = "gts_get"; -const char* grib_tool_usage = "[options] file file ..."; +const char* tool_name = "gts_get"; +const char* tool_usage = "[options] file file ..."; int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int mode = 0; diff --git a/tools/gts_ls.c b/tools/gts_ls.c index 04bba3595..e8d68b478 100644 --- a/tools/gts_ls.c +++ b/tools/gts_ls.c @@ -32,11 +32,11 @@ grib_option grib_options[] = { { "v", 0, 0, 1, 0, 0 } }; -const char* grib_tool_description = +const char* tool_description = "List content of GTS files printing values of " "some keys.\n\tIt does not fail when a key is not found."; -const char* grib_tool_name = "gts_ls"; -const char* grib_tool_usage = "[options] file file ..."; +const char* tool_name = "gts_ls"; +const char* tool_usage = "[options] file file ..."; int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int mode = 0; diff --git a/tools/metar_compare.c b/tools/metar_compare.c index 9af1c9d28..1e0a8f6d0 100644 --- a/tools/metar_compare.c +++ b/tools/metar_compare.c @@ -194,14 +194,14 @@ int global_counter = 0; int start = -1; int end = -1; -const char* grib_tool_description = +const char* tool_description = "Compare METAR messages contained in two files." "\n\tIf some differences are found it fails returning an error code." "\n\tFloating-point values are compared exactly by default, different tolerance can be defined see -P -A -R." "\n\tDefault behaviour: absolute error=0, bit-by-bit compare, same order in files."; -const char* grib_tool_name = "metar_compare"; -const char* grib_tool_usage = +const char* tool_name = "metar_compare"; +const char* tool_usage = "[options] " "file file"; diff --git a/tools/metar_copy.c b/tools/metar_copy.c index 714a29337..a8bed2211 100644 --- a/tools/metar_copy.c +++ b/tools/metar_copy.c @@ -10,11 +10,11 @@ #include "grib_tools.h" -const char* grib_tool_description = +const char* tool_description = "Copies the content of METAR files printing" " values of some keys."; -const char* grib_tool_name = "metar_copy"; -const char* grib_tool_usage = "[options] file file ... output_file"; +const char* tool_name = "metar_copy"; +const char* tool_usage = "[options] file file ... output_file"; grib_option grib_options[] = { /* {id, args, help}, on, command_line, value */ diff --git a/tools/metar_dump.c b/tools/metar_dump.c index 577068d7b..1c496c5a8 100644 --- a/tools/metar_dump.c +++ b/tools/metar_dump.c @@ -36,9 +36,9 @@ grib_option grib_options[] = { { "x", 0, 0, 0, 1, 0 } }; -const char* grib_tool_description = "Dump the content of a METAR file in different formats."; -const char* grib_tool_name = "metar_dump"; -const char* grib_tool_usage = "[options] file file ..."; +const char* tool_description = "Dump the content of a METAR file in different formats."; +const char* tool_name = "metar_dump"; +const char* tool_usage = "[options] file file ..."; int grib_options_count = sizeof(grib_options) / sizeof(grib_option); @@ -59,7 +59,7 @@ int grib_tool_init(grib_runtime_options* options) options->dump_mode = "default"; if (opt > 1) { - printf("%s: simultaneous O/D options not allowed\n", grib_tool_name); + printf("%s: simultaneous O/D options not allowed\n", tool_name); exit(1); } diff --git a/tools/metar_filter.c b/tools/metar_filter.c index 97db49d4c..bbf3306c0 100644 --- a/tools/metar_filter.c +++ b/tools/metar_filter.c @@ -24,11 +24,11 @@ grib_option grib_options[] = { { "7", 0, 0, 0, 1, 0 }, { "v", 0, 0, 0, 1, 0 } }; -const char* grib_tool_description = +const char* tool_description = "Apply the rules defined in rules_file to each METAR " "message\n\tin the files provided as arguments."; -const char* grib_tool_name = "metar_filter"; -const char* grib_tool_usage = +const char* tool_name = "metar_filter"; +const char* tool_usage = "[options] rules_file " "file file ..."; int fail = 0; diff --git a/tools/metar_get.c b/tools/metar_get.c index e2ae92f8f..2508034ba 100644 --- a/tools/metar_get.c +++ b/tools/metar_get.c @@ -29,12 +29,12 @@ grib_option grib_options[] = { { "v", 0, 0, 1, 0, 0 } }; -const char* grib_tool_description = +const char* tool_description = "Get values of some keys from a METAR file." "\n\tIt is similar to metar_ls, but fails returning an error code " "\n\twhen an error occurs (e.g. key not found)."; -const char* grib_tool_name = "metar_get"; -const char* grib_tool_usage = "[options] file file ..."; +const char* tool_name = "metar_get"; +const char* tool_usage = "[options] file file ..."; int grib_options_count = sizeof(grib_options) / sizeof(grib_option); double lat = 0; diff --git a/tools/metar_ls.c b/tools/metar_ls.c index c23acb7f9..8d795b7b9 100644 --- a/tools/metar_ls.c +++ b/tools/metar_ls.c @@ -44,11 +44,11 @@ grib_option grib_options[] = { /*{"x",0,0,0,1,0}*/ }; -const char* grib_tool_description = +const char* tool_description = "List content of METAR files printing values of " "some keys.\n\tIt does not fail when a key is not found."; -const char* grib_tool_name = "metar_ls"; -const char* grib_tool_usage = "[options] file file ..."; +const char* tool_name = "metar_ls"; +const char* tool_usage = "[options] file file ..."; int grib_options_count = sizeof(grib_options) / sizeof(grib_option); double lat = 0; diff --git a/tools/taf_dump.c b/tools/taf_dump.c index 6e37b15ef..a6cdb704e 100644 --- a/tools/taf_dump.c +++ b/tools/taf_dump.c @@ -29,9 +29,9 @@ grib_option grib_options[] = { { "x", 0, 0, 0, 1, 0 } }; -const char* grib_tool_description = "Dump the content of a TAF file in different formats."; -const char* grib_tool_name = "taf_dump"; -const char* grib_tool_usage = "[options] file file ..."; +const char* tool_description = "Dump the content of a TAF file in different formats."; +const char* tool_name = "taf_dump"; +const char* tool_usage = "[options] file file ..."; int grib_options_count = sizeof(grib_options) / sizeof(grib_option); @@ -53,7 +53,7 @@ int grib_tool_init(grib_runtime_options* options) if (opt > 1) { - printf("%s: simultaneous C/O/D options not allowed\n", grib_tool_name); + printf("%s: simultaneous C/O/D options not allowed\n", tool_name); exit(1); } diff --git a/tools/taf_filter.c b/tools/taf_filter.c index c94b6dd17..148d5b1c9 100644 --- a/tools/taf_filter.c +++ b/tools/taf_filter.c @@ -26,11 +26,11 @@ grib_option grib_options[] = { { "7", 0, 0, 0, 1, 0 }, { "v", 0, 0, 0, 1, 0 } }; -const char* grib_tool_description = +const char* tool_description = "Apply the rules defined in rules_file to each TAF " "message\n\tin the files provided as arguments."; -const char* grib_tool_name = "taf_filter"; -const char* grib_tool_usage = +const char* tool_name = "taf_filter"; +const char* tool_usage = "[options] rules_file " "file file ..."; int fail = 0; diff --git a/tools/taf_get.c b/tools/taf_get.c index 44567f8e0..de1c66078 100644 --- a/tools/taf_get.c +++ b/tools/taf_get.c @@ -33,12 +33,12 @@ grib_option grib_options[] = { { "i:", 0, 0, 0, 1, 0 } }; -const char* grib_tool_description = +const char* tool_description = "Get values of some keys from a TAF file." "\n\tIt is similar to taf_ls, but fails returning an error code " "\n\twhen an error occurs (e.g. key not found)."; -const char* grib_tool_name = "taf_get"; -const char* grib_tool_usage = "[options] file file ..."; +const char* tool_name = "taf_get"; +const char* tool_usage = "[options] file file ..."; int grib_options_count = sizeof(grib_options) / sizeof(grib_option); int mode = 0; diff --git a/tools/taf_ls.c b/tools/taf_ls.c index c640f90a1..ad0a2ff92 100644 --- a/tools/taf_ls.c +++ b/tools/taf_ls.c @@ -37,11 +37,11 @@ grib_option grib_options[] = { { "x", 0, 0, 0, 1, 0 } }; -const char* grib_tool_description = +const char* tool_description = "List content of TAF files printing values of " "some keys.\n\tIt does not fail when a key is not found."; -const char* grib_tool_name = "taf_ls"; -const char* grib_tool_usage = "[options] file file ..."; +const char* tool_name = "taf_ls"; +const char* tool_usage = "[options] file file ..."; int grib_options_count = sizeof(grib_options) / sizeof(grib_option); double lat = 0;