From fe36ddeb89c5a0bdbcf4793355fb47a0f6516f4f Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 29 May 2019 12:56:48 +0100 Subject: [PATCH 01/49] ECC-928: Remove lwda for type=gai --- definitions/mars/grib.lwda.gai.def | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 definitions/mars/grib.lwda.gai.def diff --git a/definitions/mars/grib.lwda.gai.def b/definitions/mars/grib.lwda.gai.def deleted file mode 100644 index 66e453379..000000000 --- a/definitions/mars/grib.lwda.gai.def +++ /dev/null @@ -1,2 +0,0 @@ -alias mars.anoffset=offsetToEndOf4DvarWindow; - From 68e6d72169d565418b4d3c22ce3c7c316b7502d1 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 5 Aug 2019 11:51:15 +0100 Subject: [PATCH 02/49] Bump up version to 2.13.1 --- .appveyor.yml | 2 +- VERSION.cmake | 2 +- version.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index c521562e2..95589b0b8 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -2,7 +2,7 @@ # general configuration # #---------------------------------# -version: 2.13.0-{build}-{branch} +version: 2.13.1-{build}-{branch} branches: only: diff --git a/VERSION.cmake b/VERSION.cmake index 5b14eeea9..ff5d68035 100644 --- a/VERSION.cmake +++ b/VERSION.cmake @@ -1 +1 @@ -set( ${PROJECT_NAME}_VERSION_STR "2.13.0" ) +set( ${PROJECT_NAME}_VERSION_STR "2.13.1" ) diff --git a/version.sh b/version.sh index 3df9c0fb8..2f4426c8d 100644 --- a/version.sh +++ b/version.sh @@ -15,7 +15,7 @@ PACKAGE_NAME='eccodes' # Package version ECCODES_MAJOR_VERSION=2 ECCODES_MINOR_VERSION=13 -ECCODES_REVISION_VERSION=0 +ECCODES_REVISION_VERSION=1 ECCODES_CURRENT=1 ECCODES_REVISION=0 From 4f45f0c00c3a597b7baf825c52f4ac9903dfdddb Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 5 Aug 2019 12:21:48 +0100 Subject: [PATCH 03/49] ECC-960, ECC-963, ECC-960 --- definitions/grib1/2.98.172.table | 26 ++++----- definitions/grib1/2.98.173.table | 2 +- .../grib1/localConcepts/ecmf/cfVarName.def | 56 +++++++++---------- definitions/grib1/localConcepts/ecmf/name.def | 56 +++++++++---------- .../grib1/localConcepts/ecmf/paramId.def | 28 +++++----- .../grib1/localConcepts/ecmf/shortName.def | 56 +++++++++---------- .../grib1/localConcepts/ecmf/units.def | 28 +++++----- definitions/grib2/cfVarName.def | 42 ++++++++++++++ .../grib2/localConcepts/ecmf/cfVarName.def | 56 +++++++++---------- definitions/grib2/localConcepts/ecmf/name.def | 56 +++++++++---------- .../grib2/localConcepts/ecmf/paramId.def | 28 +++++----- .../grib2/localConcepts/ecmf/shortName.def | 56 +++++++++---------- .../grib2/localConcepts/ecmf/units.def | 28 +++++----- definitions/grib2/name.def | 42 ++++++++++++++ definitions/grib2/paramId.def | 42 ++++++++++++++ definitions/grib2/shortName.def | 42 ++++++++++++++ definitions/grib2/units.def | 42 ++++++++++++++ src/grib_util.c | 3 - 18 files changed, 448 insertions(+), 241 deletions(-) diff --git a/definitions/grib1/2.98.172.table b/definitions/grib1/2.98.172.table index 37a3c2f15..5d8f8653c 100644 --- a/definitions/grib1/2.98.172.table +++ b/definitions/grib1/2.98.172.table @@ -4,22 +4,22 @@ 44 44 ESRATE Snow evaporation (m of water s**-1) 45 45 - Snowmelt (m of water s**-1) 48 48 - Magnitude of turbulent surface stress (N m**-2) -50 50 - Large-scale precipitation fraction (~) +50 50 MLSPFR Mean large-scale precipitation fraction (~) 142 142 MLSPRT Mean large-scale precipitation rate (m s**-1) 143 143 CPRATE Mean convective precipitation rate (m s**-1) 144 144 - Snowfall (convective + stratiform) (m of water equivalent s**-1) 145 145 BLDRATE Boundary layer dissipation (W m**-2) -146 146 - Surface sensible heat flux (W m**-2) -147 147 - Surface latent heat flux (W m**-2) -149 149 - Surface net radiation (W m**-2) -153 153 - Short-wave heating rate (K s**-1) -154 154 - Long-wave heating rate (K s**-1) -169 169 - Surface solar radiation downwards (W m**-2) -175 175 - Surface thermal radiation downwards (W m**-2) -176 176 - Surface solar radiation (W m**-2) -177 177 - Surface thermal radiation (W m**-2) -178 178 - Top solar radiation (W m**-2) -179 179 - Top thermal radiation (W m**-2) +146 146 MSSHFL Mean surface sensible heat flux (W m**-2) +147 147 MSLHFL Mean surface latent heat flux (W m**-2) +149 149 MSNRF Mean surface net radiation flux (W m**-2) +153 153 MSWHR Mean short-wave heating rate (K s**-1) +154 154 MLWHR Mean long-wave heating rate (K s**-1) +169 169 MSDSRF Mean surface downward solar radiation flux (W m**-2) +175 175 MSDTRF Mean surface downward thermal radiation flux (W m**-2) +176 176 MSNSRF Mean surface net solar radiation flux (W m**-2) +177 177 MSNTRF Mean surface net thermal radiation flux (W m**-2) +178 178 MTNSRF Mean top net solar radiation flux (W m**-2) +179 179 MTNTRF Mean top net thermal radiation flux (W m**-2) 180 180 EWSSRA East-West surface stress rate of accumulation (N m**-2) 181 181 NSSSRA North-South surface stress rate of accumulation (N m**-2) 182 182 ERATE Evaporation (m of water s**-1) @@ -27,7 +27,7 @@ 195 195 - Longitudinal component of gravity wave stress (N m**-2) 196 196 - Meridional component of gravity wave stress (N m**-2) 197 197 GWDRATE Gravity wave dissipation (W m**-2) -205 205 - Runoff (m s**-1) +205 205 MRORT Mean runoff rate (m s**-1) 208 208 - Top net solar radiation, clear sky (W m**-2) 209 209 - Top net thermal radiation, clear sky (W m**-2) 210 210 - Surface net solar radiation, clear sky (W m**-2) diff --git a/definitions/grib1/2.98.173.table b/definitions/grib1/2.98.173.table index 3e5342965..e16e9a700 100644 --- a/definitions/grib1/2.98.173.table +++ b/definitions/grib1/2.98.173.table @@ -6,7 +6,7 @@ 48 48 - Magnitude of turbulent surface stress anomaly (N m**-2) 50 50 - Large-scale precipitation fraction anomaly (~) 142 142 LSPARA Stratiform precipitation (Large-scale precipitation) anomalous rate of accumulation (m s**-1) -143 143 - Convective precipitation anomaly (m s**-1) +143 143 MCPRA Mean convective precipitation rate anomaly (m s**-1) 144 144 SFARA Snowfall (convective + stratiform) anomalous rate of accumulation (m of water equivalent s**-1) 145 145 - Boundary layer dissipation anomaly (J m**-2) 146 146 SSHFARA Surface sensible heat flux anomalous rate of accumulation (J m**-2) diff --git a/definitions/grib1/localConcepts/ecmf/cfVarName.def b/definitions/grib1/localConcepts/ecmf/cfVarName.def index e83fa6b8f..70819a846 100644 --- a/definitions/grib1/localConcepts/ecmf/cfVarName.def +++ b/definitions/grib1/localConcepts/ecmf/cfVarName.def @@ -14629,8 +14629,8 @@ table2Version = 172 ; indicatorOfParameter = 48 ; } -#Large-scale precipitation fraction -'p50.172' = { +#Mean large-scale precipitation fraction +'mlspfr' = { table2Version = 172 ; indicatorOfParameter = 50 ; } @@ -14654,58 +14654,58 @@ table2Version = 172 ; indicatorOfParameter = 145 ; } -#Surface sensible heat flux -'p146.172' = { +#Mean surface sensible heat flux +'msshfl' = { table2Version = 172 ; indicatorOfParameter = 146 ; } -#Surface latent heat flux -'p147.172' = { +#Mean surface latent heat flux +'mslhfl' = { table2Version = 172 ; indicatorOfParameter = 147 ; } -#Surface net radiation -'p149.172' = { +#Mean surface net radiation flux +'msnrf' = { table2Version = 172 ; indicatorOfParameter = 149 ; } -#Short-wave heating rate -'p153.172' = { +#Mean short-wave heating rate +'mswhr' = { table2Version = 172 ; indicatorOfParameter = 153 ; } -#Long-wave heating rate -'p154.172' = { +#Mean long-wave heating rate +'mlwhr' = { table2Version = 172 ; indicatorOfParameter = 154 ; } -#Surface solar radiation downwards -'p169.172' = { +#Mean surface downward solar radiation flux +'msdsrf' = { table2Version = 172 ; indicatorOfParameter = 169 ; } -#Surface thermal radiation downwards -'p175.172' = { +#Mean surface downward thermal radiation flux +'msdtrf' = { table2Version = 172 ; indicatorOfParameter = 175 ; } -#Surface solar radiation -'p176.172' = { +#Mean surface net solar radiation flux +'msnsrf' = { table2Version = 172 ; indicatorOfParameter = 176 ; } -#Surface thermal radiation -'p177.172' = { +#Mean surface net thermal radiation flux +'msntrf' = { table2Version = 172 ; indicatorOfParameter = 177 ; } -#Top solar radiation -'p178.172' = { +#Mean top net solar radiation flux +'mtnsrf' = { table2Version = 172 ; indicatorOfParameter = 178 ; } -#Top thermal radiation -'p179.172' = { +#Mean top net thermal radiation flux +'mtntrf' = { table2Version = 172 ; indicatorOfParameter = 179 ; } @@ -14744,8 +14744,8 @@ table2Version = 172 ; indicatorOfParameter = 197 ; } -#Runoff -'p205.172' = { +#Mean runoff rate +'mrort' = { table2Version = 172 ; indicatorOfParameter = 205 ; } @@ -14819,8 +14819,8 @@ table2Version = 173 ; indicatorOfParameter = 142 ; } -#Convective precipitation anomaly -'p143.173' = { +#Mean convective precipitation rate anomaly +'mcpra' = { table2Version = 173 ; indicatorOfParameter = 143 ; } diff --git a/definitions/grib1/localConcepts/ecmf/name.def b/definitions/grib1/localConcepts/ecmf/name.def index 275de73d2..8bb75fe63 100644 --- a/definitions/grib1/localConcepts/ecmf/name.def +++ b/definitions/grib1/localConcepts/ecmf/name.def @@ -14629,8 +14629,8 @@ table2Version = 172 ; indicatorOfParameter = 48 ; } -#Large-scale precipitation fraction -'Large-scale precipitation fraction' = { +#Mean large-scale precipitation fraction +'Mean large-scale precipitation fraction' = { table2Version = 172 ; indicatorOfParameter = 50 ; } @@ -14654,58 +14654,58 @@ table2Version = 172 ; indicatorOfParameter = 145 ; } -#Surface sensible heat flux -'Surface sensible heat flux' = { +#Mean surface sensible heat flux +'Mean surface sensible heat flux' = { table2Version = 172 ; indicatorOfParameter = 146 ; } -#Surface latent heat flux -'Surface latent heat flux' = { +#Mean surface latent heat flux +'Mean surface latent heat flux' = { table2Version = 172 ; indicatorOfParameter = 147 ; } -#Surface net radiation -'Surface net radiation' = { +#Mean surface net radiation flux +'Mean surface net radiation flux' = { table2Version = 172 ; indicatorOfParameter = 149 ; } -#Short-wave heating rate -'Short-wave heating rate' = { +#Mean short-wave heating rate +'Mean short-wave heating rate' = { table2Version = 172 ; indicatorOfParameter = 153 ; } -#Long-wave heating rate -'Long-wave heating rate' = { +#Mean long-wave heating rate +'Mean long-wave heating rate' = { table2Version = 172 ; indicatorOfParameter = 154 ; } -#Surface solar radiation downwards -'Surface solar radiation downwards' = { +#Mean surface downward solar radiation flux +'Mean surface downward solar radiation flux' = { table2Version = 172 ; indicatorOfParameter = 169 ; } -#Surface thermal radiation downwards -'Surface thermal radiation downwards' = { +#Mean surface downward thermal radiation flux +'Mean surface downward thermal radiation flux' = { table2Version = 172 ; indicatorOfParameter = 175 ; } -#Surface solar radiation -'Surface solar radiation' = { +#Mean surface net solar radiation flux +'Mean surface net solar radiation flux' = { table2Version = 172 ; indicatorOfParameter = 176 ; } -#Surface thermal radiation -'Surface thermal radiation' = { +#Mean surface net thermal radiation flux +'Mean surface net thermal radiation flux' = { table2Version = 172 ; indicatorOfParameter = 177 ; } -#Top solar radiation -'Top solar radiation' = { +#Mean top net solar radiation flux +'Mean top net solar radiation flux' = { table2Version = 172 ; indicatorOfParameter = 178 ; } -#Top thermal radiation -'Top thermal radiation' = { +#Mean top net thermal radiation flux +'Mean top net thermal radiation flux' = { table2Version = 172 ; indicatorOfParameter = 179 ; } @@ -14744,8 +14744,8 @@ table2Version = 172 ; indicatorOfParameter = 197 ; } -#Runoff -'Runoff' = { +#Mean runoff rate +'Mean runoff rate' = { table2Version = 172 ; indicatorOfParameter = 205 ; } @@ -14819,8 +14819,8 @@ table2Version = 173 ; indicatorOfParameter = 142 ; } -#Convective precipitation anomaly -'Convective precipitation anomaly' = { +#Mean convective precipitation rate anomaly +'Mean convective precipitation rate anomaly' = { table2Version = 173 ; indicatorOfParameter = 143 ; } diff --git a/definitions/grib1/localConcepts/ecmf/paramId.def b/definitions/grib1/localConcepts/ecmf/paramId.def index 5501d85f7..e7e57b9be 100644 --- a/definitions/grib1/localConcepts/ecmf/paramId.def +++ b/definitions/grib1/localConcepts/ecmf/paramId.def @@ -14629,7 +14629,7 @@ table2Version = 172 ; indicatorOfParameter = 48 ; } -#Large-scale precipitation fraction +#Mean large-scale precipitation fraction '172050' = { table2Version = 172 ; indicatorOfParameter = 50 ; @@ -14654,57 +14654,57 @@ table2Version = 172 ; indicatorOfParameter = 145 ; } -#Surface sensible heat flux +#Mean surface sensible heat flux '172146' = { table2Version = 172 ; indicatorOfParameter = 146 ; } -#Surface latent heat flux +#Mean surface latent heat flux '172147' = { table2Version = 172 ; indicatorOfParameter = 147 ; } -#Surface net radiation +#Mean surface net radiation flux '172149' = { table2Version = 172 ; indicatorOfParameter = 149 ; } -#Short-wave heating rate +#Mean short-wave heating rate '172153' = { table2Version = 172 ; indicatorOfParameter = 153 ; } -#Long-wave heating rate +#Mean long-wave heating rate '172154' = { table2Version = 172 ; indicatorOfParameter = 154 ; } -#Surface solar radiation downwards +#Mean surface downward solar radiation flux '172169' = { table2Version = 172 ; indicatorOfParameter = 169 ; } -#Surface thermal radiation downwards +#Mean surface downward thermal radiation flux '172175' = { table2Version = 172 ; indicatorOfParameter = 175 ; } -#Surface solar radiation +#Mean surface net solar radiation flux '172176' = { table2Version = 172 ; indicatorOfParameter = 176 ; } -#Surface thermal radiation +#Mean surface net thermal radiation flux '172177' = { table2Version = 172 ; indicatorOfParameter = 177 ; } -#Top solar radiation +#Mean top net solar radiation flux '172178' = { table2Version = 172 ; indicatorOfParameter = 178 ; } -#Top thermal radiation +#Mean top net thermal radiation flux '172179' = { table2Version = 172 ; indicatorOfParameter = 179 ; @@ -14744,7 +14744,7 @@ table2Version = 172 ; indicatorOfParameter = 197 ; } -#Runoff +#Mean runoff rate '172205' = { table2Version = 172 ; indicatorOfParameter = 205 ; @@ -14819,7 +14819,7 @@ table2Version = 173 ; indicatorOfParameter = 142 ; } -#Convective precipitation anomaly +#Mean convective precipitation rate anomaly '173143' = { table2Version = 173 ; indicatorOfParameter = 143 ; diff --git a/definitions/grib1/localConcepts/ecmf/shortName.def b/definitions/grib1/localConcepts/ecmf/shortName.def index f91795872..4d0f70675 100644 --- a/definitions/grib1/localConcepts/ecmf/shortName.def +++ b/definitions/grib1/localConcepts/ecmf/shortName.def @@ -14629,8 +14629,8 @@ table2Version = 172 ; indicatorOfParameter = 48 ; } -#Large-scale precipitation fraction -'~' = { +#Mean large-scale precipitation fraction +'mlspfr' = { table2Version = 172 ; indicatorOfParameter = 50 ; } @@ -14654,58 +14654,58 @@ table2Version = 172 ; indicatorOfParameter = 145 ; } -#Surface sensible heat flux -'~' = { +#Mean surface sensible heat flux +'msshfl' = { table2Version = 172 ; indicatorOfParameter = 146 ; } -#Surface latent heat flux -'~' = { +#Mean surface latent heat flux +'mslhfl' = { table2Version = 172 ; indicatorOfParameter = 147 ; } -#Surface net radiation -'~' = { +#Mean surface net radiation flux +'msnrf' = { table2Version = 172 ; indicatorOfParameter = 149 ; } -#Short-wave heating rate -'~' = { +#Mean short-wave heating rate +'mswhr' = { table2Version = 172 ; indicatorOfParameter = 153 ; } -#Long-wave heating rate -'~' = { +#Mean long-wave heating rate +'mlwhr' = { table2Version = 172 ; indicatorOfParameter = 154 ; } -#Surface solar radiation downwards -'~' = { +#Mean surface downward solar radiation flux +'msdsrf' = { table2Version = 172 ; indicatorOfParameter = 169 ; } -#Surface thermal radiation downwards -'~' = { +#Mean surface downward thermal radiation flux +'msdtrf' = { table2Version = 172 ; indicatorOfParameter = 175 ; } -#Surface solar radiation -'~' = { +#Mean surface net solar radiation flux +'msnsrf' = { table2Version = 172 ; indicatorOfParameter = 176 ; } -#Surface thermal radiation -'~' = { +#Mean surface net thermal radiation flux +'msntrf' = { table2Version = 172 ; indicatorOfParameter = 177 ; } -#Top solar radiation -'~' = { +#Mean top net solar radiation flux +'mtnsrf' = { table2Version = 172 ; indicatorOfParameter = 178 ; } -#Top thermal radiation -'~' = { +#Mean top net thermal radiation flux +'mtntrf' = { table2Version = 172 ; indicatorOfParameter = 179 ; } @@ -14744,8 +14744,8 @@ table2Version = 172 ; indicatorOfParameter = 197 ; } -#Runoff -'~' = { +#Mean runoff rate +'mrort' = { table2Version = 172 ; indicatorOfParameter = 205 ; } @@ -14819,8 +14819,8 @@ table2Version = 173 ; indicatorOfParameter = 142 ; } -#Convective precipitation anomaly -'~' = { +#Mean convective precipitation rate anomaly +'mcpra' = { table2Version = 173 ; indicatorOfParameter = 143 ; } diff --git a/definitions/grib1/localConcepts/ecmf/units.def b/definitions/grib1/localConcepts/ecmf/units.def index 8c9197dfd..1c8093d7b 100644 --- a/definitions/grib1/localConcepts/ecmf/units.def +++ b/definitions/grib1/localConcepts/ecmf/units.def @@ -14629,7 +14629,7 @@ table2Version = 172 ; indicatorOfParameter = 48 ; } -#Large-scale precipitation fraction +#Mean large-scale precipitation fraction '~' = { table2Version = 172 ; indicatorOfParameter = 50 ; @@ -14654,57 +14654,57 @@ table2Version = 172 ; indicatorOfParameter = 145 ; } -#Surface sensible heat flux +#Mean surface sensible heat flux 'W m**-2' = { table2Version = 172 ; indicatorOfParameter = 146 ; } -#Surface latent heat flux +#Mean surface latent heat flux 'W m**-2' = { table2Version = 172 ; indicatorOfParameter = 147 ; } -#Surface net radiation +#Mean surface net radiation flux 'W m**-2' = { table2Version = 172 ; indicatorOfParameter = 149 ; } -#Short-wave heating rate +#Mean short-wave heating rate 'K s**-1' = { table2Version = 172 ; indicatorOfParameter = 153 ; } -#Long-wave heating rate +#Mean long-wave heating rate 'K s**-1' = { table2Version = 172 ; indicatorOfParameter = 154 ; } -#Surface solar radiation downwards +#Mean surface downward solar radiation flux 'W m**-2' = { table2Version = 172 ; indicatorOfParameter = 169 ; } -#Surface thermal radiation downwards +#Mean surface downward thermal radiation flux 'W m**-2' = { table2Version = 172 ; indicatorOfParameter = 175 ; } -#Surface solar radiation +#Mean surface net solar radiation flux 'W m**-2' = { table2Version = 172 ; indicatorOfParameter = 176 ; } -#Surface thermal radiation +#Mean surface net thermal radiation flux 'W m**-2' = { table2Version = 172 ; indicatorOfParameter = 177 ; } -#Top solar radiation +#Mean top net solar radiation flux 'W m**-2' = { table2Version = 172 ; indicatorOfParameter = 178 ; } -#Top thermal radiation +#Mean top net thermal radiation flux 'W m**-2' = { table2Version = 172 ; indicatorOfParameter = 179 ; @@ -14744,7 +14744,7 @@ table2Version = 172 ; indicatorOfParameter = 197 ; } -#Runoff +#Mean runoff rate 'm s**-1' = { table2Version = 172 ; indicatorOfParameter = 205 ; @@ -14819,7 +14819,7 @@ table2Version = 173 ; indicatorOfParameter = 142 ; } -#Convective precipitation anomaly +#Mean convective precipitation rate anomaly 'm s**-1' = { table2Version = 173 ; indicatorOfParameter = 143 ; diff --git a/definitions/grib2/cfVarName.def b/definitions/grib2/cfVarName.def index 7f97cda28..4636f33cc 100644 --- a/definitions/grib2/cfVarName.def +++ b/definitions/grib2/cfVarName.def @@ -1279,6 +1279,48 @@ parameterCategory = 0 ; parameterNumber = 9 ; } +#Forest fire weather index +'fwinx' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 5 ; + } +#Fine fuel moisture code +'ffmcode' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 6 ; + } +#Duff moisture code +'dufmcode' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 7 ; + } +#Drought code +'drtcode' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 8 ; + } +#Initial fire spread index +'infsinx' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 9 ; + } +#Fire buildup index +'fbupinx' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 10 ; + } +#Fire daily severity rating +'fdsrte' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 11 ; + } #Cloudy radiance (with respect to wave number) 'p260550' = { discipline = 3 ; diff --git a/definitions/grib2/localConcepts/ecmf/cfVarName.def b/definitions/grib2/localConcepts/ecmf/cfVarName.def index 1e9c28427..1beb1a3f7 100644 --- a/definitions/grib2/localConcepts/ecmf/cfVarName.def +++ b/definitions/grib2/localConcepts/ecmf/cfVarName.def @@ -18888,8 +18888,8 @@ parameterCategory = 172 ; parameterNumber = 48 ; } -#Large-scale precipitation fraction -'p50.172' = { +#Mean large-scale precipitation fraction +'mlspfr' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 50 ; @@ -18918,68 +18918,68 @@ parameterCategory = 172 ; parameterNumber = 145 ; } -#Surface sensible heat flux -'p146.172' = { +#Mean surface sensible heat flux +'msshfl' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 146 ; } -#Surface latent heat flux -'p147.172' = { +#Mean surface latent heat flux +'mslhfl' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 147 ; } -#Surface net radiation -'p149.172' = { +#Mean surface net radiation flux +'msnrf' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 149 ; } -#Short-wave heating rate -'p153.172' = { +#Mean short-wave heating rate +'mswhr' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 153 ; } -#Long-wave heating rate -'p154.172' = { +#Mean long-wave heating rate +'mlwhr' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 154 ; } -#Surface solar radiation downwards -'p169.172' = { +#Mean surface downward solar radiation flux +'msdsrf' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 169 ; } -#Surface thermal radiation downwards -'p175.172' = { +#Mean surface downward thermal radiation flux +'msdtrf' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 175 ; } -#Surface solar radiation -'p176.172' = { +#Mean surface net solar radiation flux +'msnsrf' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 176 ; } -#Surface thermal radiation -'p177.172' = { +#Mean surface net thermal radiation flux +'msntrf' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 177 ; } -#Top solar radiation -'p178.172' = { +#Mean top net solar radiation flux +'mtnsrf' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 178 ; } -#Top thermal radiation -'p179.172' = { +#Mean top net thermal radiation flux +'mtntrf' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 179 ; @@ -19026,8 +19026,8 @@ parameterCategory = 172 ; parameterNumber = 197 ; } -#Runoff -'p205.172' = { +#Mean runoff rate +'mrort' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 205 ; @@ -19116,8 +19116,8 @@ parameterCategory = 173 ; parameterNumber = 142 ; } -#Convective precipitation anomaly -'p143.173' = { +#Mean convective precipitation rate anomaly +'mcpra' = { discipline = 192 ; parameterCategory = 173 ; parameterNumber = 143 ; diff --git a/definitions/grib2/localConcepts/ecmf/name.def b/definitions/grib2/localConcepts/ecmf/name.def index 7c803d7a1..d75472401 100644 --- a/definitions/grib2/localConcepts/ecmf/name.def +++ b/definitions/grib2/localConcepts/ecmf/name.def @@ -18888,8 +18888,8 @@ parameterCategory = 172 ; parameterNumber = 48 ; } -#Large-scale precipitation fraction -'Large-scale precipitation fraction' = { +#Mean large-scale precipitation fraction +'Mean large-scale precipitation fraction' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 50 ; @@ -18918,68 +18918,68 @@ parameterCategory = 172 ; parameterNumber = 145 ; } -#Surface sensible heat flux -'Surface sensible heat flux' = { +#Mean surface sensible heat flux +'Mean surface sensible heat flux' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 146 ; } -#Surface latent heat flux -'Surface latent heat flux' = { +#Mean surface latent heat flux +'Mean surface latent heat flux' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 147 ; } -#Surface net radiation -'Surface net radiation' = { +#Mean surface net radiation flux +'Mean surface net radiation flux' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 149 ; } -#Short-wave heating rate -'Short-wave heating rate' = { +#Mean short-wave heating rate +'Mean short-wave heating rate' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 153 ; } -#Long-wave heating rate -'Long-wave heating rate' = { +#Mean long-wave heating rate +'Mean long-wave heating rate' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 154 ; } -#Surface solar radiation downwards -'Surface solar radiation downwards' = { +#Mean surface downward solar radiation flux +'Mean surface downward solar radiation flux' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 169 ; } -#Surface thermal radiation downwards -'Surface thermal radiation downwards' = { +#Mean surface downward thermal radiation flux +'Mean surface downward thermal radiation flux' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 175 ; } -#Surface solar radiation -'Surface solar radiation' = { +#Mean surface net solar radiation flux +'Mean surface net solar radiation flux' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 176 ; } -#Surface thermal radiation -'Surface thermal radiation' = { +#Mean surface net thermal radiation flux +'Mean surface net thermal radiation flux' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 177 ; } -#Top solar radiation -'Top solar radiation' = { +#Mean top net solar radiation flux +'Mean top net solar radiation flux' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 178 ; } -#Top thermal radiation -'Top thermal radiation' = { +#Mean top net thermal radiation flux +'Mean top net thermal radiation flux' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 179 ; @@ -19026,8 +19026,8 @@ parameterCategory = 172 ; parameterNumber = 197 ; } -#Runoff -'Runoff' = { +#Mean runoff rate +'Mean runoff rate' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 205 ; @@ -19116,8 +19116,8 @@ parameterCategory = 173 ; parameterNumber = 142 ; } -#Convective precipitation anomaly -'Convective precipitation anomaly' = { +#Mean convective precipitation rate anomaly +'Mean convective precipitation rate anomaly' = { discipline = 192 ; parameterCategory = 173 ; parameterNumber = 143 ; diff --git a/definitions/grib2/localConcepts/ecmf/paramId.def b/definitions/grib2/localConcepts/ecmf/paramId.def index 5d4a5eb47..043e71747 100644 --- a/definitions/grib2/localConcepts/ecmf/paramId.def +++ b/definitions/grib2/localConcepts/ecmf/paramId.def @@ -18888,7 +18888,7 @@ parameterCategory = 172 ; parameterNumber = 48 ; } -#Large-scale precipitation fraction +#Mean large-scale precipitation fraction '172050' = { discipline = 192 ; parameterCategory = 172 ; @@ -18918,67 +18918,67 @@ parameterCategory = 172 ; parameterNumber = 145 ; } -#Surface sensible heat flux +#Mean surface sensible heat flux '172146' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 146 ; } -#Surface latent heat flux +#Mean surface latent heat flux '172147' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 147 ; } -#Surface net radiation +#Mean surface net radiation flux '172149' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 149 ; } -#Short-wave heating rate +#Mean short-wave heating rate '172153' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 153 ; } -#Long-wave heating rate +#Mean long-wave heating rate '172154' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 154 ; } -#Surface solar radiation downwards +#Mean surface downward solar radiation flux '172169' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 169 ; } -#Surface thermal radiation downwards +#Mean surface downward thermal radiation flux '172175' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 175 ; } -#Surface solar radiation +#Mean surface net solar radiation flux '172176' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 176 ; } -#Surface thermal radiation +#Mean surface net thermal radiation flux '172177' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 177 ; } -#Top solar radiation +#Mean top net solar radiation flux '172178' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 178 ; } -#Top thermal radiation +#Mean top net thermal radiation flux '172179' = { discipline = 192 ; parameterCategory = 172 ; @@ -19026,7 +19026,7 @@ parameterCategory = 172 ; parameterNumber = 197 ; } -#Runoff +#Mean runoff rate '172205' = { discipline = 192 ; parameterCategory = 172 ; @@ -19116,7 +19116,7 @@ parameterCategory = 173 ; parameterNumber = 142 ; } -#Convective precipitation anomaly +#Mean convective precipitation rate anomaly '173143' = { discipline = 192 ; parameterCategory = 173 ; diff --git a/definitions/grib2/localConcepts/ecmf/shortName.def b/definitions/grib2/localConcepts/ecmf/shortName.def index c45131dd7..da5c0b741 100644 --- a/definitions/grib2/localConcepts/ecmf/shortName.def +++ b/definitions/grib2/localConcepts/ecmf/shortName.def @@ -18888,8 +18888,8 @@ parameterCategory = 172 ; parameterNumber = 48 ; } -#Large-scale precipitation fraction -'~' = { +#Mean large-scale precipitation fraction +'mlspfr' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 50 ; @@ -18918,68 +18918,68 @@ parameterCategory = 172 ; parameterNumber = 145 ; } -#Surface sensible heat flux -'~' = { +#Mean surface sensible heat flux +'msshfl' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 146 ; } -#Surface latent heat flux -'~' = { +#Mean surface latent heat flux +'mslhfl' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 147 ; } -#Surface net radiation -'~' = { +#Mean surface net radiation flux +'msnrf' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 149 ; } -#Short-wave heating rate -'~' = { +#Mean short-wave heating rate +'mswhr' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 153 ; } -#Long-wave heating rate -'~' = { +#Mean long-wave heating rate +'mlwhr' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 154 ; } -#Surface solar radiation downwards -'~' = { +#Mean surface downward solar radiation flux +'msdsrf' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 169 ; } -#Surface thermal radiation downwards -'~' = { +#Mean surface downward thermal radiation flux +'msdtrf' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 175 ; } -#Surface solar radiation -'~' = { +#Mean surface net solar radiation flux +'msnsrf' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 176 ; } -#Surface thermal radiation -'~' = { +#Mean surface net thermal radiation flux +'msntrf' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 177 ; } -#Top solar radiation -'~' = { +#Mean top net solar radiation flux +'mtnsrf' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 178 ; } -#Top thermal radiation -'~' = { +#Mean top net thermal radiation flux +'mtntrf' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 179 ; @@ -19026,8 +19026,8 @@ parameterCategory = 172 ; parameterNumber = 197 ; } -#Runoff -'~' = { +#Mean runoff rate +'mrort' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 205 ; @@ -19116,8 +19116,8 @@ parameterCategory = 173 ; parameterNumber = 142 ; } -#Convective precipitation anomaly -'~' = { +#Mean convective precipitation rate anomaly +'mcpra' = { discipline = 192 ; parameterCategory = 173 ; parameterNumber = 143 ; diff --git a/definitions/grib2/localConcepts/ecmf/units.def b/definitions/grib2/localConcepts/ecmf/units.def index e8bcf332e..3ffe24ed1 100644 --- a/definitions/grib2/localConcepts/ecmf/units.def +++ b/definitions/grib2/localConcepts/ecmf/units.def @@ -18888,7 +18888,7 @@ parameterCategory = 172 ; parameterNumber = 48 ; } -#Large-scale precipitation fraction +#Mean large-scale precipitation fraction '~' = { discipline = 192 ; parameterCategory = 172 ; @@ -18918,67 +18918,67 @@ parameterCategory = 172 ; parameterNumber = 145 ; } -#Surface sensible heat flux +#Mean surface sensible heat flux 'W m**-2' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 146 ; } -#Surface latent heat flux +#Mean surface latent heat flux 'W m**-2' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 147 ; } -#Surface net radiation +#Mean surface net radiation flux 'W m**-2' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 149 ; } -#Short-wave heating rate +#Mean short-wave heating rate 'K s**-1' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 153 ; } -#Long-wave heating rate +#Mean long-wave heating rate 'K s**-1' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 154 ; } -#Surface solar radiation downwards +#Mean surface downward solar radiation flux 'W m**-2' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 169 ; } -#Surface thermal radiation downwards +#Mean surface downward thermal radiation flux 'W m**-2' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 175 ; } -#Surface solar radiation +#Mean surface net solar radiation flux 'W m**-2' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 176 ; } -#Surface thermal radiation +#Mean surface net thermal radiation flux 'W m**-2' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 177 ; } -#Top solar radiation +#Mean top net solar radiation flux 'W m**-2' = { discipline = 192 ; parameterCategory = 172 ; parameterNumber = 178 ; } -#Top thermal radiation +#Mean top net thermal radiation flux 'W m**-2' = { discipline = 192 ; parameterCategory = 172 ; @@ -19026,7 +19026,7 @@ parameterCategory = 172 ; parameterNumber = 197 ; } -#Runoff +#Mean runoff rate 'm s**-1' = { discipline = 192 ; parameterCategory = 172 ; @@ -19116,7 +19116,7 @@ parameterCategory = 173 ; parameterNumber = 142 ; } -#Convective precipitation anomaly +#Mean convective precipitation rate anomaly 'm s**-1' = { discipline = 192 ; parameterCategory = 173 ; diff --git a/definitions/grib2/name.def b/definitions/grib2/name.def index 00ed847fd..f95ca3294 100644 --- a/definitions/grib2/name.def +++ b/definitions/grib2/name.def @@ -1279,6 +1279,48 @@ parameterCategory = 0 ; parameterNumber = 9 ; } +#Forest fire weather index +'Forest fire weather index' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 5 ; + } +#Fine fuel moisture code +'Fine fuel moisture code' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 6 ; + } +#Duff moisture code +'Duff moisture code' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 7 ; + } +#Drought code +'Drought code' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 8 ; + } +#Initial fire spread index +'Initial fire spread index' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 9 ; + } +#Fire buildup index +'Fire buildup index' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 10 ; + } +#Fire daily severity rating +'Fire daily severity rating' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 11 ; + } #Cloudy radiance (with respect to wave number) 'Cloudy radiance (with respect to wave number)' = { discipline = 3 ; diff --git a/definitions/grib2/paramId.def b/definitions/grib2/paramId.def index c7aa7d4fb..846e3afce 100644 --- a/definitions/grib2/paramId.def +++ b/definitions/grib2/paramId.def @@ -1279,6 +1279,48 @@ parameterCategory = 0 ; parameterNumber = 9 ; } +#Forest fire weather index +'260540' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 5 ; + } +#Fine fuel moisture code +'260541' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 6 ; + } +#Duff moisture code +'260542' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 7 ; + } +#Drought code +'260543' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 8 ; + } +#Initial fire spread index +'260544' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 9 ; + } +#Fire buildup index +'260545' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 10 ; + } +#Fire daily severity rating +'260546' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 11 ; + } #Cloudy radiance (with respect to wave number) '260550' = { discipline = 3 ; diff --git a/definitions/grib2/shortName.def b/definitions/grib2/shortName.def index 7926bc05d..19fd95ac7 100644 --- a/definitions/grib2/shortName.def +++ b/definitions/grib2/shortName.def @@ -1279,6 +1279,48 @@ parameterCategory = 0 ; parameterNumber = 9 ; } +#Forest fire weather index +'fwinx' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 5 ; + } +#Fine fuel moisture code +'ffmcode' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 6 ; + } +#Duff moisture code +'dufmcode' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 7 ; + } +#Drought code +'drtcode' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 8 ; + } +#Initial fire spread index +'infsinx' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 9 ; + } +#Fire buildup index +'fbupinx' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 10 ; + } +#Fire daily severity rating +'fdsrte' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 11 ; + } #Cloudy radiance (with respect to wave number) '~' = { discipline = 3 ; diff --git a/definitions/grib2/units.def b/definitions/grib2/units.def index f19342417..e956f5b19 100644 --- a/definitions/grib2/units.def +++ b/definitions/grib2/units.def @@ -1279,6 +1279,48 @@ parameterCategory = 0 ; parameterNumber = 9 ; } +#Forest fire weather index +'Numeric' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 5 ; + } +#Fine fuel moisture code +'Numeric' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 6 ; + } +#Duff moisture code +'Numeric' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 7 ; + } +#Drought code +'Numeric' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 8 ; + } +#Initial fire spread index +'Numeric' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 9 ; + } +#Fire buildup index +'Numeric' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 10 ; + } +#Fire daily severity rating +'Numeric' = { + discipline = 2 ; + parameterCategory = 4 ; + parameterNumber = 11 ; + } #Cloudy radiance (with respect to wave number) 'W m**-1 sr**-1' = { discipline = 3 ; diff --git a/src/grib_util.c b/src/grib_util.c index 1abd054a2..75717ae0d 100644 --- a/src/grib_util.c +++ b/src/grib_util.c @@ -1050,9 +1050,6 @@ grib_handle* grib_util_set_spec2(grib_handle* h, /* The "pl" is given from the template, but "section_copy" will take care of setting the right headers */ { - char levtype[80]; - size_t n = sizeof(levtype); - Assert(grib_get_string(h,"levelType",levtype,&n) == 0); switch (spec->grid_type) { case GRIB_UTIL_GRID_SPEC_REDUCED_GG: case GRIB_UTIL_GRID_SPEC_REDUCED_ROTATED_GG: From cd0207608fafcc6be02cbb0c0ab6ba8848be762e Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 5 Aug 2019 12:30:36 +0100 Subject: [PATCH 04/49] ECC-964 --- definitions/grib1/2.98.171.table | 2 +- definitions/grib1/localConcepts/ecmf/shortName.def | 2 +- definitions/grib2/localConcepts/ecmf/cfVarName.def | 2 +- definitions/grib2/localConcepts/ecmf/shortName.def | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/definitions/grib1/2.98.171.table b/definitions/grib1/2.98.171.table index 18666a4f5..39cf33bfe 100644 --- a/definitions/grib1/2.98.171.table +++ b/definitions/grib1/2.98.171.table @@ -137,7 +137,7 @@ 204 204 - Precipitation analysis weights 205 205 - Runoff (m) 206 206 - Total column ozone (kg m**-2) -207 207 - 10 metre wind speed (m s**-1) +207 207 10SIA 10 metre wind speed (m s**-1) 208 208 - Top net solar radiation, clear sky (W m**-2 s) 209 209 - Top net thermal radiation, clear sky (W m**-2 s) 210 210 - Surface net solar radiation, clear sky (W m**-2 s) diff --git a/definitions/grib1/localConcepts/ecmf/shortName.def b/definitions/grib1/localConcepts/ecmf/shortName.def index 4d0f70675..92c1dd09e 100644 --- a/definitions/grib1/localConcepts/ecmf/shortName.def +++ b/definitions/grib1/localConcepts/ecmf/shortName.def @@ -14375,7 +14375,7 @@ indicatorOfParameter = 206 ; } #10 metre wind speed anomaly -'10ua' = { +'10sia' = { table2Version = 171 ; indicatorOfParameter = 207 ; } diff --git a/definitions/grib2/localConcepts/ecmf/cfVarName.def b/definitions/grib2/localConcepts/ecmf/cfVarName.def index 1beb1a3f7..9cbe41085 100644 --- a/definitions/grib2/localConcepts/ecmf/cfVarName.def +++ b/definitions/grib2/localConcepts/ecmf/cfVarName.def @@ -18583,7 +18583,7 @@ parameterNumber = 206 ; } #10 metre wind speed anomaly -'ua10' = { +'sia10' = { discipline = 192 ; parameterCategory = 171 ; parameterNumber = 207 ; diff --git a/definitions/grib2/localConcepts/ecmf/shortName.def b/definitions/grib2/localConcepts/ecmf/shortName.def index da5c0b741..49501d40d 100644 --- a/definitions/grib2/localConcepts/ecmf/shortName.def +++ b/definitions/grib2/localConcepts/ecmf/shortName.def @@ -18583,7 +18583,7 @@ parameterNumber = 206 ; } #10 metre wind speed anomaly -'10ua' = { +'10sia' = { discipline = 192 ; parameterCategory = 171 ; parameterNumber = 207 ; From 8efdcd31a54640498791ca777adf2bff10dce790 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 5 Aug 2019 12:32:54 +0100 Subject: [PATCH 05/49] ECC-948 --- definitions/mars/type.table | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/definitions/mars/type.table b/definitions/mars/type.table index 70d76903c..c9dd876fa 100644 --- a/definitions/mars/type.table +++ b/definitions/mars/type.table @@ -56,7 +56,7 @@ 70 or Ocean reanalysis 71 fx Flux forcing 72 fu Fill-up -73 sfo Simulation forced with observations +73 sfo Simulations with forcing 80 fcmean Forecast mean 81 fcmax Forecast maximum 82 fcmin Forecast minimum From f9ff79591dee878b0df848ffbcb46b9a36878165 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 5 Aug 2019 12:38:19 +0100 Subject: [PATCH 06/49] ECC-947 --- definitions/mars/grib.wfas.cf.def | 7 +++++++ definitions/mars/grib.wfas.fc.def | 7 +++++++ definitions/mars/grib.wfas.fu.def | 15 +++++++++++++++ definitions/mars/grib.wfas.pf.def | 8 ++++++++ definitions/mars/grib.wfas.sfo.def | 15 +++++++++++++++ definitions/mars/grib.wfcl.cf.def | 10 ++++++++++ definitions/mars/grib.wfcl.fc.def | 10 ++++++++++ definitions/mars/grib.wfcl.pf.def | 13 +++++++++++++ definitions/mars/grib.wfcl.sfo.def | 14 ++++++++++++++ definitions/mars/stream.table | 3 ++- 10 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 definitions/mars/grib.wfas.cf.def create mode 100644 definitions/mars/grib.wfas.fc.def create mode 100644 definitions/mars/grib.wfas.fu.def create mode 100644 definitions/mars/grib.wfas.pf.def create mode 100644 definitions/mars/grib.wfas.sfo.def create mode 100644 definitions/mars/grib.wfcl.cf.def create mode 100644 definitions/mars/grib.wfcl.fc.def create mode 100644 definitions/mars/grib.wfcl.pf.def create mode 100644 definitions/mars/grib.wfcl.sfo.def diff --git a/definitions/mars/grib.wfas.cf.def b/definitions/mars/grib.wfas.cf.def new file mode 100644 index 000000000..95c6f47af --- /dev/null +++ b/definitions/mars/grib.wfas.cf.def @@ -0,0 +1,7 @@ +# GLOFAS + +alias mars.origin = inputOriginatingCentre; + +# We need this because 'efas_post_proc' is defined later +meta efas_model sprintf("%s", efas_post_proc) : no_copy; +alias mars.model = efas_model; diff --git a/definitions/mars/grib.wfas.fc.def b/definitions/mars/grib.wfas.fc.def new file mode 100644 index 000000000..95c6f47af --- /dev/null +++ b/definitions/mars/grib.wfas.fc.def @@ -0,0 +1,7 @@ +# GLOFAS + +alias mars.origin = inputOriginatingCentre; + +# We need this because 'efas_post_proc' is defined later +meta efas_model sprintf("%s", efas_post_proc) : no_copy; +alias mars.model = efas_model; diff --git a/definitions/mars/grib.wfas.fu.def b/definitions/mars/grib.wfas.fu.def new file mode 100644 index 000000000..6ebed133f --- /dev/null +++ b/definitions/mars/grib.wfas.fu.def @@ -0,0 +1,15 @@ +# GLOFAS + +# ECC-701 +alias mars.step = endStep; + +alias mars.date = dateOfForecast; +alias mars.time = timeOfForecast; + +alias mars.origin = inputOriginatingCentre; + +alias mars.anoffset=anoffset; + +# We need this because 'efas_post_proc' is defined later +meta efas_model sprintf("%s", efas_post_proc) : no_copy; +alias mars.model = efas_model; diff --git a/definitions/mars/grib.wfas.pf.def b/definitions/mars/grib.wfas.pf.def new file mode 100644 index 000000000..9a8ede38f --- /dev/null +++ b/definitions/mars/grib.wfas.pf.def @@ -0,0 +1,8 @@ +# GLOFAS +alias mars.origin = inputOriginatingCentre; + +alias mars.number = perturbationNumber; + +# We need this because 'efas_post_proc' is defined later +meta efas_model sprintf("%s", efas_post_proc) : no_copy; +alias mars.model = efas_model; diff --git a/definitions/mars/grib.wfas.sfo.def b/definitions/mars/grib.wfas.sfo.def new file mode 100644 index 000000000..6ebed133f --- /dev/null +++ b/definitions/mars/grib.wfas.sfo.def @@ -0,0 +1,15 @@ +# GLOFAS + +# ECC-701 +alias mars.step = endStep; + +alias mars.date = dateOfForecast; +alias mars.time = timeOfForecast; + +alias mars.origin = inputOriginatingCentre; + +alias mars.anoffset=anoffset; + +# We need this because 'efas_post_proc' is defined later +meta efas_model sprintf("%s", efas_post_proc) : no_copy; +alias mars.model = efas_model; diff --git a/definitions/mars/grib.wfcl.cf.def b/definitions/mars/grib.wfcl.cf.def new file mode 100644 index 000000000..9693247bb --- /dev/null +++ b/definitions/mars/grib.wfcl.cf.def @@ -0,0 +1,10 @@ +# GLOFAS climatology +alias mars.origin = inputOriginatingCentre; + +# We need this because 'efas_post_proc' is defined later +meta efas_model sprintf("%s", efas_post_proc) : no_copy; +alias mars.model = efas_model; + +alias mars.date = dateOfModelVersion; +alias mars.time = dataTime; +alias mars.hdate = dataDate; diff --git a/definitions/mars/grib.wfcl.fc.def b/definitions/mars/grib.wfcl.fc.def new file mode 100644 index 000000000..9693247bb --- /dev/null +++ b/definitions/mars/grib.wfcl.fc.def @@ -0,0 +1,10 @@ +# GLOFAS climatology +alias mars.origin = inputOriginatingCentre; + +# We need this because 'efas_post_proc' is defined later +meta efas_model sprintf("%s", efas_post_proc) : no_copy; +alias mars.model = efas_model; + +alias mars.date = dateOfModelVersion; +alias mars.time = dataTime; +alias mars.hdate = dataDate; diff --git a/definitions/mars/grib.wfcl.pf.def b/definitions/mars/grib.wfcl.pf.def new file mode 100644 index 000000000..3fe7a09a4 --- /dev/null +++ b/definitions/mars/grib.wfcl.pf.def @@ -0,0 +1,13 @@ +# GLOFAS climatology + +alias mars.origin = inputOriginatingCentre; + +alias mars.number = perturbationNumber; + +# We need this because 'efas_post_proc' is defined later +meta efas_model sprintf("%s", efas_post_proc) : no_copy; +alias mars.model = efas_model; + +alias mars.date = dateOfModelVersion; +alias mars.time = dataTime; +alias mars.hdate = dataDate; diff --git a/definitions/mars/grib.wfcl.sfo.def b/definitions/mars/grib.wfcl.sfo.def new file mode 100644 index 000000000..97b2019ee --- /dev/null +++ b/definitions/mars/grib.wfcl.sfo.def @@ -0,0 +1,14 @@ +# GLOFAS climatology + +# ECC-701 +alias mars.step = endStep; + +alias mars.date = dateOfModelVersion; +alias mars.time = dataTime; +alias mars.hdate = dataDate; + +alias mars.origin = inputOriginatingCentre; + +# We need this because 'efas_post_proc' is defined later +meta efas_model sprintf("%s", efas_post_proc) : no_copy; +alias mars.model = efas_model; diff --git a/definitions/mars/stream.table b/definitions/mars/stream.table index 678218e08..af22214b5 100644 --- a/definitions/mars/stream.table +++ b/definitions/mars/stream.table @@ -34,7 +34,8 @@ 1057 efas European Flood Awareness System (EFAS) 1058 efse European Flood Awareness System (EFAS) seasonal forecasts 1059 efcl European Flood Awareness System (EFAS) climatology -1060 wfas Global flood awareness system +1060 wfas Global flood awareness system (GLOFAS) +1061 wfcl Global flood awareness system (GLOFAS) climatology 1070 msdc Monthly standard deviation and covariance 1071 moda Monthly means of daily means 1072 monr Monthly means using G. Boer's step function From 8ce794b3b12911546f5bdf37ada51251c1a75267 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 5 Aug 2019 12:42:40 +0100 Subject: [PATCH 07/49] Tigge: UER-16-CERRA --- tigge/tigge_check.h | 461 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 461 insertions(+) diff --git a/tigge/tigge_check.h b/tigge/tigge_check.h index 5b5f61c9c..47f3bb014 100644 --- a/tigge/tigge_check.h +++ b/tigge/tigge_check.h @@ -3409,6 +3409,467 @@ uerra, eswi-enfo:total_cloud_cover_sfc maximum value 96.4844 is not in [100,100] }, {&point_in_time, &has_bitmap}, }, +/* + carra / cerra +*/ + { + "specific_rain_water_content_ml", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"paramId", GRIB_TYPE_LONG, 75}, + + {"discipline", GRIB_TYPE_LONG, 0}, + {"parameterCategory", GRIB_TYPE_LONG, 1}, + {"parameterNumber", GRIB_TYPE_LONG, 85}, + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 105}, + {"scaleFactorOfFirstFixedSurface", GRIB_TYPE_LONG, 0}, + {NULL, }, + }, + {&point_in_time, &given_level}, /* check model levels?? */ + }, + + { + "specific_snow_water_content_ml", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"paramId", GRIB_TYPE_LONG, 76}, + + {"discipline", GRIB_TYPE_LONG, 0}, + {"parameterCategory", GRIB_TYPE_LONG, 1}, + {"parameterNumber", GRIB_TYPE_LONG, 86}, + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 105}, + {"scaleFactorOfFirstFixedSurface", GRIB_TYPE_LONG, 0}, + {NULL, }, + }, + {&point_in_time, &given_level}, /* check model levels?? */ + }, + + { + "graupel_ml", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"paramId", GRIB_TYPE_LONG, 260028}, + + {"discipline", GRIB_TYPE_LONG, 0}, + {"parameterCategory", GRIB_TYPE_LONG, 1}, + {"parameterNumber", GRIB_TYPE_LONG, 32}, + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 105}, + {"scaleFactorOfFirstFixedSurface", GRIB_TYPE_LONG, 0}, + {NULL, }, + }, + {&point_in_time, &given_level}, /* check model levels?? */ + }, + + { + "turbulent_kinetic_energy_ml", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"paramId", GRIB_TYPE_LONG, 260155}, + + {"discipline", GRIB_TYPE_LONG, 0}, + {"parameterCategory", GRIB_TYPE_LONG, 19}, + {"parameterNumber", GRIB_TYPE_LONG, 11}, + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 105}, + {"scaleFactorOfFirstFixedSurface", GRIB_TYPE_LONG, 0}, + {NULL, }, + }, + {&point_in_time, &given_level}, /* check model levels?? */ + }, + + { + "specific_rain_water_content_pl", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"paramId", GRIB_TYPE_LONG, 75}, + + {"discipline", GRIB_TYPE_LONG, 0}, + {"parameterCategory", GRIB_TYPE_LONG, 1}, + {"parameterNumber", GRIB_TYPE_LONG, 85}, + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 100}, + {NULL, }, + }, + {&point_in_time, &given_level, &pressure_level}, + }, + + { + "specific_snow_water_content_pl", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"paramId", GRIB_TYPE_LONG, 76}, + + {"discipline", GRIB_TYPE_LONG, 0}, + {"parameterCategory", GRIB_TYPE_LONG, 1}, + {"parameterNumber", GRIB_TYPE_LONG, 86}, + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 100}, + {NULL, }, + }, + {&point_in_time, &given_level, &pressure_level}, + }, + + { + "graupel_pl", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"paramId", GRIB_TYPE_LONG, 260028}, + + {"discipline", GRIB_TYPE_LONG, 0}, + {"parameterCategory", GRIB_TYPE_LONG, 1}, + {"parameterNumber", GRIB_TYPE_LONG, 32}, + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 100}, + {NULL, }, + }, + {&point_in_time, &given_level, &pressure_level}, + }, + + { + "pseudo-adiabatic_potential_temperature_pl", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"paramId", GRIB_TYPE_LONG, 3014}, + + {"discipline", GRIB_TYPE_LONG, 0}, + {"parameterCategory", GRIB_TYPE_LONG, 0}, + {"parameterNumber", GRIB_TYPE_LONG, 3}, + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 100}, + {NULL, }, + }, + {&point_in_time, &given_level, &pressure_level}, + }, + + { + "geometric_vertical_velocity_pl", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"paramId", GRIB_TYPE_LONG, 260238}, + + {"discipline", GRIB_TYPE_LONG, 0}, + {"parameterCategory", GRIB_TYPE_LONG, 2}, + {"parameterNumber", GRIB_TYPE_LONG, 9}, + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 100}, + {NULL, }, + }, + {&point_in_time, &given_level, &pressure_level}, + }, + + { + "potential_vorticity_pl", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"paramId", GRIB_TYPE_LONG, 60}, + + {"discipline", GRIB_TYPE_LONG, 0}, + {"parameterCategory", GRIB_TYPE_LONG, 2}, + {"parameterNumber", GRIB_TYPE_LONG, 14}, + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 100}, + {NULL, }, + }, + {&point_in_time, &given_level, &pressure_level}, + }, + + { + "visibility_sfc", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"paramId", GRIB_TYPE_LONG, 3020}, + + {"discipline", GRIB_TYPE_LONG, 0}, + {"parameterCategory", GRIB_TYPE_LONG, 19}, + {"parameterNumber", GRIB_TYPE_LONG, 0}, + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 1}, + {NULL, }, + }, + {&point_in_time, &predefined_level}, + }, + + { + "cloud_base_sfc", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"paramId", GRIB_TYPE_LONG, 260107}, + + {"discipline", GRIB_TYPE_LONG, 0}, + {"parameterCategory", GRIB_TYPE_LONG, 6}, + {"parameterNumber", GRIB_TYPE_LONG, 11}, + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 1}, + {NULL, }, + }, + {&point_in_time, &predefined_level}, + }, + + { + "cloud_top_sfc", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"paramId", GRIB_TYPE_LONG, 260108}, + + {"discipline", GRIB_TYPE_LONG, 0}, + {"parameterCategory", GRIB_TYPE_LONG, 6}, + {"parameterNumber", GRIB_TYPE_LONG, 12}, + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 1}, + {NULL, }, + }, + {&point_in_time, &predefined_level}, + }, + + { + "sea_ice_cover_sfc", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"paramId", GRIB_TYPE_LONG, 31}, + + {"discipline", GRIB_TYPE_LONG, 10}, + {"parameterCategory", GRIB_TYPE_LONG, 2}, + {"parameterNumber", GRIB_TYPE_LONG, 0}, + + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 1}, + {NULL, }, + }, + {&point_in_time, &predefined_level, &has_bitmap}, + }, + + { + "sea_surface_temperature_sfc", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"paramId", GRIB_TYPE_LONG, 34}, + + {"discipline", GRIB_TYPE_LONG, 10}, + {"parameterCategory", GRIB_TYPE_LONG, 3}, + {"parameterNumber", GRIB_TYPE_LONG, 0}, + + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 1}, + {NULL, }, + }, + {&point_in_time, &predefined_level, &has_bitmap}, + }, + + { + "precipitation_type_sfc", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"paramId", GRIB_TYPE_LONG, 260015}, + + {"discipline", GRIB_TYPE_LONG, 0}, + {"parameterCategory", GRIB_TYPE_LONG, 1}, + {"parameterNumber", GRIB_TYPE_LONG, 19}, + + {"typeOfStatisticalProcessing", GRIB_TYPE_LONG, 1}, + + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 1}, + {NULL, }, + }, + {&point_in_time, &predefined_level}, + }, + + { + "specific_rain_water_content_hl", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"paramId", GRIB_TYPE_LONG, 75}, + + {"discipline", GRIB_TYPE_LONG, 0}, + {"parameterCategory", GRIB_TYPE_LONG, 1}, + {"parameterNumber", GRIB_TYPE_LONG, 85}, + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 103}, + {"scaleFactorOfFirstFixedSurface", GRIB_TYPE_LONG, 0}, + {NULL, }, + }, + {&point_in_time, &given_level, &height_level}, + }, + + { + "specific_snow_water_content_hl", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"paramId", GRIB_TYPE_LONG, 76}, + + {"discipline", GRIB_TYPE_LONG, 0}, + {"parameterCategory", GRIB_TYPE_LONG, 1}, + {"parameterNumber", GRIB_TYPE_LONG, 86}, + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 103}, + {"scaleFactorOfFirstFixedSurface", GRIB_TYPE_LONG, 0}, + {NULL, }, + }, + {&point_in_time, &given_level, &height_level}, + }, + + { + "turbulent_kinetic_energy_hl", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"paramId", GRIB_TYPE_LONG, 260155}, + + {"discipline", GRIB_TYPE_LONG, 0}, + {"parameterCategory", GRIB_TYPE_LONG, 19}, + {"parameterNumber", GRIB_TYPE_LONG, 11}, + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 103}, + {"scaleFactorOfFirstFixedSurface", GRIB_TYPE_LONG, 0}, + {NULL, }, + }, + {&point_in_time, &given_level, &height_level}, + }, +/* + cerra +*/ + + { + "momentum_flux_u_component_sfc", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"paramId", GRIB_TYPE_LONG, 260062}, + + {"discipline", GRIB_TYPE_LONG, 0}, + {"parameterCategory", GRIB_TYPE_LONG, 2}, + {"parameterNumber", GRIB_TYPE_LONG, 17}, + + {"typeOfStatisticalProcessing", GRIB_TYPE_LONG, 1}, + + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 1}, + {NULL, }, + }, + {&from_start, &predefined_level}, + }, + + { + "momentum_flux_v_component_sfc", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"paramId", GRIB_TYPE_LONG, 260063}, + + {"discipline", GRIB_TYPE_LONG, 0}, + {"parameterCategory", GRIB_TYPE_LONG, 2}, + {"parameterNumber", GRIB_TYPE_LONG, 18}, + + {"typeOfStatisticalProcessing", GRIB_TYPE_LONG, 1}, + + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 1}, + {NULL, }, + }, + {&from_start, &predefined_level}, + }, + + { + "time_integrated_surface_clear-sky_net_solar_radiation", + -0.1, + 1e+08, + 0, + 1e+09, + { + {"paramId", GRIB_TYPE_LONG, 210}, + + {"discipline", GRIB_TYPE_LONG, 0}, + {"parameterCategory", GRIB_TYPE_LONG, 4}, + {"parameterNumber", GRIB_TYPE_LONG, 11}, + + {"typeOfStatisticalProcessing", GRIB_TYPE_LONG, 1}, + + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 1}, + {NULL, }, + }, + {&from_start, &predefined_level}, + }, + + { + "time_integrated_surface_clear-sky_net_thermal_radiation", + -0.1, + 1e+08, + 0, + 1e+09, + { + {"paramId", GRIB_TYPE_LONG, 211}, + + {"discipline", GRIB_TYPE_LONG, 0}, + {"parameterCategory", GRIB_TYPE_LONG, 5}, + {"parameterNumber", GRIB_TYPE_LONG, 6}, + + {"typeOfStatisticalProcessing", GRIB_TYPE_LONG, 1}, + + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 1}, + {NULL, }, + }, + {&from_start, &predefined_level}, + }, + + { + "turbulent_kinetic_energy_pl", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"paramId", GRIB_TYPE_LONG, 260155}, + + {"discipline", GRIB_TYPE_LONG, 0}, + {"parameterCategory", GRIB_TYPE_LONG, 19}, + {"parameterNumber", GRIB_TYPE_LONG, 11}, + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 100}, + {NULL, }, + }, + {&point_in_time, &given_level, &pressure_level}, + }, }; From bbfb528795caf3df72c5f68c944a18da29458261 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 5 Aug 2019 12:46:52 +0100 Subject: [PATCH 08/49] ECC-949 --- tools/grib_merge.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/tools/grib_merge.c b/tools/grib_merge.c index 376291cb4..0fa6b78fb 100644 --- a/tools/grib_merge.c +++ b/tools/grib_merge.c @@ -145,24 +145,24 @@ static grib_handle* merge(grib_handle* h1,grib_handle* h2) len2=sizeof(s2)/sizeof(*s2); err=grib_get_string(h2,"gridType",s2,&len2); if (strcmp(s2,"regular_ll")) { - grib_context_log(h1->context,GRIB_LOG_WARNING,"gridType=%s not supported",s2); + grib_context_log(h1->context,GRIB_LOG_ERROR,"gridType=%s not supported",s2); return NULL; } len1=sizeof(s1)/sizeof(*s1); err=grib_get_string(h1,"gridType",s1,&len1); if (strcmp(s1,"regular_ll")) { - grib_context_log(h1->context,GRIB_LOG_WARNING,"gridType=%s not supported",s1); + grib_context_log(h1->context,GRIB_LOG_ERROR,"gridType=%s not supported",s1); return NULL; } if (!grib_key_equal(h1,h2,"iDirectionIncrementInDegrees",GRIB_TYPE_DOUBLE,&err) ) { - grib_context_log(h1->context,GRIB_LOG_WARNING, + grib_context_log(h1->context,GRIB_LOG_ERROR, "unable to merge: different iDirectionIncrementInDegrees"); return NULL; } if (!grib_key_equal(h1,h2,"jDirectionIncrementInDegrees",GRIB_TYPE_DOUBLE,&err) ) { - grib_context_log(h1->context,GRIB_LOG_WARNING, + grib_context_log(h1->context,GRIB_LOG_ERROR, "unable to merge: different jDirectionIncrementInDegrees"); return NULL; } @@ -171,7 +171,7 @@ static grib_handle* merge(grib_handle* h1,grib_handle* h2) grib_get_long(h2,"latitudeOfFirstGridPoint",&l2); grib_get_long(h2,"jDirectionIncrement",&idj); if ( (l1-l2) % idj ) { - grib_context_log(h1->context,GRIB_LOG_WARNING, "unable to merge: incompatible grid"); + grib_context_log(h1->context,GRIB_LOG_ERROR, "unable to merge: incompatible grid"); return NULL; } @@ -179,7 +179,7 @@ static grib_handle* merge(grib_handle* h1,grib_handle* h2) grib_get_long(h2,"longitudeOfFirstGridPoint",&l2); grib_get_long(h2,"iDirectionIncrement",&idi); if ( (l1-l2) % idi ) { - grib_context_log(h1->context,GRIB_LOG_WARNING, "unable to merge: incompatible grid"); + grib_context_log(h1->context,GRIB_LOG_ERROR, "unable to merge: incompatible grid"); return NULL; } @@ -214,14 +214,22 @@ static grib_handle* merge(grib_handle* h1,grib_handle* h2) grib_get_double(h1,"longitudeOfFirstGridPointInDegrees",&lonFirst1); grib_get_double(h2,"longitudeOfFirstGridPointInDegrees",&lonFirst2); - latFirst = latFirst1>latFirst2 ? latFirst1 : latFirst2; - lonFirst = lonFirst1latFirst2 ? latFirst1 : latFirst2; + lonFirst = lonFirst1lonLast2 ? lonLast1 : lonLast2; From bbea289979b99f6009a80e72065ff1f80b99e536 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 23 Sep 2019 11:34:55 +0100 Subject: [PATCH 09/49] ECC-673: bufr_filter: cope with emoslib and bufrdc having different executable names --- tools/bufr_filter | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/bufr_filter b/tools/bufr_filter index 645485334..ffd51ac17 100755 --- a/tools/bufr_filter +++ b/tools/bufr_filter @@ -1,7 +1,8 @@ #!/bin/sh set -u script_dir=`dirname $0` -EMOSLIB_TOOL=bufrdc_emoslib_bufr_filter +BUFRDC_TOOL=bufrdc_emoslib_bufr_filter +EMOSLIB_TOOL=emoslib_bufr_filter ECCODES_TOOL=codes_bufr_filter result=0 # return code from function ERR_TOOL_NOT_FOUND=666 @@ -37,7 +38,7 @@ if [ $# -eq 0 ]; then the_tool=$ECCODES_TOOL try_tool "${@}" if [ $result -eq $ERR_TOOL_NOT_FOUND ]; then - the_tool=$EMOSLIB_TOOL + the_tool=$BUFRDC_TOOL try_tool "${@}" fi exit 0 @@ -53,6 +54,10 @@ if [ $is_emoslib -eq 1 ]; then pkg='emoslib/bufrdc' the_tool=$EMOSLIB_TOOL try_tool "${@}" + if [ $result -eq $ERR_TOOL_NOT_FOUND ]; then + the_tool=$BUFRDC_TOOL + try_tool "${@}" + fi else pkg='ecCodes' the_tool=$ECCODES_TOOL From 0cd671e8e0b303c92e31c856570ea9e5347f4972 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 24 Sep 2019 17:24:37 +0100 Subject: [PATCH 10/49] Add key localUsePresent for BUFR (same as GRIB) --- definitions/bufr/boot_edition_0.def | 1 + definitions/bufr/boot_edition_1.def | 2 +- definitions/bufr/boot_edition_2.def | 1 + definitions/bufr/boot_edition_3.def | 1 + definitions/bufr/boot_edition_4.def | 2 +- 5 files changed, 5 insertions(+), 2 deletions(-) diff --git a/definitions/bufr/boot_edition_0.def b/definitions/bufr/boot_edition_0.def index 086b379a5..12f7a2578 100644 --- a/definitions/bufr/boot_edition_0.def +++ b/definitions/bufr/boot_edition_0.def @@ -12,6 +12,7 @@ template section_1 "bufr/section.1.1.def"; flagbit localSectionPresent(section1Flags,7) = 1; alias section2Present=localSectionPresent; +alias localUsePresent=localSectionPresent; if(localSectionPresent){ template section_2 "bufr/section.2.def"; diff --git a/definitions/bufr/boot_edition_1.def b/definitions/bufr/boot_edition_1.def index 26d2af230..44f27f999 100644 --- a/definitions/bufr/boot_edition_1.def +++ b/definitions/bufr/boot_edition_1.def @@ -12,7 +12,7 @@ template section_1 "bufr/section.1.1.def"; flagbit localSectionPresent(section1Flags,7) = 1; alias section2Present=localSectionPresent; - +alias localUsePresent=localSectionPresent; if(localSectionPresent){ template section_2 "bufr/section.2.def"; diff --git a/definitions/bufr/boot_edition_2.def b/definitions/bufr/boot_edition_2.def index 580532c17..01d1d228d 100644 --- a/definitions/bufr/boot_edition_2.def +++ b/definitions/bufr/boot_edition_2.def @@ -12,6 +12,7 @@ template section_1 "bufr/section.1.2.def"; flagbit localSectionPresent(section1Flags,7) = 1; alias section2Present=localSectionPresent; +alias localUsePresent=localSectionPresent; if(localSectionPresent){ template section_2 "bufr/section.2.def"; diff --git a/definitions/bufr/boot_edition_3.def b/definitions/bufr/boot_edition_3.def index 4bb740592..28216ed3f 100644 --- a/definitions/bufr/boot_edition_3.def +++ b/definitions/bufr/boot_edition_3.def @@ -12,6 +12,7 @@ template section_1 "bufr/section.1.3.def"; flagbit localSectionPresent(section1Flags,7) = 1; alias section2Present=localSectionPresent; +alias localUsePresent=localSectionPresent; if(localSectionPresent){ template section_2 "bufr/section.2.def"; diff --git a/definitions/bufr/boot_edition_4.def b/definitions/bufr/boot_edition_4.def index f25469381..ee7e14721 100644 --- a/definitions/bufr/boot_edition_4.def +++ b/definitions/bufr/boot_edition_4.def @@ -12,7 +12,7 @@ template section_1 "bufr/section.1.4.def"; flagbit localSectionPresent(section1Flags,7) = 1; alias section2Present=localSectionPresent; - +alias localUsePresent=localSectionPresent; if(localSectionPresent){ template section_2 "bufr/section.2.def"; From ab8d84ee698484e1b81d7da3c99b7738f166c7c9 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 24 Sep 2019 17:25:24 +0100 Subject: [PATCH 11/49] grib_count_in_filename: Use binary mode for opening GRIB/BUFR file --- src/grib_io.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/grib_io.c b/src/grib_io.c index 30adcbd2a..511990d52 100644 --- a/src/grib_io.c +++ b/src/grib_io.c @@ -1303,6 +1303,7 @@ int wmo_read_any_from_stream(void* stream_data,long (*stream_proc)(void*,void* b return err; } +/* This function allocates memory for the result so the user is responsible for freeing it */ void* wmo_read_any_from_stream_malloc(void* stream_data,long (*stream_proc)(void*,void* buffer,long len) ,size_t *size, int* err) { alloc_buffer u; @@ -1333,7 +1334,7 @@ void* wmo_read_any_from_stream_malloc(void* stream_data,long (*stream_proc)(void /*================== */ - +/* This function allocates memory for the result so the user is responsible for freeing it */ void *wmo_read_gts_from_file_malloc(FILE* f,int headers_only,size_t *size,off_t *offset,int* err) { alloc_buffer u; @@ -1359,6 +1360,7 @@ void *wmo_read_gts_from_file_malloc(FILE* f,int headers_only,size_t *size,off_t return u.buffer; } +/* This function allocates memory for the result so the user is responsible for freeing it */ void *wmo_read_taf_from_file_malloc(FILE* f,int headers_only,size_t *size,off_t *offset,int* err) { alloc_buffer u; @@ -1384,6 +1386,7 @@ void *wmo_read_taf_from_file_malloc(FILE* f,int headers_only,size_t *size,off_t return u.buffer; } +/* This function allocates memory for the result so the user is responsible for freeing it */ void *wmo_read_metar_from_file_malloc(FILE* f,int headers_only,size_t *size,off_t *offset,int* err) { alloc_buffer u; @@ -1409,6 +1412,7 @@ void *wmo_read_metar_from_file_malloc(FILE* f,int headers_only,size_t *size,off_ return u.buffer; } +/* This function allocates memory for the result so the user is responsible for freeing it */ static void *_wmo_read_any_from_file_malloc(FILE* f,int* err,size_t *size,off_t *offset, int grib_ok,int bufr_ok, int hdf5_ok, int wrap_ok, int headers_only) { @@ -1436,22 +1440,23 @@ static void *_wmo_read_any_from_file_malloc(FILE* f,int* err,size_t *size,off_t return u.buffer; } + +/* This function allocates memory for the result so the user is responsible for freeing it */ void *wmo_read_any_from_file_malloc(FILE* f,int headers_only,size_t *size,off_t *offset,int* err) { return _wmo_read_any_from_file_malloc(f,err,size,offset, 1, 1, 1, 1, headers_only); } - +/* This function allocates memory for the result so the user is responsible for freeing it */ void *wmo_read_grib_from_file_malloc(FILE* f,int headers_only,size_t *size,off_t *offset,int* err) { return _wmo_read_any_from_file_malloc(f,err,size,offset, 1, 0, 0, 0, headers_only); } - +/* This function allocates memory for the result so the user is responsible for freeing it */ void *wmo_read_bufr_from_file_malloc(FILE* f,int headers_only,size_t *size,off_t *offset,int* err) { return _wmo_read_any_from_file_malloc(f,err,size,offset, 0, 1, 0, 0, headers_only); } - /* ======================================= */ typedef struct context_alloc_buffer { @@ -1471,7 +1476,6 @@ static void* context_allocate_buffer(void *data,size_t* length,int *err) return u->buffer; } - int grib_read_any_headers_only_from_file(grib_context* ctx,FILE* f,void* buffer,size_t* len) { int err; @@ -1533,7 +1537,6 @@ int grib_read_any_from_file(grib_context* ctx,FILE* f,void* buffer,size_t* len) } /* ======================================= */ - typedef struct memory_read_data { unsigned char *data; size_t data_len; @@ -1669,7 +1672,7 @@ int grib_count_in_filename(grib_context* c, const char* filename, int* n) int err=0; FILE* fp = NULL; if (!c) c=grib_context_get_default(); - fp = fopen(filename, "r"); + fp = fopen(filename, "rb"); if (!fp) { grib_context_log(c, GRIB_LOG_ERROR,"grib_count_in_filename: Unable to read file \"%s\"", filename); perror(filename); From e79a19c7415309eaba103feef41199c262dc20a1 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 25 Sep 2019 14:34:02 +0100 Subject: [PATCH 12/49] Remove unused header file --- src/CMakeLists.txt | 1 - src/Makefile.am | 1 - src/grib_expression.h | 78 ------------------------------------------- 3 files changed, 80 deletions(-) delete mode 100644 src/grib_expression.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7d43d4995..624fc78d7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -371,7 +371,6 @@ list( APPEND grib_api_srcs grib_dumper_class.h grib_dumper_factory.h grib_emoslib.h - grib_expression.h grib_iterator_class.h grib_iterator_factory.h grib_nearest_class.h diff --git a/src/Makefile.am b/src/Makefile.am index 280eba40f..1db931265 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -406,7 +406,6 @@ noinst_HEADERS = grib_api_internal.h \ grib_dumper_factory.h \ grib_accessor_class.h \ grib_accessor_factory.h \ - grib_expression.h \ grib_nearest_class.h \ grib_nearest_factory.h \ grib_box_class.h \ diff --git a/src/grib_expression.h b/src/grib_expression.h deleted file mode 100644 index a746cb60a..000000000 --- a/src/grib_expression.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2005-2019 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. - */ - -#ifndef grib_expression_H -#define grib_expression_H - -#include "grib_api_internal.h" - - -typedef int (*expression_evaluate_long_proc)(grib_expression*,grib_handle*,long*); -typedef int (*expression_evaluate_double_proc)(grib_expression*,grib_handle*,double*); -typedef const char* (*expression_evaluate_string_proc)(grib_expression*,grib_handle*,char*,size_t*,int*); -typedef const char* (*expression_get_name_proc)(grib_expression*); - -typedef void (*expression_print_proc)(grib_context*,grib_expression*,grib_handle*); -typedef void (*expression_compile_proc)(grib_expression*,grib_compiler*); -typedef void (*expression_add_dependency_proc) (grib_expression*e, grib_accessor* observer ); - -typedef struct grib_expression_class grib_expression_class; - -typedef void (*expression_class_init_proc) (grib_expression_class*e); -typedef void (*expression_init_proc) (grib_expression*e); -typedef void (*expression_destroy_proc) (grib_context*,grib_expression*e); - -typedef int (*expression_native_type_proc)(grib_expression*,grib_handle*); - -struct grib_expression { - grib_expression_class* cclass; -}; - -struct grib_expression_class { - - grib_expression_class **super; - const char *name; - size_t size; - int inited; - - expression_class_init_proc init_class; - expression_init_proc init; - expression_destroy_proc destroy; - - - expression_print_proc print; - expression_compile_proc compile; - expression_add_dependency_proc add_dependency; - - expression_native_type_proc native_type; - expression_get_name_proc get_name; - - expression_evaluate_long_proc evaluate_long; - expression_evaluate_double_proc evaluate_double; - expression_evaluate_string_proc evaluate_string; -}; - - -struct grib_arguments { - struct grib_arguments *next; - grib_expression *expression; - char value[80]; -}; - - -long grib_expression_evaluate(grib_handle*,grib_expression*); -void grib_expression_free(grib_context*,grib_expression*); - -grib_arguments* grib_arguments_new(grib_context*,grib_expression*,grib_arguments*); -void grib_arguments_free(grib_context*,grib_arguments*); - -const char* grib_argument_next(grib_arguments**); - -#endif From 9fd0f613d3b48d87ac7e00d033c0468bc47807ea Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 25 Sep 2019 14:35:43 +0100 Subject: [PATCH 13/49] Refactoring --- src/action_class_assert.c | 104 +++++++++--------- src/action_class_close.c | 61 +++++----- src/encode_double_array.c | 5 +- src/grib_accessor_class_blob.c | 29 ++--- ...ssor_class_bufr_extract_datetime_subsets.c | 2 +- src/grib_accessor_class_bytes.c | 65 +++++------ src/grib_accessor_class_data_simple_packing.c | 4 +- src/grib_accessor_class_g1_message_length.c | 6 +- src/grib_accessor_class_long.c | 6 +- src/grib_accessor_class_variable.c | 40 +++---- src/grib_dumper_class_bufr_encode_python.c | 10 +- src/grib_io.c | 8 +- src/grib_iterator_class_lambert_conformal.c | 4 +- src/grib_openjpeg_encoding.c | 4 +- 14 files changed, 174 insertions(+), 174 deletions(-) diff --git a/src/action_class_assert.c b/src/action_class_assert.c index e4bc1a773..4a7b2aa4e 100644 --- a/src/action_class_assert.c +++ b/src/action_class_assert.c @@ -79,81 +79,81 @@ static void init_class(grib_action_class* c) grib_action* grib_action_create_assert( grib_context* context, grib_expression* expression) { - grib_action_assert* a = NULL; - grib_action_class* c = grib_action_class_assert; - grib_action* act = (grib_action*)grib_context_malloc_clear_persistent(context,c->size); - act->next = NULL; - act->name = grib_context_strdup_persistent(context, "assertion"); - act->op = grib_context_strdup_persistent(context, "evaluate"); - act->cclass = c; - act->context = context; - a = (grib_action_assert*)act; - a->expression = expression; - return act; + grib_action_assert* a = NULL; + grib_action_class* c = grib_action_class_assert; + grib_action* act = (grib_action*)grib_context_malloc_clear_persistent(context,c->size); + act->next = NULL; + act->name = grib_context_strdup_persistent(context, "assertion"); + act->op = grib_context_strdup_persistent(context, "evaluate"); + act->cclass = c; + act->context = context; + a = (grib_action_assert*)act; + a->expression = expression; + return act; } static int create_accessor(grib_section* p, grib_action* act,grib_loader *h) { - grib_action_assert* self = (grib_action_assert*)act; - grib_accessor* as = grib_accessor_factory(p, act,0,NULL); - if(!as)return GRIB_INTERNAL_ERROR; - grib_dependency_observe_expression(as,self->expression); + grib_action_assert* self = (grib_action_assert*)act; + grib_accessor* as = grib_accessor_factory(p, act,0,NULL); + if(!as)return GRIB_INTERNAL_ERROR; + grib_dependency_observe_expression(as,self->expression); - grib_push_accessor(as,p->block); + grib_push_accessor(as,p->block); - - return GRIB_SUCCESS; + return GRIB_SUCCESS; } static void dump( grib_action* act, FILE* f, int lvl) { - int i =0; - grib_action_assert* self=(grib_action_assert*)act; - for (i=0;icontext,f," "); - grib_expression_print(act->context,self->expression,0); - printf("\n"); + int i =0; + grib_action_assert* self=(grib_action_assert*)act; + for (i=0;icontext,f," "); + grib_expression_print(act->context,self->expression,0); + printf("\n"); } static void destroy(grib_context* context,grib_action* act) { - grib_action_assert* a = ( grib_action_assert*)act; - grib_expression_free(context,a->expression); - grib_context_free_persistent(context, act->name); - grib_context_free_persistent(context, act->op); + grib_action_assert* a = ( grib_action_assert*)act; + grib_expression_free(context,a->expression); + grib_context_free_persistent(context, act->name); + grib_context_free_persistent(context, act->op); } -static int execute(grib_action* a,grib_handle* h) { - int ret=0; - double res=0; - grib_action_assert* self= (grib_action_assert*)a; +static int execute(grib_action* a,grib_handle* h) +{ + int ret=0; + double res=0; + grib_action_assert* self= (grib_action_assert*)a; - if ((ret=grib_expression_evaluate_double(h,self->expression,&res)) != GRIB_SUCCESS) - return ret; + if ((ret=grib_expression_evaluate_double(h,self->expression,&res)) != GRIB_SUCCESS) + return ret; - if (res != 0) - return GRIB_SUCCESS; - else { - grib_context_log(h->context,GRIB_LOG_ERROR,"Assertion failure: "); - grib_expression_print(h->context,self->expression,h); - printf("\n"); - return GRIB_ASSERTION_FAILURE; - } + if (res != 0) { + return GRIB_SUCCESS; + } + else { + grib_context_log(h->context,GRIB_LOG_ERROR,"Assertion failure: "); + grib_expression_print(h->context,self->expression,h); + printf("\n"); + return GRIB_ASSERTION_FAILURE; + } } static int notify_change(grib_action* a, grib_accessor* observer,grib_accessor* observed) { - grib_action_assert* self = (grib_action_assert*) a; + grib_action_assert* self = (grib_action_assert*) a; - int ret = GRIB_SUCCESS; - long lres; + int ret = GRIB_SUCCESS; + long lres; - if ((ret = grib_expression_evaluate_long(grib_handle_of_accessor(observed), self->expression,&lres)) - != GRIB_SUCCESS) return ret; + if ((ret = grib_expression_evaluate_long(grib_handle_of_accessor(observed), self->expression,&lres)) + != GRIB_SUCCESS) return ret; - - if (lres != 0) - return GRIB_SUCCESS; - else - return GRIB_ASSERTION_FAILURE; + if (lres != 0) + return GRIB_SUCCESS; + else + return GRIB_ASSERTION_FAILURE; } diff --git a/src/action_class_close.c b/src/action_class_close.c index 4556d15a9..82e13a23e 100644 --- a/src/action_class_close.c +++ b/src/action_class_close.c @@ -72,57 +72,54 @@ static void init_class(grib_action_class* c) grib_action* grib_action_create_close( grib_context* context, char* filename) { - char buf[1024]; + char buf[1024]; - grib_action_close* a ; - grib_action_class* c = grib_action_class_close; - grib_action* act = (grib_action*)grib_context_malloc_clear_persistent(context,c->size); - act->op = grib_context_strdup_persistent(context,"section"); + grib_action_close* a ; + grib_action_class* c = grib_action_class_close; + grib_action* act = (grib_action*)grib_context_malloc_clear_persistent(context,c->size); + act->op = grib_context_strdup_persistent(context,"section"); - act->cclass = c; - a = (grib_action_close*)act; - act->context = context; + act->cclass = c; + a = (grib_action_close*)act; + act->context = context; - a->filename = grib_context_strdup_persistent(context,filename); + a->filename = grib_context_strdup_persistent(context,filename); - sprintf(buf,"close_%p",(void*)a->filename); + sprintf(buf,"close_%p",(void*)a->filename); - act->name = grib_context_strdup_persistent(context,buf); + act->name = grib_context_strdup_persistent(context,buf); - return act; + return act; } static int execute(grib_action* act, grib_handle *h) { - char filename[2048]={0,}; - size_t len=2048; - grib_action_close* self = (grib_action_close*) act; - int err =0; - grib_file* file=0; + char filename[2048]={0,}; + size_t len=2048; + grib_action_close* self = (grib_action_close*) act; + int err =0; + grib_file* file=0; - err=grib_get_string(h,self->filename,filename,&len); - /* fprintf(stderr,"++++ name %s\n",filename); */ - if (err) return err; - /* grib_file_close(filename,1,&err); */ - file=grib_get_file(filename,&err); - if (err) return err; - if (file) grib_file_pool_delete_file(file); + err=grib_get_string(h,self->filename,filename,&len); + /* fprintf(stderr,"++++ name %s\n",filename); */ + if (err) return err; + /* grib_file_close(filename,1,&err); */ + file=grib_get_file(filename,&err); + if (err) return err; + if (file) grib_file_pool_delete_file(file); - return err; + return err; } - static void dump(grib_action* act, FILE* f, int lvl) { } - static void destroy(grib_context* context,grib_action* act) { - grib_action_close* a = (grib_action_close*) act; - - grib_context_free_persistent(context, a->filename); - grib_context_free_persistent(context, act->name); - grib_context_free_persistent(context, act->op); + grib_action_close* a = (grib_action_close*) act; + grib_context_free_persistent(context, a->filename); + grib_context_free_persistent(context, act->name); + grib_context_free_persistent(context, act->op); } diff --git a/src/encode_double_array.c b/src/encode_double_array.c index e41131126..04732e002 100644 --- a/src/encode_double_array.c +++ b/src/encode_double_array.c @@ -199,11 +199,8 @@ void encode_double_array_unrolled(int numBits, long packStart, long datasize, { U_BYTEORDER; long i, j, z = *gz; -#ifdef _ARCH_PWR6 + #define __UNROLL_DEPTH_2 8 -#else -#define __UNROLL_DEPTH_2 8 -#endif data += packStart; datasize -= packStart; diff --git a/src/grib_accessor_class_blob.c b/src/grib_accessor_class_blob.c index d36c473c3..0e405a846 100644 --- a/src/grib_accessor_class_blob.c +++ b/src/grib_accessor_class_blob.c @@ -129,28 +129,29 @@ static void init_class(grib_accessor_class* c) static void init(grib_accessor* a, const long len , grib_arguments* arg ) { - grib_get_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, arg, 0), &a->length); - Assert(a->length>=0); - + grib_get_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, arg, 0), &a->length); + Assert(a->length>=0); } -static int get_native_type(grib_accessor* a){ - return GRIB_TYPE_BYTES; +static int get_native_type(grib_accessor* a) +{ + return GRIB_TYPE_BYTES; } -static int unpack_bytes (grib_accessor* a,unsigned char* buffer, size_t *len) { - if (*len < a->length) { - *len = a->length; - return GRIB_ARRAY_TOO_SMALL; - } - *len = a->length; +static int unpack_bytes (grib_accessor* a,unsigned char* buffer, size_t *len) +{ + if (*len < a->length) { + *len = a->length; + return GRIB_ARRAY_TOO_SMALL; + } + *len = a->length; - memcpy(buffer, grib_handle_of_accessor(a)->buffer->data + a->offset, *len); + memcpy(buffer, grib_handle_of_accessor(a)->buffer->data + a->offset, *len); - return GRIB_SUCCESS; + return GRIB_SUCCESS; } static void dump(grib_accessor* a, grib_dumper* dumper) { - grib_dump_bytes(dumper,a,NULL); + grib_dump_bytes(dumper,a,NULL); } diff --git a/src/grib_accessor_class_bufr_extract_datetime_subsets.c b/src/grib_accessor_class_bufr_extract_datetime_subsets.c index 129bdbcc6..d125c8c6c 100644 --- a/src/grib_accessor_class_bufr_extract_datetime_subsets.c +++ b/src/grib_accessor_class_bufr_extract_datetime_subsets.c @@ -183,7 +183,7 @@ static int build_long_array(grib_context* c, grib_handle* h, int compressed, long** array, const char* key, long numberOfSubsets, int zero_on_error) { int err = 0; - size_t i; + long i; size_t n=numberOfSubsets; *array=(long*)grib_context_malloc_clear(c, sizeof(long)*numberOfSubsets); if(compressed) { diff --git a/src/grib_accessor_class_bytes.c b/src/grib_accessor_class_bytes.c index f684bc171..500685de2 100644 --- a/src/grib_accessor_class_bytes.c +++ b/src/grib_accessor_class_bytes.c @@ -129,47 +129,48 @@ static void init_class(grib_accessor_class* c) static void init(grib_accessor* a, const long len , grib_arguments* arg ) { - /*grib_accessor_signed* self = (grib_accessor_signed*)a; */ - a->length = len; - Assert(a->length>=0); - + /*grib_accessor_signed* self = (grib_accessor_signed*)a; */ + a->length = len; + Assert(a->length>=0); } -static int get_native_type(grib_accessor* a){ - return GRIB_TYPE_BYTES; +static int get_native_type(grib_accessor* a) +{ + return GRIB_TYPE_BYTES; } +static int compare(grib_accessor* a, grib_accessor* b) +{ + int retval=GRIB_SUCCESS; -static int compare(grib_accessor* a, grib_accessor* b) { - int retval=GRIB_SUCCESS; + size_t alen = (size_t)grib_byte_count(a); + size_t blen = (size_t)grib_byte_count(b); - size_t alen = (size_t)grib_byte_count(a); - size_t blen = (size_t)grib_byte_count(b); + if (alen != blen) return GRIB_COUNT_MISMATCH; - if (alen != blen) return GRIB_COUNT_MISMATCH; - - return retval; + return retval; } -static int unpack_string(grib_accessor *a , char* v, size_t *len){ - unsigned char* p=NULL; - char* s=v; - int i; - long length=grib_byte_count(a); +static int unpack_string(grib_accessor *a , char* v, size_t *len) +{ + unsigned char* p=NULL; + char* s=v; + int i; + long length=grib_byte_count(a); - if (*len < 2*length) { - *len=2*length; - return GRIB_ARRAY_TOO_SMALL; - } - - p = grib_handle_of_accessor(a)->buffer->data + grib_byte_offset(a); - - for (i = 0; i < length; i++) { - sprintf (s,"%02x", *(p++)); - s+=2; - } - - *len=length; + if (*len < 2*length) { + *len=2*length; + return GRIB_ARRAY_TOO_SMALL; + } - return GRIB_SUCCESS; + p = grib_handle_of_accessor(a)->buffer->data + grib_byte_offset(a); + + for (i = 0; i < length; i++) { + sprintf (s,"%02x", *(p++)); + s+=2; + } + + *len=length; + + return GRIB_SUCCESS; } diff --git a/src/grib_accessor_class_data_simple_packing.c b/src/grib_accessor_class_data_simple_packing.c index a9a8f0d0e..f08c6c188 100644 --- a/src/grib_accessor_class_data_simple_packing.c +++ b/src/grib_accessor_class_data_simple_packing.c @@ -331,7 +331,7 @@ static int _unpack_double(grib_accessor* a, double* val, size_t *len,unsigned c GRIB_SUCCESS) return err; - /*/ + /* * check we don't decode bpv > max(ulong) as it is * not currently supported by the algorithm */ @@ -557,7 +557,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t *len) if((err = grib_get_long_internal(gh,self->optimize_scaling_factor, &optimize_scaling_factor)) != GRIB_SUCCESS) return err; - /*/ + /* * check we don't encode bpv > max(ulong)-1 as it is * not currently supported by the algorithm */ diff --git a/src/grib_accessor_class_g1_message_length.c b/src/grib_accessor_class_g1_message_length.c index 070ed2385..1ed7495f3 100644 --- a/src/grib_accessor_class_g1_message_length.c +++ b/src/grib_accessor_class_g1_message_length.c @@ -224,9 +224,9 @@ static int pack_long(grib_accessor* a, const long* val,size_t *len) if((ret = pack_long_unsigned_helper(a,&tlen,len,/*check=*/0)) != GRIB_SUCCESS) return ret; /* - if((ret = super->pack_long(a,&tlen,len)) != GRIB_SUCCESS) - return ret; - */ + if((ret = super->pack_long(a,&tlen,len)) != GRIB_SUCCESS) + return ret; + */ { long total_length = -1, sec4_length = -1; diff --git a/src/grib_accessor_class_long.c b/src/grib_accessor_class_long.c index 6faefbd20..9c1684d85 100644 --- a/src/grib_accessor_class_long.c +++ b/src/grib_accessor_class_long.c @@ -129,8 +129,6 @@ static void init_class(grib_accessor_class* c) /* END_CLASS_IMP */ - - static int get_native_type(grib_accessor* a) { return GRIB_TYPE_LONG; @@ -216,8 +214,7 @@ static int unpack_double(grib_accessor* a, double* val,size_t *len) if (ret) return ret; rlen=count; - if(*len < rlen) - { + if(*len < rlen) { grib_context_log(a->context, GRIB_LOG_ERROR, " wrong size for %s it contains %d values ", a->name , rlen); *len = 0; return GRIB_ARRAY_TOO_SMALL; @@ -234,7 +231,6 @@ static int unpack_double(grib_accessor* a, double* val,size_t *len) values = (long*)grib_context_malloc(a->context,rlen*sizeof(long)); if(!values) return GRIB_INTERNAL_ERROR; - ret = grib_unpack_long(a,values,&rlen); if(ret != GRIB_SUCCESS){ grib_context_free(a->context,values); diff --git a/src/grib_accessor_class_variable.c b/src/grib_accessor_class_variable.c index 8118b4c3d..2cc343faf 100644 --- a/src/grib_accessor_class_variable.c +++ b/src/grib_accessor_class_variable.c @@ -160,28 +160,28 @@ static void init(grib_accessor* a, const long length , grib_arguments* args ) switch(self->type) { - case GRIB_TYPE_DOUBLE: - grib_expression_evaluate_double(hand,expression,&d); - pack_double(a,&d,&len); - break; + case GRIB_TYPE_DOUBLE: + grib_expression_evaluate_double(hand,expression,&d); + pack_double(a,&d,&len); + break; - case GRIB_TYPE_LONG: - grib_expression_evaluate_long(hand,expression,&l); - pack_long(a,&l,&len); - break; + case GRIB_TYPE_LONG: + grib_expression_evaluate_long(hand,expression,&l); + pack_long(a,&l,&len); + break; - default: { - char tmp[1024]; - len = sizeof(tmp); - p = grib_expression_evaluate_string(hand,expression,tmp,&len,&ret); - if (ret != GRIB_SUCCESS) { - grib_context_log(a->context,GRIB_LOG_ERROR,"unable to evaluate %s as string",a->name); - Assert(0); - } - len = strlen(p)+1; - pack_string(a,p,&len); - break; + default: { + char tmp[1024]; + len = sizeof(tmp); + p = grib_expression_evaluate_string(hand,expression,tmp,&len,&ret); + if (ret != GRIB_SUCCESS) { + grib_context_log(a->context,GRIB_LOG_ERROR,"unable to evaluate %s as string",a->name); + Assert(0); } + len = strlen(p)+1; + pack_string(a,p,&len); + break; + } } } } @@ -367,7 +367,7 @@ static long byte_count(grib_accessor* a) { return strlen(buf)+1; } } - */ +*/ static int compare(grib_accessor* a, grib_accessor* b) { diff --git a/src/grib_dumper_class_bufr_encode_python.c b/src/grib_dumper_class_bufr_encode_python.c index d2fd1501b..c9919c582 100644 --- a/src/grib_dumper_class_bufr_encode_python.c +++ b/src/grib_dumper_class_bufr_encode_python.c @@ -205,7 +205,7 @@ static void dump_values(grib_dumper* d,grib_accessor* a) depth-=2; /* Note: In Python to make a tuple with one element, you need the trailing comma */ - if (size > 4) fprintf(self->dumper.out,",) # %ld values\n", size); + if (size > 4) fprintf(self->dumper.out,",) # %lu values\n", (unsigned long)size); else fprintf(self->dumper.out,",)\n"); grib_context_free(c,values); @@ -287,7 +287,7 @@ static void dump_values_attribute(grib_dumper* d,grib_accessor* a, const char* p depth-=2; /* Note: In python to make a tuple with one element, you need the trailing comma */ - if (size > 4) fprintf(self->dumper.out,",) # %ld values\n", size); + if (size > 4) fprintf(self->dumper.out,",) # %lu values\n", (unsigned long)size); else fprintf(self->dumper.out,",)\n"); grib_context_free(c,values); @@ -374,7 +374,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) depth-=2; /* Note: In python to make a tuple with one element, you need the trailing comma */ - if (size > 4) fprintf(self->dumper.out,",) # %ld values\n", size); + if (size > 4) fprintf(self->dumper.out,",) # %lu values\n", (unsigned long)size); else fprintf(self->dumper.out,",)\n"); grib_context_free(a->context,values); @@ -462,7 +462,7 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr depth-=2; /* Note: In python to make a tuple with one element, you need the trailing comma */ - if (size > 4) fprintf(self->dumper.out,",) # %ld values\n", size); + if (size > 4) fprintf(self->dumper.out,",) # %lu values\n", (unsigned long)size); else fprintf(self->dumper.out,",)\n"); grib_context_free(a->context,values); @@ -697,7 +697,7 @@ static void _dump_long_array(grib_handle* h, FILE* f, const char* key, const cha } if (icount>cols) {fprintf(f," \n ");} /* Note: In python to make a tuple with one element, you need the trailing comma */ - if (size > 4) fprintf(f,"%ld ,) # %ld values\n",val[size-1], size); + if (size > 4) fprintf(f,"%ld ,) # %lu values\n",val[size-1], (unsigned long)size); else fprintf(f,"%ld ,)\n",val[size-1]); grib_context_free(h->context,val); diff --git a/src/grib_io.c b/src/grib_io.c index 0049d00f7..3802efa51 100644 --- a/src/grib_io.c +++ b/src/grib_io.c @@ -494,7 +494,9 @@ static int read_HDF5_offset(reader *r, int length, unsigned long* v, unsigned ch static int read_HDF5(reader *r) { - /* See: http://www.hdfgroup.org/HDF5/doc/H5.format.html#Superblock */ + /* + * See: http://www.hdfgroup.org/HDF5/doc/H5.format.html#Superblock + */ unsigned char tmp[49]; /* Should be enough */ unsigned char buf[4]; @@ -629,7 +631,9 @@ static int read_HDF5(reader *r) static int read_WRAP(reader *r) { - /* See: http://www.hdfgroup.org/HDF5/doc/H5.format.html#Superblock */ + /* + * See: http://www.hdfgroup.org/HDF5/doc/H5.format.html#Superblock + */ unsigned char tmp[36]; /* Should be enough */ unsigned char buf[8]; diff --git a/src/grib_iterator_class_lambert_conformal.c b/src/grib_iterator_class_lambert_conformal.c index d8e4ccbb9..2f01801c4 100644 --- a/src/grib_iterator_class_lambert_conformal.c +++ b/src/grib_iterator_class_lambert_conformal.c @@ -177,7 +177,9 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args) if((err = grib_get_long_internal(h, salternativeRowScanning,&alternativeRowScanning)) !=GRIB_SUCCESS) return err; - /* See Wolfram MathWorld: http://mathworld.wolfram.com/LambertConformalConicProjection.html */ + /* + * See Wolfram MathWorld: http://mathworld.wolfram.com/LambertConformalConicProjection.html + */ latFirstInRadians = latFirstInDegrees * DEG2RAD; lonFirstInRadians = lonFirstInDegrees * DEG2RAD; Latin1InRadians = Latin1InDegrees * DEG2RAD; diff --git a/src/grib_openjpeg_encoding.c b/src/grib_openjpeg_encoding.c index b92e7ce1f..40c4c7edc 100644 --- a/src/grib_openjpeg_encoding.c +++ b/src/grib_openjpeg_encoding.c @@ -211,7 +211,9 @@ cleanup: /* OpenJPEG 2.1 version of grib_openjpeg_encoding.c */ -/* opj_* Helper code from https://groups.google.com/forum/#!topic/openjpeg/8cebr0u7JgY */ +/* opj_* Helper code from + * https://groups.google.com/forum/#!topic/openjpeg/8cebr0u7JgY + */ /* These routines are added to use memory instead of a file for input and output */ /* struct need to treat memory as a stream */ typedef struct From 56b0ad4a73f5346658d08d6c4c523adea78c00e1 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 25 Sep 2019 14:43:19 +0100 Subject: [PATCH 14/49] Remove unused header file --- windows/msvc/grib_api_lib/grib_api_lib.vcproj | 4 ---- windows/msvc/grib_api_lib/grib_api_lib.vcxproj | 1 - windows/msvc/grib_api_lib/grib_api_lib.vcxproj.filters | 5 +---- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/windows/msvc/grib_api_lib/grib_api_lib.vcproj b/windows/msvc/grib_api_lib/grib_api_lib.vcproj index 8ab6dc98f..47c945500 100644 --- a/windows/msvc/grib_api_lib/grib_api_lib.vcproj +++ b/windows/msvc/grib_api_lib/grib_api_lib.vcproj @@ -1838,10 +1838,6 @@ RelativePath="..\..\..\src\grib_emoslib.h" > - - diff --git a/windows/msvc/grib_api_lib/grib_api_lib.vcxproj b/windows/msvc/grib_api_lib/grib_api_lib.vcxproj index 0c0d08513..a6a9f1edd 100755 --- a/windows/msvc/grib_api_lib/grib_api_lib.vcxproj +++ b/windows/msvc/grib_api_lib/grib_api_lib.vcxproj @@ -547,7 +547,6 @@ - diff --git a/windows/msvc/grib_api_lib/grib_api_lib.vcxproj.filters b/windows/msvc/grib_api_lib/grib_api_lib.vcxproj.filters index c1414e201..8e3828e34 100755 --- a/windows/msvc/grib_api_lib/grib_api_lib.vcxproj.filters +++ b/windows/msvc/grib_api_lib/grib_api_lib.vcxproj.filters @@ -1166,9 +1166,6 @@ Header Files - - Header Files - Header Files @@ -1206,4 +1203,4 @@ - \ No newline at end of file + From 184ff8258c87a1a358f75f8d11ec52ce4f1c6852 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 25 Sep 2019 17:51:28 +0100 Subject: [PATCH 15/49] ECC-991: Fix types --- src/bufr_util.c | 4 ++-- src/grib_api.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bufr_util.c b/src/bufr_util.c index fd2811e7f..f459b0b0e 100644 --- a/src/bufr_util.c +++ b/src/bufr_util.c @@ -472,8 +472,8 @@ static int bufr_decode_header(const void* message, off_t offset, size_t size, co { int err = GRIB_SUCCESS; - hdr->message_offset = offset; - hdr->message_size = size; + hdr->message_offset = (unsigned long)offset; + hdr->message_size = (unsigned long)size; err = bufr_extract_edition(message, &hdr->edition); diff --git a/src/grib_api.h b/src/grib_api.h index 3ee657707..0e204641c 100644 --- a/src/grib_api.h +++ b/src/grib_api.h @@ -1561,8 +1561,8 @@ int parse_keyval_string(const char *grib_tool, char *arg, int values_required, i grib_handle *grib_new_from_file(grib_context *c, FILE *f, int headers_only, int *error); typedef struct codes_bufr_header { - off_t message_offset; - size_t message_size; + unsigned long message_offset; + unsigned long message_size; /* Section 0 keys */ long edition; From eee9d9773a19efb9f0d49d5597c5b4659dbdfa8e Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 26 Sep 2019 18:29:30 +0100 Subject: [PATCH 16/49] ECC-991: Add the local lat/lon keys --- src/bufr_util.c | 96 ++++++++++++++++++++--------- src/grib_api.h | 17 ++++-- tests/bufr_extract_headers.c | 38 +++++++----- tests/bufr_extract_headers.sh | 111 ++++++++++++++++++++++++++++++++++ 4 files changed, 214 insertions(+), 48 deletions(-) diff --git a/src/bufr_util.c b/src/bufr_util.c index f459b0b0e..2be091e14 100644 --- a/src/bufr_util.c +++ b/src/bufr_util.c @@ -141,9 +141,6 @@ static int bufr_extract_edition(const void* message, long* edition) /* The ECMWF BUFR local use section */ static int bufr_decode_rdb_keys(const void* message, long offset_section2, codes_bufr_header* hdr) { - const long nbits_section2Length = 3*8; - long pos_section2Length = offset_section2*8; - long nbits_rdbType = 1*8; long pos_rdbType = (offset_section2+4)*8; long nbits_oldSubtype = 1*8; @@ -165,7 +162,6 @@ static int bufr_decode_rdb_keys(const void* message, long offset_section2, codes DebugAssert(hdr->localSectionPresent); - hdr->section2Length = grib_decode_unsigned_long(message, &pos_section2Length, nbits_section2Length); hdr->rdbType = (long)grib_decode_unsigned_long(message, &pos_rdbType, nbits_rdbType); hdr->oldSubtype = (long)grib_decode_unsigned_long(message, &pos_oldSubtype, nbits_oldSubtype); @@ -204,16 +200,14 @@ static int bufr_decode_rdb_keys(const void* message, long offset_section2, codes static int bufr_decode_extra_rdb_keys(const void* message, long offset_section2, codes_bufr_header* hdr) { size_t i = 0; - int isSatelliteType = 0; - int isSatellite = 0; + long start = 0; + const long offset_keyData = offset_section2 + 6; + const long offset_keyMore = offset_section2 + 19; /* 8 bytes long */ + const long offset_keySat = offset_section2 + 27; /* 9 bytes long */ - /*const long offset_keyData = offset_section2 + 6;*/ - const long offset_keyMore = offset_section2 + 19; - /*const long offset_keySat = offset_section2 + 27;*/ - - /*unsigned char* p = (unsigned char*)message + offset_keyData;*/ - char* q = (char*)message + offset_keyMore; + unsigned char* pKeyData = (unsigned char*)message + offset_keyData; + char* pKeyMore = (char*)message + offset_keyMore; DebugAssert(hdr->localSectionPresent); @@ -221,15 +215,57 @@ static int bufr_decode_extra_rdb_keys(const void* message, long offset_section2, isSatelliteType = 1; } if (isSatelliteType || hdr->numberOfSubsets > 1) { - isSatellite = 1; + hdr->isSatellite = 1; } else { - isSatellite = 0; + hdr->isSatellite = 0; } + + if (hdr->isSatellite) { + unsigned char* pKeyMoreLong = (unsigned char*)message + offset_keyMore; /* as an integer */ + unsigned char* pKeySat = (unsigned char*)message + offset_keySat; + long lValue = 0; + start = 40; + lValue = (long)grib_decode_unsigned_long(pKeyData, &start, 26); + hdr->localLongitude1 = (lValue - 18000000.0)/100000.0; + start = 72; + lValue = (long)grib_decode_unsigned_long(pKeyData, &start, 25); + hdr->localLatitude1 = (lValue - 9000000.0)/100000.0; + start = 0; + lValue = (long)grib_decode_unsigned_long(pKeyMoreLong, &start, 26); + hdr->localLongitude2 = (lValue -18000000.0)/100000.0; + start = 32; + lValue = (long)grib_decode_unsigned_long(pKeyMoreLong, &start, 25); + hdr->localLatitude2 = (lValue - 9000000)/100000.0; + + if (hdr->oldSubtype == 255 || hdr->numberOfSubsets > 255 || + (hdr->oldSubtype >= 121 && hdr->oldSubtype <= 130) || + hdr->oldSubtype==31) + { + start = 0; + hdr->localNumberOfObservations = (long)grib_decode_unsigned_long(pKeySat, &start, 16); + start = 16; + hdr->satelliteID = (long)grib_decode_unsigned_long(pKeySat, &start, 16); + } + else + { + start = 0; + hdr->localNumberOfObservations = (long)grib_decode_unsigned_long(pKeySat, &start, 8); + start = 8; + hdr->satelliteID = (long)grib_decode_unsigned_long(pKeySat, &start, 16); + } + } + else { + long lValue = 0; + start = 72; + lValue = (long)grib_decode_unsigned_long(pKeyData, &start, 25); + hdr->localLatitude = (lValue -9000000.0)/100000.0; + start = 40; + lValue = (long)grib_decode_unsigned_long(pKeyData, &start, 26); + hdr->localLongitude = (lValue - 18000000.0)/100000.0; - if (!isSatellite) { /* interpret keyMore as a string */ for (i=0; i<8; ++i) { - hdr->ident[i] = *q++; + hdr->ident[i] = *pKeyMore++; } hdr->ident[i] = '\0'; } @@ -260,6 +296,7 @@ static int bufr_decode_edition3(const void* message, codes_bufr_header* hdr) long nbits_updateSequenceNumber = 1*8; long pos_updateSequenceNumber = 14*8; + long section1Flags = 0; long nbits_section1Flags = 1*8; long pos_section1Flags = 15*8; @@ -290,6 +327,7 @@ static int bufr_decode_edition3(const void* message, codes_bufr_header* hdr) long nbits_typicalMinute = 1*8; long pos_typicalMinute = 24*8; + long section2Length = 0; long offset_section2 = 0; long offset_section3 = 0; long nbits_numberOfSubsets = 2*8; @@ -305,7 +343,7 @@ static int bufr_decode_edition3(const void* message, codes_bufr_header* hdr) hdr->bufrHeaderSubCentre = (long)grib_decode_unsigned_long(message, &pos_bufrHeaderSubCentre, nbits_bufrHeaderSubCentre); hdr->bufrHeaderCentre = (long)grib_decode_unsigned_long(message, &pos_bufrHeaderCentre, nbits_bufrHeaderCentre); hdr->updateSequenceNumber = (long)grib_decode_unsigned_long(message, &pos_updateSequenceNumber, nbits_updateSequenceNumber); - hdr->section1Flags = (long)grib_decode_unsigned_long(message, &pos_section1Flags, nbits_section1Flags); + section1Flags = (long)grib_decode_unsigned_long(message, &pos_section1Flags, nbits_section1Flags); hdr->dataCategory = (long)grib_decode_unsigned_long(message, &pos_dataCategory, nbits_dataCategory); hdr->dataSubCategory = (long)grib_decode_unsigned_long(message, &pos_dataSubCategory, nbits_dataSubCategory); hdr->masterTablesVersionNumber = (long)grib_decode_unsigned_long( @@ -318,21 +356,21 @@ static int bufr_decode_edition3(const void* message, codes_bufr_header* hdr) hdr->typicalMinute = (long)grib_decode_unsigned_long(message, &pos_typicalMinute, nbits_typicalMinute); offset_section2 = BUFR_SECTION0_LEN + section1Length; /*bytes*/ - hdr->section2Length = 0; - hdr->localSectionPresent = (hdr->section1Flags != 0); + section2Length = 0; + hdr->localSectionPresent = (section1Flags != 0); if (hdr->localSectionPresent) { long pos_section2Length; const long nbits_section2Length = 3*8; pos_section2Length = offset_section2*8; - hdr->section2Length = grib_decode_unsigned_long(message, &pos_section2Length, nbits_section2Length); + section2Length = grib_decode_unsigned_long(message, &pos_section2Length, nbits_section2Length); if (hdr->bufrHeaderCentre == 98) { err = bufr_decode_rdb_keys(message, offset_section2, hdr); } } - offset_section3 = BUFR_SECTION0_LEN + section1Length + hdr->section2Length; /*bytes*/ + offset_section3 = BUFR_SECTION0_LEN + section1Length + section2Length; /*bytes*/ nbits_numberOfSubsets = 2*8; pos_numberOfSubsets = (offset_section3+4)*8; hdr->numberOfSubsets = grib_decode_unsigned_long(message, &pos_numberOfSubsets, nbits_numberOfSubsets); @@ -342,7 +380,7 @@ static int bufr_decode_edition3(const void* message, codes_bufr_header* hdr) hdr->observedData = (section3Flags & 1<<7) ? 1 : 0; hdr->compressedData = (section3Flags & 1<<6) ? 1 : 0; - if (hdr->localSectionPresent && hdr->bufrHeaderCentre == 98 && hdr->section2Length == 52) { + if (hdr->localSectionPresent && hdr->bufrHeaderCentre == 98 && section2Length == 52) { err = bufr_decode_extra_rdb_keys(message, offset_section2, hdr); } @@ -372,6 +410,7 @@ static int bufr_decode_edition4(const void* message, codes_bufr_header* hdr) long nbits_updateSequenceNumber = 1*8; long pos_updateSequenceNumber = 16*8; + long section1Flags = 0; long nbits_section1Flags = 1*8; long pos_section1Flags = 17*8; @@ -408,6 +447,7 @@ static int bufr_decode_edition4(const void* message, codes_bufr_header* hdr) long nbits_typicalSecond = 1*8; long pos_typicalSecond = 29*8; + long section2Length = 0; long offset_section2 = 0; long offset_section3 = 0; long nbits_numberOfSubsets = 2*8; @@ -423,7 +463,7 @@ static int bufr_decode_edition4(const void* message, codes_bufr_header* hdr) hdr->bufrHeaderCentre = (long)grib_decode_unsigned_long(message, &pos_bufrHeaderCentre, nbits_bufrHeaderCentre); hdr->bufrHeaderSubCentre = (long)grib_decode_unsigned_long(message, &pos_bufrHeaderSubCentre, nbits_bufrHeaderSubCentre); hdr->updateSequenceNumber = (long)grib_decode_unsigned_long(message, &pos_updateSequenceNumber, nbits_updateSequenceNumber); - hdr->section1Flags = (long)grib_decode_unsigned_long(message, &pos_section1Flags, nbits_section1Flags); + section1Flags = (long)grib_decode_unsigned_long(message, &pos_section1Flags, nbits_section1Flags); hdr->dataCategory = (long)grib_decode_unsigned_long(message, &pos_dataCategory, nbits_dataCategory); hdr->internationalDataSubCategory = (long)grib_decode_unsigned_long(message, &pos_internationalDataSubCategory, nbits_internationalDataSubCategory); hdr->dataSubCategory = (long)grib_decode_unsigned_long(message, &pos_dataSubCategory, nbits_dataSubCategory); @@ -437,21 +477,21 @@ static int bufr_decode_edition4(const void* message, codes_bufr_header* hdr) hdr->typicalSecond = (long)grib_decode_unsigned_long(message, &pos_typicalSecond, nbits_typicalSecond); offset_section2 = BUFR_SECTION0_LEN + section1Length; /*bytes*/ - hdr->section2Length = 0; - hdr->localSectionPresent = (hdr->section1Flags != 0); + section2Length = 0; + hdr->localSectionPresent = (section1Flags != 0); if (hdr->localSectionPresent) { long pos_section2Length; const long nbits_section2Length = 3*8; pos_section2Length = offset_section2*8; - hdr->section2Length = grib_decode_unsigned_long(message, &pos_section2Length, nbits_section2Length); + section2Length = grib_decode_unsigned_long(message, &pos_section2Length, nbits_section2Length); if (hdr->bufrHeaderCentre == 98) { err = bufr_decode_rdb_keys(message, offset_section2, hdr); } } - offset_section3 = BUFR_SECTION0_LEN + section1Length + hdr->section2Length; /*bytes*/ + offset_section3 = BUFR_SECTION0_LEN + section1Length + section2Length; /*bytes*/ nbits_numberOfSubsets = 2*8; pos_numberOfSubsets = (offset_section3+4)*8; hdr->numberOfSubsets = grib_decode_unsigned_long(message, &pos_numberOfSubsets, nbits_numberOfSubsets); @@ -461,7 +501,7 @@ static int bufr_decode_edition4(const void* message, codes_bufr_header* hdr) hdr->observedData = (section3Flags & 1<<7) ? 1 : 0; hdr->compressedData = (section3Flags & 1<<6) ? 1 : 0; - if (hdr->localSectionPresent && hdr->bufrHeaderCentre == 98 && hdr->section2Length == 52) { + if (hdr->localSectionPresent && hdr->bufrHeaderCentre == 98 && section2Length == 52) { err = bufr_decode_extra_rdb_keys(message, offset_section2, hdr); } diff --git a/src/grib_api.h b/src/grib_api.h index 0e204641c..5a8dcfc9d 100644 --- a/src/grib_api.h +++ b/src/grib_api.h @@ -1573,7 +1573,6 @@ typedef struct codes_bufr_header { long bufrHeaderSubCentre; long bufrHeaderCentre; long updateSequenceNumber; - long section1Flags; long dataCategory; long dataSubCategory; long masterTablesVersionNumber; @@ -1592,7 +1591,6 @@ typedef struct codes_bufr_header { long localSectionPresent; /* ECMWF local section keys */ - unsigned long section2Length; long rdbType; long oldSubtype; char ident[9]; @@ -1613,9 +1611,18 @@ typedef struct codes_bufr_header { long rectimeMinute; long rectimeSecond; - long qualityControl; - long newSubtype; - long daLoop; + long isSatellite; + double localLongitude1; + double localLatitude1; + double localLongitude2; + double localLatitude2; + double localLatitude; + double localLongitude; + long localNumberOfObservations; + long satelliteID; + long qualityControl; + long newSubtype; + long daLoop; /* Section 3 keys */ unsigned long numberOfSubsets; diff --git a/tests/bufr_extract_headers.c b/tests/bufr_extract_headers.c index 3b96173a1..9a989b46b 100644 --- a/tests/bufr_extract_headers.c +++ b/tests/bufr_extract_headers.c @@ -13,16 +13,21 @@ static const char* not_found = "not_found"; -void print_rdb_key(int has_local, long value) +static void print_rdb_key(int local, long value) { - if (has_local) - printf("%ld ", value); - else - printf("%s ", not_found); + if (local) printf("%ld ", value); + else printf("%s ", not_found); } -void print_rdb_ident(int has_local, const char* value) + +static void print_rdb_key_double(int local, double value) { - if (value == NULL || strlen(value) == 0) + if (local) printf("%g ", value); + else printf("%s ", not_found); +} + +static void print_rdb_ident(int local, const char* value) +{ + if (!local || value == NULL || strlen(value) == 0) printf("%s ", not_found); else printf("%s ", value); @@ -47,8 +52,7 @@ int main(int argc, char* argv[]) for (i=0; i < num_messages; ++i) { codes_bufr_header bh = headers[i]; /* - * Mimic the behaviour of bufr_get -f -p keys - * for testing + * Mimic the behaviour of bufr_get -f -p keys for testing */ const int has_ecmwf_local = (bh.localSectionPresent == 1 && bh.bufrHeaderCentre == 98); @@ -60,7 +64,6 @@ int main(int argc, char* argv[]) if (strstr(keys, "bufrHeaderSubCentre")) printf("%ld ", bh.bufrHeaderSubCentre); if (strstr(keys, "bufrHeaderCentre")) printf("%ld ", bh.bufrHeaderCentre); if (strstr(keys, "updateSequenceNumber")) printf("%ld ", bh.updateSequenceNumber); - if (strstr(keys, "section1Flags")) printf("%ld ", bh.section1Flags); if (strstr(keys, "dataCategory")) printf("%ld ", bh.dataCategory); if (strstr(keys, "dataSubCategory")) printf("%ld ", bh.dataSubCategory); if (strstr(keys, "masterTablesVersionNumber")) printf("%ld ", bh.masterTablesVersionNumber); @@ -75,8 +78,6 @@ int main(int argc, char* argv[]) if (strstr(keys, "typicalSecond")) printf("%ld ", bh.typicalSecond); if (strstr(keys, "localSectionPresent")) printf("%ld ", bh.localSectionPresent); - if (strstr(keys, "section2Length")) printf("%ld ", bh.section2Length); - if (strstr(keys, "rdbType")) print_rdb_key(has_ecmwf_local, bh.rdbType); if (strstr(keys, "oldSubtype")) print_rdb_key(has_ecmwf_local, bh.oldSubtype); if (strstr(keys, "localYear")) print_rdb_key(has_ecmwf_local, bh.localYear); @@ -97,9 +98,16 @@ int main(int argc, char* argv[]) if (strstr(keys, "newSubtype")) print_rdb_key(has_ecmwf_local, bh.newSubtype); if (strstr(keys, "daLoop")) print_rdb_key(has_ecmwf_local, bh.daLoop); - if (strstr(keys, "numberOfSubsets")) printf("%ld ", bh.numberOfSubsets); - if (strstr(keys, "observedData")) printf("%ld ", bh.observedData); - if (strstr(keys, "compressedData")) printf("%ld ", bh.compressedData); + if (strstr(keys, "localLongitude1")) print_rdb_key_double(has_ecmwf_local, bh.localLongitude1); + if (strstr(keys, "localLatitude1")) print_rdb_key_double(has_ecmwf_local, bh.localLatitude1); + if (strstr(keys, "localLongitude2")) print_rdb_key_double(has_ecmwf_local, bh.localLongitude2); + if (strstr(keys, "localLatitude2")) print_rdb_key_double(has_ecmwf_local, bh.localLatitude2); + + if (strstr(keys, "localNumberOfObservations")) printf("%ld ", bh.localNumberOfObservations); + if (strstr(keys, "satelliteID")) printf("%ld ", bh.satelliteID); + if (strstr(keys, "numberOfSubsets")) printf("%ld ", bh.numberOfSubsets); + if (strstr(keys, "observedData")) printf("%ld ", bh.observedData); + if (strstr(keys, "compressedData")) printf("%ld ", bh.compressedData); if (strstr(keys, "ident")) print_rdb_ident(has_ecmwf_local, bh.ident); printf("\n"); diff --git a/tests/bufr_extract_headers.sh b/tests/bufr_extract_headers.sh index 39dffc1fb..b97a8c2d5 100755 --- a/tests/bufr_extract_headers.sh +++ b/tests/bufr_extract_headers.sh @@ -27,5 +27,116 @@ for bf in ${bufr_files}; do diff -w $temp1 $temp2 done +# BUFRs with localLatitude1, localLongitude1, localLongitude2 etc +bufr_files=" +aaen_55.bufr +aben_55.bufr +aeolus_wmo_26.bufr +ahws_139.bufr +airs_57.bufr +alws_139.bufr +amsa_55.bufr +amsb_55.bufr +amse_55.bufr +amsu_55.bufr +amv2_87.bufr +amv3_87.bufr +asbh_139.bufr +asbl_139.bufr +asca_139.bufr +asch_139.bufr +ascs_139.bufr +aseh_139.bufr +asel_139.bufr +ashs_139.bufr +atap_55.bufr +ateu_155.bufr +atms_201.bufr +atov_55.bufr +avhm_87.bufr +avhn_87.bufr +avhr_58.bufr +b003_56.bufr +b005_87.bufr +b005_89.bufr +b007_31.bufr +cmwi_87.bufr +cmwn_87.bufr +cori_156.bufr +crit_202.bufr +csrh_189.bufr +emsg_189.bufr +emsg_87.bufr +euwv_87.bufr +fy3a_154.bufr +fy3b_154.bufr +g2nd_208.bufr +g2to_206.bufr +go15_87.bufr +goee_87.bufr +goes_87.bufr +goga_89.bufr +gosat.bufr +grst_26.bufr +gsd1_208.bufr +gsd2_208.bufr +gsd3_208.bufr +gst4_26.bufr +hirb_55.bufr +hirs_55.bufr +ias1_240.bufr +iasi_241.bufr +ifco_208.bufr +ikco_217.bufr +imssnow.bufr +itrg_208.bufr +itwt_233.bufr +j2eo_216.bufr +j2nb_216.bufr +jaso_214.bufr +kond_209.bufr +maer_207.bufr +mhen_55.bufr +mhsa_55.bufr +mhsb_55.bufr +mhse_55.bufr +mloz_206.bufr +modi_87.bufr +modw_87.bufr +monw_87.bufr +nomi_206.bufr +nos1_208.bufr +nos2_208.bufr +nos3_208.bufr +nos4_208.bufr +nos5_208.bufr +nos6_208.bufr +nos7_208.bufr +nos8_208.bufr +pgps_110.bufr +rada_250.bufr +rado_250.bufr +s4kn_165.bufr +sb19_206.bufr +sbu8_206.bufr +smin_49.bufr +smis_49.bufr +smiu_49.bufr +smos_203.bufr +sn4k_165.bufr +ssbt_127.bufr +tmr7_129.bufr +tropical_cyclone.bufr +tros_31.bufr +" + +KEYS='localLongitude1,localLatitude1,localLongitude2,localLatitude2,localNumberOfObservations,satelliteID' +for bf in ${bufr_files}; do + input=${data_dir}/bufr/$bf + $EXEC ${test_dir}/bufr_extract_headers $KEYS $input > $temp1 + ${tools_dir}/bufr_get -f -p $KEYS $input > $temp2 + diff -w $temp1 $temp2 +done + rm -f $temp1 $temp2 From eaaa6dd57eb164e600028598498f828c36088835 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Fri, 27 Sep 2019 19:55:33 +0100 Subject: [PATCH 17/49] ECC-994: New parameter for S2S ocean 'Mean sea water potential temperature in the upper 300 m' --- definitions/grib2/cfVarName.def | 12 ++++++++++++ definitions/grib2/name.def | 12 ++++++++++++ definitions/grib2/paramId.def | 12 ++++++++++++ definitions/grib2/shortName.def | 12 ++++++++++++ definitions/grib2/units.def | 12 ++++++++++++ 5 files changed, 60 insertions(+) diff --git a/definitions/grib2/cfVarName.def b/definitions/grib2/cfVarName.def index 4636f33cc..28862b57b 100644 --- a/definitions/grib2/cfVarName.def +++ b/definitions/grib2/cfVarName.def @@ -417,6 +417,18 @@ } #Mean sea water potential temperature in the upper 300 m 'mswpt300m' = { + discipline = 10 ; + parameterCategory = 4 ; + parameterNumber = 18 ; + typeOfFirstFixedSurface = 160 ; + typeOfSecondFixedSurface = 160 ; + scaledValueOfFirstFixedSurface = 0 ; + scaleFactorOfFirstFixedSurface = 0 ; + scaledValueOfSecondFixedSurface = 300 ; + scaleFactorOfSecondFixedSurface = 0 ; + } +#Mean sea water temperature in the upper 300 m +'mswt300m' = { discipline = 10 ; parameterCategory = 4 ; parameterNumber = 15 ; diff --git a/definitions/grib2/name.def b/definitions/grib2/name.def index f95ca3294..88a7b1460 100644 --- a/definitions/grib2/name.def +++ b/definitions/grib2/name.def @@ -417,6 +417,18 @@ } #Mean sea water potential temperature in the upper 300 m 'Mean sea water potential temperature in the upper 300 m' = { + discipline = 10 ; + parameterCategory = 4 ; + parameterNumber = 18 ; + typeOfFirstFixedSurface = 160 ; + typeOfSecondFixedSurface = 160 ; + scaledValueOfFirstFixedSurface = 0 ; + scaleFactorOfFirstFixedSurface = 0 ; + scaledValueOfSecondFixedSurface = 300 ; + scaleFactorOfSecondFixedSurface = 0 ; + } +#Mean sea water temperature in the upper 300 m +'Mean sea water temperature in the upper 300 m' = { discipline = 10 ; parameterCategory = 4 ; parameterNumber = 15 ; diff --git a/definitions/grib2/paramId.def b/definitions/grib2/paramId.def index 846e3afce..8e88c3260 100644 --- a/definitions/grib2/paramId.def +++ b/definitions/grib2/paramId.def @@ -416,6 +416,18 @@ scaleFactorOfLowerLimit = 0 ; } #Mean sea water potential temperature in the upper 300 m +'151126' = { + discipline = 10 ; + parameterCategory = 4 ; + parameterNumber = 18 ; + typeOfFirstFixedSurface = 160 ; + typeOfSecondFixedSurface = 160 ; + scaledValueOfFirstFixedSurface = 0 ; + scaleFactorOfFirstFixedSurface = 0 ; + scaledValueOfSecondFixedSurface = 300 ; + scaleFactorOfSecondFixedSurface = 0 ; + } +#Mean sea water temperature in the upper 300 m '151127' = { discipline = 10 ; parameterCategory = 4 ; diff --git a/definitions/grib2/shortName.def b/definitions/grib2/shortName.def index 7cce6acd1..05df59bbe 100644 --- a/definitions/grib2/shortName.def +++ b/definitions/grib2/shortName.def @@ -417,6 +417,18 @@ } #Mean sea water potential temperature in the upper 300 m 'mswpt300m' = { + discipline = 10 ; + parameterCategory = 4 ; + parameterNumber = 18 ; + typeOfFirstFixedSurface = 160 ; + typeOfSecondFixedSurface = 160 ; + scaledValueOfFirstFixedSurface = 0 ; + scaleFactorOfFirstFixedSurface = 0 ; + scaledValueOfSecondFixedSurface = 300 ; + scaleFactorOfSecondFixedSurface = 0 ; + } +#Mean sea water temperature in the upper 300 m +'mswt300m' = { discipline = 10 ; parameterCategory = 4 ; parameterNumber = 15 ; diff --git a/definitions/grib2/units.def b/definitions/grib2/units.def index e956f5b19..247ff527f 100644 --- a/definitions/grib2/units.def +++ b/definitions/grib2/units.def @@ -416,6 +416,18 @@ typeOfStatisticalProcessing = 10 ; } #Mean sea water potential temperature in the upper 300 m +'K' = { + discipline = 10 ; + parameterCategory = 4 ; + parameterNumber = 18 ; + typeOfFirstFixedSurface = 160 ; + typeOfSecondFixedSurface = 160 ; + scaledValueOfFirstFixedSurface = 0 ; + scaleFactorOfFirstFixedSurface = 0 ; + scaledValueOfSecondFixedSurface = 300 ; + scaleFactorOfSecondFixedSurface = 0 ; + } +#Mean sea water temperature in the upper 300 m 'K' = { discipline = 10 ; parameterCategory = 4 ; From 7136265bfcc21ef0b130019611ffb8a2bf652fc0 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Fri, 27 Sep 2019 19:57:36 +0100 Subject: [PATCH 18/49] ECC-994: New parameter for S2S ocean 'Mean sea water potential temperature in the upper 300 m' --- definitions/grib2/cfVarName.def | 12 ++++++++++++ definitions/grib2/name.def | 12 ++++++++++++ definitions/grib2/paramId.def | 12 ++++++++++++ definitions/grib2/shortName.def | 12 ++++++++++++ definitions/grib2/units.def | 12 ++++++++++++ 5 files changed, 60 insertions(+) diff --git a/definitions/grib2/cfVarName.def b/definitions/grib2/cfVarName.def index 4636f33cc..28862b57b 100644 --- a/definitions/grib2/cfVarName.def +++ b/definitions/grib2/cfVarName.def @@ -417,6 +417,18 @@ } #Mean sea water potential temperature in the upper 300 m 'mswpt300m' = { + discipline = 10 ; + parameterCategory = 4 ; + parameterNumber = 18 ; + typeOfFirstFixedSurface = 160 ; + typeOfSecondFixedSurface = 160 ; + scaledValueOfFirstFixedSurface = 0 ; + scaleFactorOfFirstFixedSurface = 0 ; + scaledValueOfSecondFixedSurface = 300 ; + scaleFactorOfSecondFixedSurface = 0 ; + } +#Mean sea water temperature in the upper 300 m +'mswt300m' = { discipline = 10 ; parameterCategory = 4 ; parameterNumber = 15 ; diff --git a/definitions/grib2/name.def b/definitions/grib2/name.def index f95ca3294..88a7b1460 100644 --- a/definitions/grib2/name.def +++ b/definitions/grib2/name.def @@ -417,6 +417,18 @@ } #Mean sea water potential temperature in the upper 300 m 'Mean sea water potential temperature in the upper 300 m' = { + discipline = 10 ; + parameterCategory = 4 ; + parameterNumber = 18 ; + typeOfFirstFixedSurface = 160 ; + typeOfSecondFixedSurface = 160 ; + scaledValueOfFirstFixedSurface = 0 ; + scaleFactorOfFirstFixedSurface = 0 ; + scaledValueOfSecondFixedSurface = 300 ; + scaleFactorOfSecondFixedSurface = 0 ; + } +#Mean sea water temperature in the upper 300 m +'Mean sea water temperature in the upper 300 m' = { discipline = 10 ; parameterCategory = 4 ; parameterNumber = 15 ; diff --git a/definitions/grib2/paramId.def b/definitions/grib2/paramId.def index 846e3afce..8e88c3260 100644 --- a/definitions/grib2/paramId.def +++ b/definitions/grib2/paramId.def @@ -416,6 +416,18 @@ scaleFactorOfLowerLimit = 0 ; } #Mean sea water potential temperature in the upper 300 m +'151126' = { + discipline = 10 ; + parameterCategory = 4 ; + parameterNumber = 18 ; + typeOfFirstFixedSurface = 160 ; + typeOfSecondFixedSurface = 160 ; + scaledValueOfFirstFixedSurface = 0 ; + scaleFactorOfFirstFixedSurface = 0 ; + scaledValueOfSecondFixedSurface = 300 ; + scaleFactorOfSecondFixedSurface = 0 ; + } +#Mean sea water temperature in the upper 300 m '151127' = { discipline = 10 ; parameterCategory = 4 ; diff --git a/definitions/grib2/shortName.def b/definitions/grib2/shortName.def index 7cce6acd1..05df59bbe 100644 --- a/definitions/grib2/shortName.def +++ b/definitions/grib2/shortName.def @@ -417,6 +417,18 @@ } #Mean sea water potential temperature in the upper 300 m 'mswpt300m' = { + discipline = 10 ; + parameterCategory = 4 ; + parameterNumber = 18 ; + typeOfFirstFixedSurface = 160 ; + typeOfSecondFixedSurface = 160 ; + scaledValueOfFirstFixedSurface = 0 ; + scaleFactorOfFirstFixedSurface = 0 ; + scaledValueOfSecondFixedSurface = 300 ; + scaleFactorOfSecondFixedSurface = 0 ; + } +#Mean sea water temperature in the upper 300 m +'mswt300m' = { discipline = 10 ; parameterCategory = 4 ; parameterNumber = 15 ; diff --git a/definitions/grib2/units.def b/definitions/grib2/units.def index e956f5b19..247ff527f 100644 --- a/definitions/grib2/units.def +++ b/definitions/grib2/units.def @@ -416,6 +416,18 @@ typeOfStatisticalProcessing = 10 ; } #Mean sea water potential temperature in the upper 300 m +'K' = { + discipline = 10 ; + parameterCategory = 4 ; + parameterNumber = 18 ; + typeOfFirstFixedSurface = 160 ; + typeOfSecondFixedSurface = 160 ; + scaledValueOfFirstFixedSurface = 0 ; + scaleFactorOfFirstFixedSurface = 0 ; + scaledValueOfSecondFixedSurface = 300 ; + scaleFactorOfSecondFixedSurface = 0 ; + } +#Mean sea water temperature in the upper 300 m 'K' = { discipline = 10 ; parameterCategory = 4 ; From 780c1f81740dc5d51f10fcd3abfb48f1f9e303c7 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Sun, 29 Sep 2019 18:55:10 +0100 Subject: [PATCH 19/49] ECC-972: Add WMO GRIB2 definitions to CERRA/CARRA parameters --- definitions/grib2/cfName.def | 16 ++++++++++++ definitions/grib2/cfVarName.def | 16 ++++++++++++ .../grib2/localConcepts/ecmf/cfName.def | 12 --------- .../grib2/localConcepts/ecmf/cfVarName.def | 12 --------- definitions/grib2/localConcepts/ecmf/name.def | 12 --------- .../grib2/localConcepts/ecmf/paramId.def | 12 --------- .../grib2/localConcepts/ecmf/shortName.def | 12 --------- .../grib2/localConcepts/ecmf/units.def | 12 --------- definitions/grib2/name.def | 16 ++++++++++++ definitions/grib2/paramId.def | 16 ++++++++++++ definitions/grib2/shortName.def | 16 ++++++++++++ definitions/grib2/units.def | 16 ++++++++++++ src/grib_accessor_class_concept.c | 25 +++++++++++++++++++ 13 files changed, 121 insertions(+), 72 deletions(-) diff --git a/definitions/grib2/cfName.def b/definitions/grib2/cfName.def index 4f7317055..ded66ae64 100644 --- a/definitions/grib2/cfName.def +++ b/definitions/grib2/cfName.def @@ -196,3 +196,19 @@ scaledValueOfFirstFixedSurface = 0 ; scaleFactorOfFirstFixedSurface = 0 ; } +#Surface net solar radiation, clear sky +'surface_net_downward_shortwave_flux_assuming_clear_sky' = { + discipline = 0 ; + parameterCategory = 4 ; + parameterNumber = 11 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; +} +#Surface net thermal radiation, clear sky +'surface_net_downward_longwave_flux_assuming_clear_sky' = { + discipline = 0 ; + parameterCategory = 5 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; +} diff --git a/definitions/grib2/cfVarName.def b/definitions/grib2/cfVarName.def index 28862b57b..be228be35 100644 --- a/definitions/grib2/cfVarName.def +++ b/definitions/grib2/cfVarName.def @@ -261,6 +261,22 @@ parameterCategory = 14 ; parameterNumber = 1 ; } +#Surface net solar radiation, clear sky +'ssrc' = { + discipline = 0 ; + parameterCategory = 4 ; + parameterNumber = 11 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Surface net thermal radiation, clear sky +'strc' = { + discipline = 0 ; + parameterCategory = 5 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } #Specific cloud liquid water content 'clwc' = { discipline = 0 ; diff --git a/definitions/grib2/localConcepts/ecmf/cfName.def b/definitions/grib2/localConcepts/ecmf/cfName.def index cbd606a56..9eb2f6dd1 100644 --- a/definitions/grib2/localConcepts/ecmf/cfName.def +++ b/definitions/grib2/localConcepts/ecmf/cfName.def @@ -127,18 +127,6 @@ parameterCategory = 128 ; parameterNumber = 185 ; } -#Surface net solar radiation, clear sky -'surface_net_downward_shortwave_flux_assuming_clear_sky' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 210 ; - } -#Surface net thermal radiation, clear sky -'surface_net_downward_longwave_flux_assuming_clear_sky' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 211 ; - } #Temperature of snow layer 'temperature_in_surface_snow' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/ecmf/cfVarName.def b/definitions/grib2/localConcepts/ecmf/cfVarName.def index 9cbe41085..0863d8551 100644 --- a/definitions/grib2/localConcepts/ecmf/cfVarName.def +++ b/definitions/grib2/localConcepts/ecmf/cfVarName.def @@ -968,18 +968,6 @@ parameterCategory = 128 ; parameterNumber = 209 ; } -#Surface net solar radiation, clear sky -'ssrc' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 210 ; - } -#Surface net thermal radiation, clear sky -'strc' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 211 ; - } #TOA incident solar radiation 'tisr' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/ecmf/name.def b/definitions/grib2/localConcepts/ecmf/name.def index d75472401..fff8241a0 100644 --- a/definitions/grib2/localConcepts/ecmf/name.def +++ b/definitions/grib2/localConcepts/ecmf/name.def @@ -968,18 +968,6 @@ parameterCategory = 128 ; parameterNumber = 209 ; } -#Surface net solar radiation, clear sky -'Surface net solar radiation, clear sky' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 210 ; - } -#Surface net thermal radiation, clear sky -'Surface net thermal radiation, clear sky' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 211 ; - } #TOA incident solar radiation 'TOA incident solar radiation' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/ecmf/paramId.def b/definitions/grib2/localConcepts/ecmf/paramId.def index 043e71747..67f42d74b 100644 --- a/definitions/grib2/localConcepts/ecmf/paramId.def +++ b/definitions/grib2/localConcepts/ecmf/paramId.def @@ -968,18 +968,6 @@ parameterCategory = 128 ; parameterNumber = 209 ; } -#Surface net solar radiation, clear sky -'210' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 210 ; - } -#Surface net thermal radiation, clear sky -'211' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 211 ; - } #TOA incident solar radiation '212' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/ecmf/shortName.def b/definitions/grib2/localConcepts/ecmf/shortName.def index 49501d40d..9e2b01f58 100644 --- a/definitions/grib2/localConcepts/ecmf/shortName.def +++ b/definitions/grib2/localConcepts/ecmf/shortName.def @@ -968,18 +968,6 @@ parameterCategory = 128 ; parameterNumber = 209 ; } -#Surface net solar radiation, clear sky -'ssrc' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 210 ; - } -#Surface net thermal radiation, clear sky -'strc' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 211 ; - } #TOA incident solar radiation 'tisr' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/ecmf/units.def b/definitions/grib2/localConcepts/ecmf/units.def index 3ffe24ed1..69070ecd0 100644 --- a/definitions/grib2/localConcepts/ecmf/units.def +++ b/definitions/grib2/localConcepts/ecmf/units.def @@ -968,18 +968,6 @@ parameterCategory = 128 ; parameterNumber = 209 ; } -#Surface net solar radiation, clear sky -'J m**-2' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 210 ; - } -#Surface net thermal radiation, clear sky -'J m**-2' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 211 ; - } #TOA incident solar radiation 'J m**-2' = { discipline = 192 ; diff --git a/definitions/grib2/name.def b/definitions/grib2/name.def index 88a7b1460..3f9337236 100644 --- a/definitions/grib2/name.def +++ b/definitions/grib2/name.def @@ -261,6 +261,22 @@ parameterCategory = 14 ; parameterNumber = 1 ; } +#Surface net solar radiation, clear sky +'Surface net solar radiation, clear sky' = { + discipline = 0 ; + parameterCategory = 4 ; + parameterNumber = 11 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Surface net thermal radiation, clear sky +'Surface net thermal radiation, clear sky' = { + discipline = 0 ; + parameterCategory = 5 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } #Specific cloud liquid water content 'Specific cloud liquid water content' = { discipline = 0 ; diff --git a/definitions/grib2/paramId.def b/definitions/grib2/paramId.def index 8e88c3260..f1ea4a752 100644 --- a/definitions/grib2/paramId.def +++ b/definitions/grib2/paramId.def @@ -261,6 +261,22 @@ parameterCategory = 14 ; parameterNumber = 1 ; } +#Surface net solar radiation, clear sky +'210' = { + discipline = 0 ; + parameterCategory = 4 ; + parameterNumber = 11 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Surface net thermal radiation, clear sky +'211' = { + discipline = 0 ; + parameterCategory = 5 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } #Specific cloud liquid water content '246' = { discipline = 0 ; diff --git a/definitions/grib2/shortName.def b/definitions/grib2/shortName.def index 05df59bbe..1d4c25b78 100644 --- a/definitions/grib2/shortName.def +++ b/definitions/grib2/shortName.def @@ -261,6 +261,22 @@ parameterCategory = 14 ; parameterNumber = 1 ; } +#Surface net solar radiation, clear sky +'ssrc' = { + discipline = 0 ; + parameterCategory = 4 ; + parameterNumber = 11 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Surface net thermal radiation, clear sky +'strc' = { + discipline = 0 ; + parameterCategory = 5 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } #Specific cloud liquid water content 'clwc' = { discipline = 0 ; diff --git a/definitions/grib2/units.def b/definitions/grib2/units.def index 247ff527f..24ab62918 100644 --- a/definitions/grib2/units.def +++ b/definitions/grib2/units.def @@ -261,6 +261,22 @@ parameterCategory = 14 ; parameterNumber = 1 ; } +#Surface net solar radiation, clear sky +'J m**-2' = { + discipline = 0 ; + parameterCategory = 4 ; + parameterNumber = 11 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Surface net thermal radiation, clear sky +'J m**-2' = { + discipline = 0 ; + parameterCategory = 5 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } #Specific cloud liquid water content 'kg kg**-1' = { discipline = 0 ; diff --git a/src/grib_accessor_class_concept.c b/src/grib_accessor_class_concept.c index 9afbed3d4..044871cf7 100644 --- a/src/grib_accessor_class_concept.c +++ b/src/grib_accessor_class_concept.c @@ -529,6 +529,26 @@ static int is_local_ecmwf_grib2_param_key(grib_accessor* a, long edition, long c return 0; } +static char* get_legacy_param_info(const char* key_name, long paramId) +{ + if (paramId == 210) { + if (strcmp(key_name, "paramId")==0) return "210"; + if (strcmp(key_name, "shortName")==0) return "ssrc"; + if (strcmp(key_name, "units")==0) return "J m**-2"; + if (strcmp(key_name, "name")==0) return "Surface net solar radiation, clear sky"; + if (strcmp(key_name, "cfVarName")==0) return "ssrc"; + if (strcmp(key_name, "cfName")==0) return "surface_net_downward_shortwave_flux_assuming_clear_sky"; + } else if (paramId == 211) { + if (strcmp(key_name, "paramId")==0) return "211"; + if (strcmp(key_name, "shortName")==0) return "strc"; + if (strcmp(key_name, "units")==0) return "J m**-2"; + if (strcmp(key_name, "name")==0) return "Surface net thermal radiation, clear sky"; + if (strcmp(key_name, "cfVarName")==0) return "strc"; + if (strcmp(key_name, "cfName")==0) return "surface_net_downward_longwave_flux_assuming_clear_sky"; + } + return NULL; +} + /* Try to get the name, shortName, units etc for a GRIB2 message with * local ECMWF coding i.e. discipline=192 etc */ @@ -544,11 +564,16 @@ static const char* get_ECMWF_local_parameter(grib_accessor* a, grib_handle* h) err=grib_get_long(h,"edition",&edition); if (err) return NULL; if (is_local_ecmwf_grib2_param_key(a,edition,centre)) { + char* pLocalParam = NULL; /* Must be one of: 'name', 'shortName', 'units', 'cfName' etc */ grib_accessor* a2 = NULL; long pid_guess = guess_paramId(h); if (pid_guess == -1) return NULL; + /* TODO: Need to revisit */ + pLocalParam = get_legacy_param_info(key_name, pid_guess); + if (pLocalParam) return pLocalParam; + /* Change the paramId so we can get the other string key*/ err = grib_set_long(h, "paramId", pid_guess); if (err) return NULL; From f3cee3ef1698b349a25e282f8a032289938d3ec0 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Sun, 29 Sep 2019 19:04:25 +0100 Subject: [PATCH 20/49] ECC-972: Add WMO GRIB2 definitions to CERRA/CARRA parameters --- definitions/grib2/cfName.def | 16 ++++++++++++ definitions/grib2/cfVarName.def | 16 ++++++++++++ .../grib2/localConcepts/ecmf/cfName.def | 12 --------- .../grib2/localConcepts/ecmf/cfVarName.def | 12 --------- definitions/grib2/localConcepts/ecmf/name.def | 12 --------- .../grib2/localConcepts/ecmf/paramId.def | 12 --------- .../grib2/localConcepts/ecmf/shortName.def | 12 --------- .../grib2/localConcepts/ecmf/units.def | 12 --------- definitions/grib2/name.def | 16 ++++++++++++ definitions/grib2/paramId.def | 16 ++++++++++++ definitions/grib2/shortName.def | 16 ++++++++++++ definitions/grib2/units.def | 16 ++++++++++++ src/grib_accessor_class_concept.c | 25 +++++++++++++++++++ 13 files changed, 121 insertions(+), 72 deletions(-) diff --git a/definitions/grib2/cfName.def b/definitions/grib2/cfName.def index 4f7317055..ded66ae64 100644 --- a/definitions/grib2/cfName.def +++ b/definitions/grib2/cfName.def @@ -196,3 +196,19 @@ scaledValueOfFirstFixedSurface = 0 ; scaleFactorOfFirstFixedSurface = 0 ; } +#Surface net solar radiation, clear sky +'surface_net_downward_shortwave_flux_assuming_clear_sky' = { + discipline = 0 ; + parameterCategory = 4 ; + parameterNumber = 11 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; +} +#Surface net thermal radiation, clear sky +'surface_net_downward_longwave_flux_assuming_clear_sky' = { + discipline = 0 ; + parameterCategory = 5 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; +} diff --git a/definitions/grib2/cfVarName.def b/definitions/grib2/cfVarName.def index 28862b57b..be228be35 100644 --- a/definitions/grib2/cfVarName.def +++ b/definitions/grib2/cfVarName.def @@ -261,6 +261,22 @@ parameterCategory = 14 ; parameterNumber = 1 ; } +#Surface net solar radiation, clear sky +'ssrc' = { + discipline = 0 ; + parameterCategory = 4 ; + parameterNumber = 11 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Surface net thermal radiation, clear sky +'strc' = { + discipline = 0 ; + parameterCategory = 5 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } #Specific cloud liquid water content 'clwc' = { discipline = 0 ; diff --git a/definitions/grib2/localConcepts/ecmf/cfName.def b/definitions/grib2/localConcepts/ecmf/cfName.def index cbd606a56..9eb2f6dd1 100644 --- a/definitions/grib2/localConcepts/ecmf/cfName.def +++ b/definitions/grib2/localConcepts/ecmf/cfName.def @@ -127,18 +127,6 @@ parameterCategory = 128 ; parameterNumber = 185 ; } -#Surface net solar radiation, clear sky -'surface_net_downward_shortwave_flux_assuming_clear_sky' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 210 ; - } -#Surface net thermal radiation, clear sky -'surface_net_downward_longwave_flux_assuming_clear_sky' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 211 ; - } #Temperature of snow layer 'temperature_in_surface_snow' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/ecmf/cfVarName.def b/definitions/grib2/localConcepts/ecmf/cfVarName.def index 9cbe41085..0863d8551 100644 --- a/definitions/grib2/localConcepts/ecmf/cfVarName.def +++ b/definitions/grib2/localConcepts/ecmf/cfVarName.def @@ -968,18 +968,6 @@ parameterCategory = 128 ; parameterNumber = 209 ; } -#Surface net solar radiation, clear sky -'ssrc' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 210 ; - } -#Surface net thermal radiation, clear sky -'strc' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 211 ; - } #TOA incident solar radiation 'tisr' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/ecmf/name.def b/definitions/grib2/localConcepts/ecmf/name.def index d75472401..fff8241a0 100644 --- a/definitions/grib2/localConcepts/ecmf/name.def +++ b/definitions/grib2/localConcepts/ecmf/name.def @@ -968,18 +968,6 @@ parameterCategory = 128 ; parameterNumber = 209 ; } -#Surface net solar radiation, clear sky -'Surface net solar radiation, clear sky' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 210 ; - } -#Surface net thermal radiation, clear sky -'Surface net thermal radiation, clear sky' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 211 ; - } #TOA incident solar radiation 'TOA incident solar radiation' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/ecmf/paramId.def b/definitions/grib2/localConcepts/ecmf/paramId.def index 043e71747..67f42d74b 100644 --- a/definitions/grib2/localConcepts/ecmf/paramId.def +++ b/definitions/grib2/localConcepts/ecmf/paramId.def @@ -968,18 +968,6 @@ parameterCategory = 128 ; parameterNumber = 209 ; } -#Surface net solar radiation, clear sky -'210' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 210 ; - } -#Surface net thermal radiation, clear sky -'211' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 211 ; - } #TOA incident solar radiation '212' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/ecmf/shortName.def b/definitions/grib2/localConcepts/ecmf/shortName.def index 49501d40d..9e2b01f58 100644 --- a/definitions/grib2/localConcepts/ecmf/shortName.def +++ b/definitions/grib2/localConcepts/ecmf/shortName.def @@ -968,18 +968,6 @@ parameterCategory = 128 ; parameterNumber = 209 ; } -#Surface net solar radiation, clear sky -'ssrc' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 210 ; - } -#Surface net thermal radiation, clear sky -'strc' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 211 ; - } #TOA incident solar radiation 'tisr' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/ecmf/units.def b/definitions/grib2/localConcepts/ecmf/units.def index 3ffe24ed1..69070ecd0 100644 --- a/definitions/grib2/localConcepts/ecmf/units.def +++ b/definitions/grib2/localConcepts/ecmf/units.def @@ -968,18 +968,6 @@ parameterCategory = 128 ; parameterNumber = 209 ; } -#Surface net solar radiation, clear sky -'J m**-2' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 210 ; - } -#Surface net thermal radiation, clear sky -'J m**-2' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 211 ; - } #TOA incident solar radiation 'J m**-2' = { discipline = 192 ; diff --git a/definitions/grib2/name.def b/definitions/grib2/name.def index 88a7b1460..3f9337236 100644 --- a/definitions/grib2/name.def +++ b/definitions/grib2/name.def @@ -261,6 +261,22 @@ parameterCategory = 14 ; parameterNumber = 1 ; } +#Surface net solar radiation, clear sky +'Surface net solar radiation, clear sky' = { + discipline = 0 ; + parameterCategory = 4 ; + parameterNumber = 11 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Surface net thermal radiation, clear sky +'Surface net thermal radiation, clear sky' = { + discipline = 0 ; + parameterCategory = 5 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } #Specific cloud liquid water content 'Specific cloud liquid water content' = { discipline = 0 ; diff --git a/definitions/grib2/paramId.def b/definitions/grib2/paramId.def index 8e88c3260..f1ea4a752 100644 --- a/definitions/grib2/paramId.def +++ b/definitions/grib2/paramId.def @@ -261,6 +261,22 @@ parameterCategory = 14 ; parameterNumber = 1 ; } +#Surface net solar radiation, clear sky +'210' = { + discipline = 0 ; + parameterCategory = 4 ; + parameterNumber = 11 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Surface net thermal radiation, clear sky +'211' = { + discipline = 0 ; + parameterCategory = 5 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } #Specific cloud liquid water content '246' = { discipline = 0 ; diff --git a/definitions/grib2/shortName.def b/definitions/grib2/shortName.def index 05df59bbe..1d4c25b78 100644 --- a/definitions/grib2/shortName.def +++ b/definitions/grib2/shortName.def @@ -261,6 +261,22 @@ parameterCategory = 14 ; parameterNumber = 1 ; } +#Surface net solar radiation, clear sky +'ssrc' = { + discipline = 0 ; + parameterCategory = 4 ; + parameterNumber = 11 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Surface net thermal radiation, clear sky +'strc' = { + discipline = 0 ; + parameterCategory = 5 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } #Specific cloud liquid water content 'clwc' = { discipline = 0 ; diff --git a/definitions/grib2/units.def b/definitions/grib2/units.def index 247ff527f..24ab62918 100644 --- a/definitions/grib2/units.def +++ b/definitions/grib2/units.def @@ -261,6 +261,22 @@ parameterCategory = 14 ; parameterNumber = 1 ; } +#Surface net solar radiation, clear sky +'J m**-2' = { + discipline = 0 ; + parameterCategory = 4 ; + parameterNumber = 11 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Surface net thermal radiation, clear sky +'J m**-2' = { + discipline = 0 ; + parameterCategory = 5 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } #Specific cloud liquid water content 'kg kg**-1' = { discipline = 0 ; diff --git a/src/grib_accessor_class_concept.c b/src/grib_accessor_class_concept.c index 9afbed3d4..044871cf7 100644 --- a/src/grib_accessor_class_concept.c +++ b/src/grib_accessor_class_concept.c @@ -529,6 +529,26 @@ static int is_local_ecmwf_grib2_param_key(grib_accessor* a, long edition, long c return 0; } +static char* get_legacy_param_info(const char* key_name, long paramId) +{ + if (paramId == 210) { + if (strcmp(key_name, "paramId")==0) return "210"; + if (strcmp(key_name, "shortName")==0) return "ssrc"; + if (strcmp(key_name, "units")==0) return "J m**-2"; + if (strcmp(key_name, "name")==0) return "Surface net solar radiation, clear sky"; + if (strcmp(key_name, "cfVarName")==0) return "ssrc"; + if (strcmp(key_name, "cfName")==0) return "surface_net_downward_shortwave_flux_assuming_clear_sky"; + } else if (paramId == 211) { + if (strcmp(key_name, "paramId")==0) return "211"; + if (strcmp(key_name, "shortName")==0) return "strc"; + if (strcmp(key_name, "units")==0) return "J m**-2"; + if (strcmp(key_name, "name")==0) return "Surface net thermal radiation, clear sky"; + if (strcmp(key_name, "cfVarName")==0) return "strc"; + if (strcmp(key_name, "cfName")==0) return "surface_net_downward_longwave_flux_assuming_clear_sky"; + } + return NULL; +} + /* Try to get the name, shortName, units etc for a GRIB2 message with * local ECMWF coding i.e. discipline=192 etc */ @@ -544,11 +564,16 @@ static const char* get_ECMWF_local_parameter(grib_accessor* a, grib_handle* h) err=grib_get_long(h,"edition",&edition); if (err) return NULL; if (is_local_ecmwf_grib2_param_key(a,edition,centre)) { + char* pLocalParam = NULL; /* Must be one of: 'name', 'shortName', 'units', 'cfName' etc */ grib_accessor* a2 = NULL; long pid_guess = guess_paramId(h); if (pid_guess == -1) return NULL; + /* TODO: Need to revisit */ + pLocalParam = get_legacy_param_info(key_name, pid_guess); + if (pLocalParam) return pLocalParam; + /* Change the paramId so we can get the other string key*/ err = grib_set_long(h, "paramId", pid_guess); if (err) return NULL; From 93b0fa9ada81f74ed2aecef99f7aaf5da4602eb4 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 30 Sep 2019 10:04:40 +0100 Subject: [PATCH 21/49] Const correctness --- src/grib_accessor_class_concept.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/grib_accessor_class_concept.c b/src/grib_accessor_class_concept.c index 044871cf7..4cb51812b 100644 --- a/src/grib_accessor_class_concept.c +++ b/src/grib_accessor_class_concept.c @@ -567,7 +567,7 @@ static const char* get_ECMWF_local_parameter(grib_accessor* a, grib_handle* h) char* pLocalParam = NULL; /* Must be one of: 'name', 'shortName', 'units', 'cfName' etc */ grib_accessor* a2 = NULL; - long pid_guess = guess_paramId(h); + const long pid_guess = guess_paramId(h); if (pid_guess == -1) return NULL; /* TODO: Need to revisit */ From a9ecad64c70e53474e85145049a714d06b311679 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 30 Sep 2019 13:13:37 +0100 Subject: [PATCH 22/49] Parameters: Fix cfName for legacy ECMWF parameters (discipline 192) --- src/grib_accessor_class_concept.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/grib_accessor_class_concept.c b/src/grib_accessor_class_concept.c index 4cb51812b..40d2f2c1a 100644 --- a/src/grib_accessor_class_concept.c +++ b/src/grib_accessor_class_concept.c @@ -545,6 +545,8 @@ static char* get_legacy_param_info(const char* key_name, long paramId) if (strcmp(key_name, "name")==0) return "Surface net thermal radiation, clear sky"; if (strcmp(key_name, "cfVarName")==0) return "strc"; if (strcmp(key_name, "cfName")==0) return "surface_net_downward_longwave_flux_assuming_clear_sky"; + } else if (paramId == 228051 || paramId == 228053 || paramId == 228057 || paramId == 228058 || paramId == 228059 || paramId == 228060) { + if (strcmp(key_name, "cfName")==0) return "unknown"; } return NULL; } From 591b071b4a342302cb3d4a03c8ebc098e504492a Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 1 Oct 2019 12:12:18 +0100 Subject: [PATCH 23/49] ECC-997: grib_util_set_spec: Add support for CCSDS packing (GRIB2) --- src/grib_api.h | 17 +++++++++-------- src/grib_util.c | 21 +++++++++++++++++++++ tests/grib_util_set_spec.c | 5 ++++- tests/grib_util_set_spec.sh | 8 ++++++++ 4 files changed, 42 insertions(+), 9 deletions(-) diff --git a/src/grib_api.h b/src/grib_api.h index 5a8dcfc9d..fa9763e55 100644 --- a/src/grib_api.h +++ b/src/grib_api.h @@ -1497,14 +1497,15 @@ typedef struct grib_util_grid_spec2 { } grib_util_grid_spec2; -#define GRIB_UTIL_PACKING_TYPE_SAME_AS_INPUT 0 -#define GRIB_UTIL_PACKING_TYPE_SPECTRAL_COMPLEX 1 -#define GRIB_UTIL_PACKING_TYPE_SPECTRAL_SIMPLE 2 -#define GRIB_UTIL_PACKING_TYPE_JPEG 3 -#define GRIB_UTIL_PACKING_TYPE_GRID_COMPLEX 4 -#define GRIB_UTIL_PACKING_TYPE_GRID_SIMPLE 5 -#define GRIB_UTIL_PACKING_TYPE_GRID_SIMPLE_MATRIX 6 -#define GRIB_UTIL_PACKING_TYPE_GRID_SECOND_ORDER 7 +#define GRIB_UTIL_PACKING_TYPE_SAME_AS_INPUT 0 +#define GRIB_UTIL_PACKING_TYPE_SPECTRAL_COMPLEX 1 +#define GRIB_UTIL_PACKING_TYPE_SPECTRAL_SIMPLE 2 +#define GRIB_UTIL_PACKING_TYPE_JPEG 3 +#define GRIB_UTIL_PACKING_TYPE_GRID_COMPLEX 4 +#define GRIB_UTIL_PACKING_TYPE_GRID_SIMPLE 5 +#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_SAME_AS_INPUT 0 #define GRIB_UTIL_PACKING_USE_PROVIDED 1 diff --git a/src/grib_util.c b/src/grib_util.c index 63c7f3a03..b5bd0db27 100644 --- a/src/grib_util.c +++ b/src/grib_util.c @@ -857,6 +857,7 @@ grib_handle* grib_util_set_spec2(grib_handle* h, int packingTypeIsSet=0; int setSecondOrder=0; int setJpegPacking=0; + int setCcsdsPacking=0; int convertEditionEarlier=0;/* For cases when we cannot set some keys without converting */ size_t slen=17; int grib1_high_resolution_fix = 0; /* boolean: See GRIB-863 */ @@ -925,6 +926,10 @@ grib_handle* grib_util_set_spec2(grib_handle* h, if (strcmp(input_packing_type,"grid_jpeg") && !strcmp(input_packing_type,"grid_simple")) SET_STRING_VALUE("packingType","grid_jpeg"); break; + case GRIB_UTIL_PACKING_TYPE_CCSDS: + 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_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 */ @@ -1327,6 +1332,14 @@ grib_handle* grib_util_set_spec2(grib_handle* h, 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 + */ + if (strcmp(input_packing_type,"grid_ccsds") && !strcmp(input_packing_type,"grid_simple")) + setCcsdsPacking = 1; + 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 */ @@ -1606,6 +1619,14 @@ grib_handle* grib_util_set_spec2(grib_handle* h, goto cleanup; } } + if (setCcsdsPacking == 1) { + *err = grib_set_string(outh, "packingType", "grid_ccsds", &slen); + if (*err != GRIB_SUCCESS) { + fprintf(stderr,"GRIB_UTIL_SET_SPEC: Failed to change packingType to CCSDS: %s\n", + grib_get_error_message(*err)); + goto cleanup; + } + } } if (packing_spec->deleteLocalDefinition) { diff --git a/tests/grib_util_set_spec.c b/tests/grib_util_set_spec.c index 6bf315070..a7b073e7e 100644 --- a/tests/grib_util_set_spec.c +++ b/tests/grib_util_set_spec.c @@ -23,6 +23,8 @@ static int get_packing_type_code(const char* packingType) if (STR_EQUAL(packingType, "grid_jpeg")) result = GRIB_UTIL_PACKING_TYPE_JPEG; + if (STR_EQUAL(packingType, "grid_ccsds")) + result = GRIB_UTIL_PACKING_TYPE_CCSDS; else if (STR_EQUAL(packingType, "grid_simple")) result = GRIB_UTIL_PACKING_TYPE_GRID_SIMPLE; else if (STR_EQUAL(packingType, "grid_second_order")) @@ -178,6 +180,7 @@ static void test_regular_ll(int remove_local_def, int edition, const char* packi spec.Nj = 14; spec.Ni = 17; outlen = spec.Nj * spec.Ni; + /* outlen = inlen; */ spec.iDirectionIncrementInDegrees = 1.5; spec.jDirectionIncrementInDegrees = 1.5; spec.latitudeOfFirstGridPointInDegrees = 60.0001; @@ -330,7 +333,7 @@ static void test_grid_complex_spatial_differencing(int remove_local_def, int edi static void usage(const char *prog) { fprintf(stderr, "%s: [-p packingType] [-r] [-e edition] in.grib out.grib\n", prog); - fprintf(stderr, "-p packingType: one of grid_jpeg, grid_second_order or grid_simple\n"); + fprintf(stderr, "-p packingType: one of grid_jpeg, grid_ccsds, grid_second_order or grid_simple\n"); fprintf(stderr, "-r remove local definition\n"); fprintf(stderr, "-e edition: 1 or 2\n"); exit(1); diff --git a/tests/grib_util_set_spec.sh b/tests/grib_util_set_spec.sh index 35d0a81b0..70cd5c841 100755 --- a/tests/grib_util_set_spec.sh +++ b/tests/grib_util_set_spec.sh @@ -58,6 +58,14 @@ if [ $HAVE_JPEG -eq 1 ]; then [ "$res" = "2 1 grid_jpeg" ] fi +# Convert to edition2 and use CCSDS for packing +if [ $HAVE_AEC -eq 1 ]; then + infile=../data/latlon.grib + $EXEC $grib_util_set_spec -e 2 -p grid_ccsds $infile $outfile > /dev/null + res=`${tools_dir}/grib_get -p edition,section2Used,packingType $outfile` + [ "$res" = "2 1 grid_ccsds" ] +fi + # -------------------------------------------------- # Reduced Gaussian Grid N=32 second order packing # -------------------------------------------------- From 0e3932106eca538ca83e995f34352150e68214c8 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 1 Oct 2019 13:40:49 +0100 Subject: [PATCH 24/49] Testing: prevent failure due to known error --- tests/grib_util_set_spec.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/grib_util_set_spec.sh b/tests/grib_util_set_spec.sh index 70cd5c841..fab74df00 100755 --- a/tests/grib_util_set_spec.sh +++ b/tests/grib_util_set_spec.sh @@ -69,6 +69,9 @@ fi # -------------------------------------------------- # Reduced Gaussian Grid N=32 second order packing # -------------------------------------------------- +# The gaussian tests intentionally cause an error so need to stop it failing +unset ECCODES_FAIL_IF_LOG_MESSAGE + infile=../data/reduced_gaussian_model_level.grib2 outfile=out.grib_util_set_spec.grib rm -f $outfile From 0057dc4719fe9662405db088dc257390d3d00eb0 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 1 Oct 2019 13:56:50 +0100 Subject: [PATCH 25/49] ECC-994: Tigge check update --- tigge/tigge_check.h | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/tigge/tigge_check.h b/tigge/tigge_check.h index 35aecc7c8..f3c509c2a 100644 --- a/tigge/tigge_check.h +++ b/tigge/tigge_check.h @@ -3922,7 +3922,7 @@ uerra, eswi-enfo:total_cloud_cover_sfc maximum value 96.4844 is not in [100,100] {&daily_average, &given_thickness, &has_bitmap}, }, { - "mean_sea_water_potential_temperature_in_the_upper_300_m_o2d.s2", + "mean_sea_water_temperature_in_the_upper_300_m_o2d.s2", -1e+8, 1e+8, -1e+8, @@ -3933,6 +3933,31 @@ uerra, eswi-enfo:total_cloud_cover_sfc maximum value 96.4844 is not in [100,100] {"paramId", GRIB_TYPE_LONG, 151127}, {"discipline", GRIB_TYPE_LONG, 10}, {"parameterCategory", GRIB_TYPE_LONG, 4}, + {"parameterNumber", GRIB_TYPE_LONG, 15}, + + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 160}, + {"scaleFactorOfFirstFixedSurface", GRIB_TYPE_LONG, 0}, + {"scaledValueOfFirstFixedSurface", GRIB_TYPE_LONG, 0}, + + {"typeOfSecondFixedSurface", GRIB_TYPE_LONG, 160}, + {"scaleFactorOfSecondFixedSurface", GRIB_TYPE_LONG, 0}, + {"scaledValueOfSecondFixedSurface", GRIB_TYPE_LONG, 300}, + {NULL, }, + }, + {&daily_average, &given_thickness, &has_bitmap}, + }, + { + "mean_sea_water_potential_temperature_in_the_upper_300_m_o2d.s2", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"class", GRIB_TYPE_STRING, 0, "s2"}, + + {"paramId", GRIB_TYPE_LONG, 151126}, + {"discipline", GRIB_TYPE_LONG, 10}, + {"parameterCategory", GRIB_TYPE_LONG, 4}, {"parameterNumber", GRIB_TYPE_LONG, 18}, {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 160}, From 8cbc205171ecbfff777f4455892f2d77ea3b402a Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 1 Oct 2019 13:58:40 +0100 Subject: [PATCH 26/49] ECC-994: Tigge check update --- tigge/tigge_check.h | 233 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 232 insertions(+), 1 deletion(-) diff --git a/tigge/tigge_check.h b/tigge/tigge_check.h index 47f3bb014..f3c509c2a 100644 --- a/tigge/tigge_check.h +++ b/tigge/tigge_check.h @@ -3871,6 +3871,237 @@ uerra, eswi-enfo:total_cloud_cover_sfc maximum value 96.4844 is not in [100,100] {&point_in_time, &given_level, &pressure_level}, }, + /* + s2s ocean parameters + */ + + { + "depth_of_20_C_isotherm_o2d.s2", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"class", GRIB_TYPE_STRING, 0, "s2"}, + + {"paramId", GRIB_TYPE_LONG, 151163}, + {"discipline", GRIB_TYPE_LONG, 10}, + {"parameterCategory", GRIB_TYPE_LONG, 4}, + {"parameterNumber", GRIB_TYPE_LONG, 14}, + + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 20}, + {"scaleFactorOfFirstFixedSurface", GRIB_TYPE_LONG, 2}, + {"scaledValueOfFirstFixedSurface", GRIB_TYPE_LONG, 29315}, + {NULL, }, + }, + {&daily_average, &predefined_level, &has_bitmap}, + }, + { + "average_salinity_in_the_upper_300_m_o2d.s2", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"class", GRIB_TYPE_STRING, 0, "s2"}, + + {"paramId", GRIB_TYPE_LONG, 151175}, + {"discipline", GRIB_TYPE_LONG, 10}, + {"parameterCategory", GRIB_TYPE_LONG, 4}, + {"parameterNumber", GRIB_TYPE_LONG, 21}, + + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 160}, + {"scaleFactorOfFirstFixedSurface", GRIB_TYPE_LONG, 0}, + {"scaledValueOfFirstFixedSurface", GRIB_TYPE_LONG, 0}, + + {"typeOfSecondFixedSurface", GRIB_TYPE_LONG, 160}, + {"scaleFactorOfSecondFixedSurface", GRIB_TYPE_LONG, 0}, + {"scaledValueOfSecondFixedSurface", GRIB_TYPE_LONG, 300}, + {NULL, }, + }, + {&daily_average, &given_thickness, &has_bitmap}, + }, + { + "mean_sea_water_temperature_in_the_upper_300_m_o2d.s2", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"class", GRIB_TYPE_STRING, 0, "s2"}, + + {"paramId", GRIB_TYPE_LONG, 151127}, + {"discipline", GRIB_TYPE_LONG, 10}, + {"parameterCategory", GRIB_TYPE_LONG, 4}, + {"parameterNumber", GRIB_TYPE_LONG, 15}, + + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 160}, + {"scaleFactorOfFirstFixedSurface", GRIB_TYPE_LONG, 0}, + {"scaledValueOfFirstFixedSurface", GRIB_TYPE_LONG, 0}, + + {"typeOfSecondFixedSurface", GRIB_TYPE_LONG, 160}, + {"scaleFactorOfSecondFixedSurface", GRIB_TYPE_LONG, 0}, + {"scaledValueOfSecondFixedSurface", GRIB_TYPE_LONG, 300}, + {NULL, }, + }, + {&daily_average, &given_thickness, &has_bitmap}, + }, + { + "mean_sea_water_potential_temperature_in_the_upper_300_m_o2d.s2", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"class", GRIB_TYPE_STRING, 0, "s2"}, + + {"paramId", GRIB_TYPE_LONG, 151126}, + {"discipline", GRIB_TYPE_LONG, 10}, + {"parameterCategory", GRIB_TYPE_LONG, 4}, + {"parameterNumber", GRIB_TYPE_LONG, 18}, + + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 160}, + {"scaleFactorOfFirstFixedSurface", GRIB_TYPE_LONG, 0}, + {"scaledValueOfFirstFixedSurface", GRIB_TYPE_LONG, 0}, + + {"typeOfSecondFixedSurface", GRIB_TYPE_LONG, 160}, + {"scaleFactorOfSecondFixedSurface", GRIB_TYPE_LONG, 0}, + {"scaledValueOfSecondFixedSurface", GRIB_TYPE_LONG, 300}, + {NULL, }, + }, + {&daily_average, &given_thickness, &has_bitmap}, + }, + { + "ocean_mixed_layer_thickness_defined_by_sigma_theta_0.01_kg/m3_o2d.s2", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"class", GRIB_TYPE_STRING, 0, "s2"}, + + {"paramId", GRIB_TYPE_LONG, 151225}, + {"discipline", GRIB_TYPE_LONG, 10}, + {"parameterCategory", GRIB_TYPE_LONG, 4}, + {"parameterNumber", GRIB_TYPE_LONG, 14}, + + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 169}, + {"scaleFactorOfFirstFixedSurface", GRIB_TYPE_LONG, 2}, + {"scaledValueOfFirstFixedSurface", GRIB_TYPE_LONG, 1}, + + {NULL, }, + }, + {&daily_average, &predefined_level, &has_bitmap}, + }, + { + "eastward_sea_water_velocity_o2d.s2", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"class", GRIB_TYPE_STRING, 0, "s2"}, + + {"paramId", GRIB_TYPE_LONG, 151131}, + {"discipline", GRIB_TYPE_LONG, 10}, + {"parameterCategory", GRIB_TYPE_LONG, 1}, + {"parameterNumber", GRIB_TYPE_LONG, 2}, + + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 160}, + {"scaleFactorOfFirstFixedSurface", GRIB_TYPE_LONG, 0}, + {"scaledValueOfFirstFixedSurface", GRIB_TYPE_LONG, 0}, + + {NULL, }, + }, + {&daily_average, &predefined_level, &has_bitmap}, + }, + { + "northward_sea_water_velocity_o2d.s2", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"class", GRIB_TYPE_STRING, 0, "s2"}, + + {"paramId", GRIB_TYPE_LONG, 151132}, + {"discipline", GRIB_TYPE_LONG, 10}, + {"parameterCategory", GRIB_TYPE_LONG, 1}, + {"parameterNumber", GRIB_TYPE_LONG, 3}, + + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 160}, + {"scaleFactorOfFirstFixedSurface", GRIB_TYPE_LONG, 0}, + {"scaledValueOfFirstFixedSurface", GRIB_TYPE_LONG, 0}, + + {NULL, }, + }, + {&daily_average, &predefined_level, &has_bitmap}, + }, + { + "sea-ice_thickness_o2d.s2", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"class", GRIB_TYPE_STRING, 0, "s2"}, + + {"paramId", GRIB_TYPE_LONG, 174098}, + {"discipline", GRIB_TYPE_LONG, 10}, + {"parameterCategory", GRIB_TYPE_LONG, 2}, + {"parameterNumber", GRIB_TYPE_LONG, 1}, + + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 160}, + {"scaleFactorOfFirstFixedSurface", GRIB_TYPE_LONG, 0}, + {"scaledValueOfFirstFixedSurface", GRIB_TYPE_LONG, 0}, + + {NULL, }, + }, + {&daily_average, &predefined_level, &has_bitmap}, + }, + { + "sea_surface_height_o2d.s2", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"class", GRIB_TYPE_STRING, 0, "s2"}, + + {"paramId", GRIB_TYPE_LONG, 151145}, + {"discipline", GRIB_TYPE_LONG, 10}, + {"parameterCategory", GRIB_TYPE_LONG, 3}, + {"parameterNumber", GRIB_TYPE_LONG, 1}, + + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 160}, + {"scaleFactorOfFirstFixedSurface", GRIB_TYPE_LONG, 0}, + {"scaledValueOfFirstFixedSurface", GRIB_TYPE_LONG, 0}, + + {NULL, }, + }, + {&daily_average, &predefined_level, &has_bitmap}, + }, + { + "sea_surface_practical_salinity_o2d.s2", + -1e+8, + 1e+8, + -1e+8, + 1e+8, + { + {"class", GRIB_TYPE_STRING, 0, "s2"}, + + {"paramId", GRIB_TYPE_LONG, 151219}, + {"discipline", GRIB_TYPE_LONG, 10}, + {"parameterCategory", GRIB_TYPE_LONG, 3}, + {"parameterNumber", GRIB_TYPE_LONG, 3}, + + {"typeOfFirstFixedSurface", GRIB_TYPE_LONG, 160}, + {"scaleFactorOfFirstFixedSurface", GRIB_TYPE_LONG, 0}, + {"scaledValueOfFirstFixedSurface", GRIB_TYPE_LONG, 0}, + + {NULL, }, + }, + {&daily_average, &predefined_level, &has_bitmap}, + }, }; - From 4d5abcb7db6f02d01d39b553382d4c684da9669a Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 2 Oct 2019 14:51:14 +0100 Subject: [PATCH 27/49] ECC-995: C API: Review const-ness of arguments (part 1) --- src/eccodes.c | 28 +++++++++--------- src/eccodes.h | 32 ++++++++++----------- src/grib_accessor_class_iterator.c | 5 ++-- src/grib_accessor_class_nearest.c | 3 +- src/grib_api.h | 30 +++++++++---------- src/grib_api_prototypes.h | 46 +++++++++++++++--------------- src/grib_dumper.c | 6 ++-- src/grib_dumper_class.c | 6 ++-- src/grib_handle.c | 18 ++++++------ src/grib_iterator.c | 2 +- src/grib_nearest.c | 5 ++-- src/grib_query.c | 8 ++++-- src/grib_value.c | 12 ++++---- 13 files changed, 106 insertions(+), 95 deletions(-) diff --git a/src/eccodes.c b/src/eccodes.c index 0958c6c45..818d6222d 100644 --- a/src/eccodes.c +++ b/src/eccodes.c @@ -155,7 +155,7 @@ void codes_index_delete(grib_index* index) /* Create handle */ /******************************************************************************/ -int codes_write_message(grib_handle* h,const char* file,const char* mode) +int codes_write_message(const grib_handle* h,const char* file,const char* mode) { return grib_write_message(h,file,mode); } @@ -171,7 +171,7 @@ grib_handle* codes_grib_handle_new_from_samples(grib_context* c, const char* sam { return grib_handle_new_from_samples(c, sample_name); } -grib_handle* codes_handle_clone(grib_handle* h) +grib_handle* codes_handle_clone(const grib_handle* h) { return grib_handle_clone(h); } @@ -187,11 +187,11 @@ grib_handle* codes_handle_new_from_partial_message(grib_context* c, const void* { return grib_handle_new_from_partial_message(c,data,buflen); } -int codes_get_message(grib_handle* h ,const void** message, size_t *message_length ) +int codes_get_message(const grib_handle* h ,const void** message, size_t *message_length ) { return grib_get_message(h,message,message_length); } -int codes_get_message_copy(grib_handle* h, void* message,size_t *message_length ) +int codes_get_message_copy(const grib_handle* h, void* message,size_t *message_length ) { return grib_get_message_copy(h,message,message_length); } @@ -255,11 +255,11 @@ int codes_grib_multi_handle_write(grib_multi_handle* mh,FILE* f) /* Lat/Lon iterator and nearest (GRIB specific) */ /******************************************************************************/ -grib_iterator* codes_grib_iterator_new(grib_handle* h, unsigned long flags,int* error) +grib_iterator* codes_grib_iterator_new(const grib_handle* h, unsigned long flags,int* error) { return grib_iterator_new(h,flags,error); } -int codes_grib_get_data(grib_handle *h, double *lats, double *lons, double *values) +int codes_grib_get_data(const grib_handle *h, double *lats, double *lons, double *values) { return grib_get_data(h,lats,lons,values); } @@ -284,17 +284,17 @@ int codes_grib_iterator_delete(grib_iterator *i) return grib_iterator_delete(i); } -grib_nearest* codes_grib_nearest_new(grib_handle* h, int* error) +grib_nearest* codes_grib_nearest_new(const grib_handle* h, int* error) { return grib_nearest_new(h,error); } -int codes_grib_nearest_find(grib_nearest *nearest,grib_handle* h,double inlat,double inlon, +int codes_grib_nearest_find(grib_nearest *nearest, const grib_handle* h,double inlat,double inlon, unsigned long flags,double* outlats,double* outlons, double* values,double* distances,int* indexes,size_t *len) { return grib_nearest_find(nearest, h, inlat, inlon, flags, outlats, outlons, values, distances, indexes, len); } -int codes_grib_nearest_find_multiple(grib_handle* h,int is_lsm, +int codes_grib_nearest_find_multiple(const grib_handle* h,int is_lsm, double* inlats,double* inlons,long npoints, double* outlats,double* outlons, double* values,double* distances, int* indexes) @@ -321,11 +321,11 @@ int codes_set_missing(grib_handle* h, const char* key) { return grib_set_missing(h,key); } -int codes_get_size(grib_handle* h, const char* key,size_t *size) +int codes_get_size(const grib_handle* h, const char* key,size_t *size) { return grib_get_size(h,key,size); } -int codes_get_length(grib_handle* h, const char* key,size_t *length) +int codes_get_length(const grib_handle* h, const char* key,size_t *length) { return grib_get_length(h,key,length); } @@ -407,15 +407,15 @@ int codes_set_values(grib_handle* h,grib_values* grib_values , size_t arg_count { return grib_set_values(h,grib_values,arg_count); } -int codes_get_message_offset ( grib_handle* h,off_t* offset ) +int codes_get_message_offset(const grib_handle* h,off_t* offset) { return grib_get_message_offset (h,offset); } -int codes_get_message_size ( grib_handle* h,size_t* size ) +int codes_get_message_size(const grib_handle* h,size_t* size) { return grib_get_message_size (h,size); } -void codes_dump_content(grib_handle* h,FILE* out,const char* mode, unsigned long option_flags,void* arg) +void codes_dump_content(const grib_handle* h,FILE* out,const char* mode, unsigned long option_flags,void* arg) { grib_dump_content(h, out, mode, option_flags, arg); } diff --git a/src/eccodes.h b/src/eccodes.h index beb43c15b..82f910212 100644 --- a/src/eccodes.h +++ b/src/eccodes.h @@ -415,7 +415,7 @@ codes_handle* codes_bufr_handle_new_from_file(codes_context* c, FILE* f, int* er * @param mode : mode * @return 0 if OK, integer value on error */ -int codes_write_message(codes_handle* h, const char* file, const char* mode); +int codes_write_message(const codes_handle* h, const char* file, const char* mode); codes_handle* codes_grib_util_sections_copy(codes_handle* hfrom, codes_handle* hto, int what, int *err); codes_string_list* codes_grib_util_get_param_id(const char* mars_param); @@ -485,7 +485,7 @@ codes_handle* codes_bufr_handle_new_from_samples(codes_context* c, const char* s * @param h : The handle to be cloned * @return the new handle, NULL if the message is invalid or a problem is encountered */ -codes_handle* codes_handle_clone(codes_handle* h); +codes_handle* codes_handle_clone(const codes_handle* h); /** * Frees a handle, also frees the message if it is not a user message @@ -552,7 +552,7 @@ int codes_grib_multi_handle_write(codes_multi_handle* mh, FILE* f); * @param message_length : On exit, the message size in number of bytes * @return 0 if OK, integer value on error */ -int codes_get_message(codes_handle* h, const void** message, size_t *message_length); +int codes_get_message(const codes_handle* h, const void** message, size_t *message_length); /** @@ -564,7 +564,7 @@ int codes_get_message(codes_handle* h, const void** message, size_t *message_len * On exit, the actual message length in number of bytes * @return 0 if OK, integer value on error */ -int codes_get_message_copy(codes_handle* h, void* message, size_t *message_length); +int codes_get_message_copy(const codes_handle* h, void* message, size_t *message_length); /*! @} */ /*! \defgroup iterators Iterating on latitude/longitude/values */ @@ -578,7 +578,7 @@ int codes_get_message_copy(codes_handle* h, void* message, size_t *message_lengt * \param error : error code * \return the new iterator, NULL if no iterator can be created */ -codes_iterator* codes_grib_iterator_new(codes_handle* h, unsigned long flags, int* error); +codes_iterator* codes_grib_iterator_new(const codes_handle* h, unsigned long flags, int* error); /** * Get latitude/longitude and data values. @@ -591,7 +591,7 @@ codes_iterator* codes_grib_iterator_new(codes_handle* h, unsigned long flags, in * @param values : returned array of data values * @return 0 if OK, integer value on error */ -int codes_grib_get_data(codes_handle *h, double *lats, double *lons, double *values); +int codes_grib_get_data(const codes_handle *h, double *lats, double *lons, double *values); /** * Get the next value from an iterator. @@ -646,7 +646,7 @@ int codes_grib_iterator_delete(codes_iterator *i); * \param error : error code * \return the new nearest, NULL if no nearest can be created */ -codes_nearest* codes_grib_nearest_new(codes_handle* h, int* error); +codes_nearest* codes_grib_nearest_new(const codes_handle* h, int* error); /** * Find the 4 nearest points of a latitude longitude point. @@ -669,7 +669,7 @@ codes_nearest* codes_grib_nearest_new(codes_handle* h, int* error); * @param len : size of the arrays * @return 0 if OK, integer value on error */ -int codes_grib_nearest_find(codes_nearest *nearest, codes_handle* h, double inlat, double inlon, +int codes_grib_nearest_find(codes_nearest *nearest, const codes_handle* h, double inlat, double inlon, unsigned long flags, double* outlats, double* outlons, double* values, double* distances, int* indexes, size_t *len); @@ -705,7 +705,7 @@ int codes_grib_nearest_delete(codes_nearest *nearest); * @param indexes : returned array of indexes of the nearest points * @return 0 if OK, integer value on error */ -int codes_grib_nearest_find_multiple(codes_handle* h, int is_lsm, +int codes_grib_nearest_find_multiple(const codes_handle* h, int is_lsm, double* inlats, double* inlons, long npoints, double* outlats, double* outlons, double* values, double* distances, int* indexes); @@ -723,7 +723,7 @@ int codes_grib_nearest_find_multiple(codes_handle* h, int is_lsm, * @param offset : the address of a size_t where the offset will be set * @return 0 if OK, integer value on error */ -int codes_get_offset(codes_handle* h, const char* key, size_t* offset); +int codes_get_offset(const codes_handle* h, const char* key, size_t* offset); /** * Get the number of coded value from a key, if several keys of the same name are present, the total sum is returned @@ -733,7 +733,7 @@ int codes_get_offset(codes_handle* h, const char* key, size_t* offset); * @param size : the address of a size_t where the size will be set * @return 0 if OK, integer value on error */ -int codes_get_size(codes_handle* h, const char* key, size_t *size); +int codes_get_size(const codes_handle* h, const char* key, size_t *size); /** * Get the length of the string representation of the key, if several keys of the same name are present, the maximum length is returned @@ -743,7 +743,7 @@ int codes_get_size(codes_handle* h, const char* key, size_t *size); * @param length : the address of a size_t where the length will be set * @return 0 if OK, integer value on error */ -int codes_get_length(codes_handle* h, const char* key, size_t *length); +int codes_get_length(const codes_handle* h, const char* key, size_t *length); /** * Get a long value from a key, if several keys of the same name are present, the last one is returned @@ -963,7 +963,7 @@ int codes_set_string_array(codes_handle *h, const char *key, const char **vals, * @param option_flags : all the CODES_DUMP_FLAG_x flags can be used * @param arg : used to provide a format to output data (experimental) */ -void codes_dump_content(codes_handle* h, FILE* out, const char* mode, unsigned long option_flags, void* arg); +void codes_dump_content(const codes_handle* h, FILE* out, const char* mode, unsigned long option_flags, void* arg); /** * Print all keys from the parsed definition files available in a context @@ -1215,9 +1215,9 @@ void codes_get_reduced_row_p(long pl, double lon_first, double lon_last, long *n /* read products */ -int codes_get_message_offset(codes_handle* h, off_t* offset); -int codes_get_message_size(codes_handle* h, size_t* size); -int codes_get_product_kind(codes_handle* h, ProductKind* product_kind); +int codes_get_message_offset(const codes_handle* h, off_t* offset); +int codes_get_message_size(const codes_handle* h, size_t* size); +int codes_get_product_kind(const codes_handle* h, ProductKind* product_kind); int codes_check_message_header(const void* bytes, size_t length, ProductKind product); int codes_check_message_footer(const void* bytes, size_t length, ProductKind product); diff --git a/src/grib_accessor_class_iterator.c b/src/grib_accessor_class_iterator.c index 02ac0dd3e..f4beabe76 100644 --- a/src/grib_accessor_class_iterator.c +++ b/src/grib_accessor_class_iterator.c @@ -144,8 +144,9 @@ static void dump(grib_accessor* a,grib_dumper* dumper) grib_dump_label(dumper,a,NULL); } -grib_iterator* grib_iterator_new(grib_handle* h,unsigned long flags,int* error) -{ +grib_iterator* grib_iterator_new(const grib_handle* ch, unsigned long flags, int* error) +{ + grib_handle* h = (grib_handle*)ch; grib_accessor* a = NULL; grib_accessor_iterator* ita =NULL; grib_iterator* iter =NULL; diff --git a/src/grib_accessor_class_nearest.c b/src/grib_accessor_class_nearest.c index df7e0351e..2adb1107f 100644 --- a/src/grib_accessor_class_nearest.c +++ b/src/grib_accessor_class_nearest.c @@ -140,8 +140,9 @@ static void dump(grib_accessor* a,grib_dumper* dumper) grib_dump_label(dumper,a,NULL); } -grib_nearest* grib_nearest_new(grib_handle* h,int* error) +grib_nearest* grib_nearest_new(const grib_handle* ch, int* error) { + grib_handle* h = (grib_handle*)ch; grib_accessor* a = NULL; grib_accessor_nearest* na =NULL; grib_nearest* n =NULL; diff --git a/src/grib_api.h b/src/grib_api.h index fa9763e55..fb89e7c1f 100644 --- a/src/grib_api.h +++ b/src/grib_api.h @@ -433,7 +433,7 @@ grib_handle* grib_handle_new_from_file(grib_context* c, FILE* f, int* error); * @param mode : mode * @return 0 if OK, integer value on error */ -int grib_write_message(grib_handle* h,const char* file,const char* mode); +int grib_write_message(const grib_handle* h,const char* file,const char* mode); typedef struct grib_string_list grib_string_list; struct grib_string_list { @@ -502,7 +502,7 @@ grib_handle* grib_handle_new_from_samples (grib_context* c, const char* sample_n * @param h : The handle to be cloned * @return the new handle, NULL if the message is invalid or a problem is encountered */ -grib_handle* grib_handle_clone(grib_handle* h) ; +grib_handle* grib_handle_clone(const grib_handle* h) ; /** * Frees a handle, also frees the message if it is not a user message @@ -565,7 +565,7 @@ int grib_multi_handle_write(grib_multi_handle* mh,FILE* f); * @param message_length : On exit, the message size in number of bytes * @return 0 if OK, integer value on error */ -int grib_get_message(grib_handle* h ,const void** message, size_t *message_length); +int grib_get_message(const grib_handle* h ,const void** message, size_t *message_length); /** @@ -577,7 +577,7 @@ int grib_get_message(grib_handle* h ,const void** message, size_t *message_lengt * On exit, the actual message length in number of bytes * @return 0 if OK, integer value on error */ -int grib_get_message_copy(grib_handle* h , void* message,size_t *message_length); +int grib_get_message_copy(const grib_handle* h, void* message,size_t *message_length); /*! @} */ /*! \defgroup iterators Iterating on latitude/longitude/values */ @@ -591,7 +591,7 @@ int grib_get_message_copy(grib_handle* h , void* message,size_t *message_length * \param error : error code * \return the new iterator, NULL if no iterator can be created */ -grib_iterator* grib_iterator_new(grib_handle* h, unsigned long flags,int* error); +grib_iterator* grib_iterator_new(const grib_handle* h, unsigned long flags, int* error); /** * Get latitude/longitude and data values. @@ -604,7 +604,7 @@ grib_iterator* grib_iterator_new(grib_handle* h, unsigned long flags,int* erro * @param values : returned array of data values * @return 0 if OK, integer value on error */ -int grib_get_data(grib_handle *h, double *lats, double *lons, double *values); +int grib_get_data(const grib_handle *h, double *lats, double *lons, double *values); /** * Get the next value from an iterator. @@ -659,7 +659,7 @@ int grib_iterator_delete(grib_iterator *i); * \param error : error code * \return the new nearest, NULL if no nearest can be created */ -grib_nearest* grib_nearest_new(grib_handle* h, int* error); +grib_nearest* grib_nearest_new(const grib_handle* h, int* error); /** * Find the 4 nearest points of a latitude longitude point. @@ -682,7 +682,7 @@ grib_nearest* grib_nearest_new(grib_handle* h, int* error); * @param len : size of the arrays * @return 0 if OK, integer value on error */ -int grib_nearest_find(grib_nearest *nearest,grib_handle* h,double inlat,double inlon, +int grib_nearest_find(grib_nearest *nearest, const grib_handle* h,double inlat,double inlon, unsigned long flags,double* outlats,double* outlons, double* values,double* distances,int* indexes,size_t *len); @@ -718,7 +718,7 @@ int grib_nearest_delete(grib_nearest *nearest); * @param indexes : returned array of indexes of the nearest points * @return 0 if OK, integer value on error */ -int grib_nearest_find_multiple(grib_handle* h,int is_lsm, +int grib_nearest_find_multiple(const grib_handle* h,int is_lsm, double* inlats,double* inlons,long npoints, double* outlats,double* outlons, double* values,double* distances, int* indexes); @@ -736,7 +736,7 @@ int grib_nearest_find_multiple(grib_handle* h,int is_lsm, * @param offset : the address of a size_t where the offset will be set * @return 0 if OK, integer value on error */ -int grib_get_offset(grib_handle* h, const char* key, size_t* offset); +int grib_get_offset(const grib_handle* h, const char* key, size_t* offset); /** * Get the number of coded value from a key, if several keys of the same name are present, the total sum is returned @@ -746,7 +746,7 @@ int grib_get_offset(grib_handle* h, const char* key, size_t* offset); * @param size : the address of a size_t where the size will be set * @return 0 if OK, integer value on error */ -int grib_get_size(grib_handle* h, const char* key,size_t *size); +int grib_get_size(const grib_handle* h, const char* key,size_t *size); /** * Get the length of the string representation of the key, if several keys of the same name are present, the maximum length is returned @@ -756,7 +756,7 @@ int grib_get_size(grib_handle* h, const char* key,size_t *size); * @param length : the address of a size_t where the length will be set * @return 0 if OK, integer value on error */ -int grib_get_length(grib_handle* h, const char* key,size_t *length); +int grib_get_length(const grib_handle* h, const char* key,size_t *length); /** * Get a long value from a key, if several keys of the same name are present, the last one is returned @@ -975,7 +975,7 @@ int grib_set_string_array(grib_handle* h, const char *key, const char **vals, si * @param option_flags : all the GRIB_DUMP_FLAG_x flags can be used * @param arg : used to provide a format to output data (experimental) */ -void grib_dump_content(grib_handle* h,FILE* out,const char* mode, unsigned long option_flags,void* arg); +void grib_dump_content(const grib_handle* h,FILE* out,const char* mode, unsigned long option_flags,void* arg); /** * Print all keys from the parsed definition files available in a context @@ -1365,8 +1365,8 @@ void *wmo_read_bufr_from_file_malloc(FILE* f,int headers_only,size_t *size,off_t void *wmo_read_grib_from_file_malloc(FILE* f,int headers_only,size_t *size,off_t *offset,int* err); int grib_read_any_from_file(grib_context *ctx, FILE *f, void *buffer, size_t *len); -int grib_get_message_offset ( grib_handle* h,off_t* offset); -int grib_get_message_size ( grib_handle* h,size_t* size); +int grib_get_message_offset(const grib_handle* h,off_t* offset); +int grib_get_message_size(const grib_handle* h,size_t* size); struct grib_points { grib_context* context; diff --git a/src/grib_api_prototypes.h b/src/grib_api_prototypes.h index ffe8b9878..6f30f7ec3 100644 --- a/src/grib_api_prototypes.h +++ b/src/grib_api_prototypes.h @@ -519,12 +519,12 @@ void accessor_constant_set_type(grib_accessor *a, int type); void accessor_constant_set_dval(grib_accessor *a, double dval); /* grib_accessor_class_iterator.c */ -grib_iterator *grib_iterator_new(grib_handle *h, unsigned long flags, int *error); +grib_iterator *grib_iterator_new(const grib_handle *h, unsigned long flags, int *error); /* grib_accessor_class_message.c */ /* grib_accessor_class_nearest.c */ -grib_nearest *grib_nearest_new(grib_handle *h, int *error); +grib_nearest *grib_nearest_new(const grib_handle *h, int *error); /* grib_accessor_class_box.c */ grib_box *grib_box_new(grib_handle *h, int *error); @@ -916,8 +916,8 @@ void grib_dump_bytes(grib_dumper *d, grib_accessor *a, const char *comment); void grib_dump_bits(grib_dumper *d, grib_accessor *a, const char *comment); void grib_dump_section(grib_dumper *d, grib_accessor *a, grib_block_of_accessors *block); void grib_dump_values(grib_dumper *d, grib_accessor *a); -void grib_dump_header(grib_dumper *d, grib_handle *h); -void grib_dump_footer(grib_dumper *d, grib_handle *h); +void grib_dump_header(grib_dumper *d, const grib_handle *h); +void grib_dump_footer(grib_dumper *d, const grib_handle *h); /* grib_dumper_class_serialize.c */ @@ -952,11 +952,11 @@ void grib_dump_footer(grib_dumper *d, grib_handle *h); /* grib_dumper_class_wmo.c */ /* grib_dumper_class.c */ -grib_dumper *grib_dumper_factory(const char *op, grib_handle *h, FILE *out, unsigned long option_flags, void *arg); +grib_dumper *grib_dumper_factory(const char *op, const grib_handle *h, FILE *out, unsigned long option_flags, void *arg); void grib_dump_accessors_block(grib_dumper *dumper, grib_block_of_accessors *block); void grib_dump_accessors_list(grib_dumper *dumper, grib_accessors_list *al); int grib_print(grib_handle *h, const char *name, grib_dumper *d); -void grib_dump_content(grib_handle *h, FILE *f, const char *mode, unsigned long flags, void *data); +void grib_dump_content(const grib_handle *h, FILE *f, const char *mode, unsigned long flags, void *data); void grib_dump_keys(grib_handle* h, FILE* f, const char* mode, unsigned long flags, void *data, const char **keys, size_t num_keys); grib_dumper *grib_dump_content_with_dumper(grib_handle *h, grib_dumper *dumper, FILE *f, const char *mode, unsigned long flags, void *data); void codes_dump_bufr_flat(grib_accessors_list *al, grib_handle *h, FILE *f, const char *mode, unsigned long flags, void *data); @@ -1070,8 +1070,8 @@ int grib_handle_delete(grib_handle *h); grib_handle *grib_new_handle(grib_context *c); grib_handle *grib_handle_new_from_samples(grib_context *c, const char *name); grib_handle *codes_bufr_handle_new_from_samples(grib_context *c, const char *name); -int grib_write_message(grib_handle *h, const char *file, const char *mode); -grib_handle *grib_handle_clone(grib_handle *h); +int grib_write_message(const grib_handle *h, const char *file, const char *mode); +grib_handle *grib_handle_clone(const grib_handle *h); grib_handle *codes_handle_new_from_file(grib_context *c, FILE *f, ProductKind product, int *error); grib_handle *codes_grib_handle_new_from_file(grib_context *c, FILE *f, int *error); grib_handle *codes_bufr_handle_new_from_file(grib_context *c, FILE *f, int *error); @@ -1095,13 +1095,13 @@ int grib_multi_handle_append(grib_handle *h, int start_section, grib_multi_handl int grib_multi_handle_write(grib_multi_handle *h, FILE *f); int grib_get_partial_message(grib_handle *h, const void **msg, size_t *len, int start_section); int grib_get_partial_message_copy(grib_handle *h, void *message, size_t *len, int start_section); -int grib_get_message_copy(grib_handle *h, void *message, size_t *len); -int grib_get_message_offset(grib_handle *h, off_t *offset); -int codes_get_product_kind(grib_handle *h, ProductKind *product_kind); +int grib_get_message_copy(const grib_handle *h, void *message, size_t *len); +int grib_get_message_offset(const grib_handle *h, off_t *offset); +int codes_get_product_kind(const grib_handle *h, ProductKind *product_kind); int codes_check_message_header(const void *bytes, size_t length, ProductKind product); int codes_check_message_footer(const void *bytes, size_t length, ProductKind product); -int grib_get_message_size(grib_handle *h, size_t *size); -int grib_get_message(grib_handle *h, const void **msg, size_t *size); +int grib_get_message_size(const grib_handle *h, size_t *size); +int grib_get_message(const grib_handle *h, const void **msg, size_t *size); int grib_get_message_headers(grib_handle *h, const void **msg, size_t *size); grib_handle *grib_handle_new(grib_context *c); grib_action *grib_action_from_filter(const char *filter); @@ -1219,9 +1219,9 @@ grib_action *grib_parse_file(grib_context *gc, const char *filename); int grib_type_to_int(char id); /* grib_query.c */ -grib_accessors_list *grib_find_accessors_list(grib_handle *h, const char *name); +grib_accessors_list *grib_find_accessors_list(const grib_handle *h, const char *name); char *grib_split_name_attribute(grib_context *c, const char *name, char *attribute_name); -grib_accessor *grib_find_accessor(grib_handle *h, const char *name); +grib_accessor *grib_find_accessor(const grib_handle *h, const char *name); grib_accessor *grib_find_attribute(grib_handle *h, const char *name, const char *attr_name, int *err); grib_accessor *grib_find_accessor_fast(grib_handle *h, const char *name); @@ -1295,12 +1295,12 @@ int _grib_get_double_array_internal(grib_handle *h, grib_accessor *a, double *va int grib_get_double_array_internal(grib_handle *h, const char *name, double *val, size_t *length); int grib_get_double_array(grib_handle *h, const char *name, double *val, size_t *length); int _grib_get_string_length(grib_accessor *a, size_t *size); -int grib_get_string_length(grib_handle *h, const char *name, size_t *size); -int _grib_get_size(grib_handle *h, grib_accessor *a, size_t *size); -int grib_get_size(grib_handle *h, const char *name, size_t *size); -int grib_get_length(grib_handle *h, const char *name, size_t *length); +int grib_get_string_length(const grib_handle *h, const char *name, size_t *size); +int _grib_get_size(const grib_handle *h, grib_accessor *a, size_t *size); +int grib_get_size(const grib_handle *h, const char *name, size_t *size); +int grib_get_length(const grib_handle *h, const char *name, size_t *length); int grib_get_count(grib_handle *h, const char *name, size_t *size); -int grib_get_offset(grib_handle *h, const char *key, size_t *val); +int grib_get_offset(const grib_handle *h, const char *key, size_t *val); int _grib_get_string_array_internal(grib_handle *h, grib_accessor *a, char **val, size_t buffer_len, size_t *decoded_length); int grib_get_string_array(grib_handle *h, const char *name, char **val, size_t *length); int _grib_get_long_array_internal(grib_handle *h, grib_accessor *a, long *val, size_t buffer_len, size_t *decoded_length); @@ -1386,12 +1386,12 @@ grib_box *grib_box_factory(grib_handle *h, grib_arguments *args); /* grib_box_class_reduced_gaussian.c */ /* grib_nearest.c */ -int grib_nearest_find(grib_nearest *nearest, grib_handle *h, double inlat, double inlon, unsigned long flags, double *outlats, double *outlons, double *values, double *distances, int *indexes, size_t *len); +int grib_nearest_find(grib_nearest *nearest, const grib_handle *h, double inlat, double inlon, unsigned long flags, double *outlats, double *outlons, double *values, double *distances, int *indexes, size_t *len); int grib_nearest_init(grib_nearest *i, grib_handle *h, grib_arguments *args); int grib_nearest_delete(grib_nearest *i); void grib_binary_search(double xx[], const unsigned long n, double x, int *ju, int *jl); double grib_nearest_distance(double radius, double lon1, double lat1, double lon2, double lat2); -int grib_nearest_find_multiple(grib_handle *h, int is_lsm, double *inlats, double *inlons, long npoints, double *outlats, double *outlons, double *values, double *distances, int *indexes); +int grib_nearest_find_multiple(const grib_handle *h, int is_lsm, double *inlats, double *inlons, long npoints, double *outlats, double *outlons, double *values, double *distances, int *indexes); /* grib_nearest_class.c */ grib_nearest *grib_nearest_factory(grib_handle *h, grib_arguments *args); @@ -1417,7 +1417,7 @@ grib_nearest *grib_nearest_factory(grib_handle *h, grib_arguments *args); /* grib_iterator_class_lambert_conformal.c */ /* grib_iterator.c */ -int grib_get_data(grib_handle *h, double *lats, double *lons, double *values); +int grib_get_data(const grib_handle *h, double *lats, double *lons, double *values); int grib_iterator_next(grib_iterator *i, double *lat, double *lon, double *value); int grib_iterator_has_next(grib_iterator *i); int grib_iterator_previous(grib_iterator *i, double *lat, double *lon, double *value); diff --git a/src/grib_dumper.c b/src/grib_dumper.c index 4839f9acf..ebe36bef1 100644 --- a/src/grib_dumper.c +++ b/src/grib_dumper.c @@ -211,8 +211,9 @@ void grib_dump_values(grib_dumper* d,grib_accessor* a) Assert(0); } -void grib_dump_header(grib_dumper* d,grib_handle* h) +void grib_dump_header(grib_dumper* d, const grib_handle* ch) { + grib_handle* h = (grib_handle*)ch; grib_dumper_class *c = d->cclass; while(c) { @@ -225,8 +226,9 @@ void grib_dump_header(grib_dumper* d,grib_handle* h) } } -void grib_dump_footer(grib_dumper* d,grib_handle* h) +void grib_dump_footer(grib_dumper* d, const grib_handle* ch) { + grib_handle* h = (grib_handle*)ch; grib_dumper_class *c = d->cclass; while(c) { diff --git a/src/grib_dumper_class.c b/src/grib_dumper_class.c index 02ca5b346..c71754735 100644 --- a/src/grib_dumper_class.c +++ b/src/grib_dumper_class.c @@ -29,7 +29,7 @@ static struct table_entry table[] = #define NUMBER(x) (sizeof(x)/sizeof(x[0])) -grib_dumper* grib_dumper_factory(const char* op, grib_handle* h, FILE* out, unsigned long option_flags,void* arg) +grib_dumper* grib_dumper_factory(const char* op, const grib_handle* h, FILE* out, unsigned long option_flags,void* arg) { int i; for(i = 0; i < NUMBER(table) ; i++) @@ -38,7 +38,7 @@ grib_dumper* grib_dumper_factory(const char* op, grib_handle* h, FILE* out, unsi grib_dumper_class* c = *(table[i].cclass); grib_dumper* d = (grib_dumper*) grib_context_malloc_clear(h->context,c->size); d->depth = 0; - d->handle = h; + d->handle = (grib_handle*)h; d->cclass = c; d->option_flags = option_flags; d->arg = arg; @@ -80,7 +80,7 @@ int grib_print(grib_handle* h, const char* name, grib_dumper *d ){ return GRIB_NOT_FOUND; } -void grib_dump_content(grib_handle* h, FILE* f,const char* mode,unsigned long flags,void *data) +void grib_dump_content(const grib_handle* h, FILE* f,const char* mode,unsigned long flags,void *data) { grib_dumper *dumper; dumper = grib_dumper_factory(mode?mode:"serialize", h, f, flags, data); diff --git a/src/grib_handle.c b/src/grib_handle.c index 44296ec99..c13a1ec6b 100644 --- a/src/grib_handle.c +++ b/src/grib_handle.c @@ -295,7 +295,7 @@ grib_handle* codes_bufr_handle_new_from_samples ( grib_context* c, const char* n return g; } -int grib_write_message(grib_handle* h,const char* file,const char* mode) +int grib_write_message(const grib_handle* h,const char* file,const char* mode) { FILE* fh=0; int err; @@ -324,9 +324,9 @@ int grib_write_message(grib_handle* h,const char* file,const char* mode) return 0; } -grib_handle* grib_handle_clone ( grib_handle* h ) +grib_handle* grib_handle_clone(const grib_handle* h) { - grib_handle* result = grib_handle_new_from_message_copy ( h->context, h->buffer->data, h->buffer->ulength ); + grib_handle* result = grib_handle_new_from_message_copy(h->context, h->buffer->data, h->buffer->ulength ); result->product_kind = h->product_kind; return result; } @@ -1264,7 +1264,7 @@ int grib_get_partial_message_copy ( grib_handle* h , void* message,size_t *len, return GRIB_SUCCESS; } -int grib_get_message_copy ( grib_handle* h , void* message,size_t *len ) +int grib_get_message_copy(const grib_handle* h, void* message,size_t *len) { if ( !h ) return GRIB_NOT_FOUND; @@ -1278,7 +1278,7 @@ int grib_get_message_copy ( grib_handle* h , void* message,size_t *len ) return GRIB_SUCCESS; } -int grib_get_message_offset ( grib_handle* h,off_t* offset ) +int grib_get_message_offset(const grib_handle* h,off_t* offset) { if (h) *offset=h->offset; else return GRIB_INTERNAL_ERROR; @@ -1286,7 +1286,7 @@ int grib_get_message_offset ( grib_handle* h,off_t* offset ) return 0; } -int codes_get_product_kind(grib_handle* h, ProductKind* product_kind) +int codes_get_product_kind(const grib_handle* h, ProductKind* product_kind) { if (h) { *product_kind = h->product_kind; @@ -1327,20 +1327,22 @@ int codes_check_message_footer(const void* bytes, size_t length, ProductKind pro return GRIB_SUCCESS; } -int grib_get_message_size ( grib_handle* h,size_t* size ) +int grib_get_message_size(const grib_handle* ch,size_t* size) { long totalLength=0; int ret=0; + grib_handle* h = (grib_handle*)ch; *size = h->buffer->ulength; ret=grib_get_long(h,"totalLength",&totalLength); if (!ret) *size=totalLength; return ret; } -int grib_get_message ( grib_handle* h,const void** msg,size_t* size ) +int grib_get_message(const grib_handle* ch, const void** msg, size_t* size) { long totalLength=0; int ret=0; + grib_handle* h = (grib_handle*)ch; *msg = h->buffer->data; *size = h->buffer->ulength; diff --git a/src/grib_iterator.c b/src/grib_iterator.c index 910f6756d..7193ec4c5 100644 --- a/src/grib_iterator.c +++ b/src/grib_iterator.c @@ -44,7 +44,7 @@ static void init_mutex() #endif -int grib_get_data(grib_handle* h,double* lats, double* lons,double* values) +int grib_get_data(const grib_handle* h,double* lats, double* lons,double* values) { int err=0; grib_iterator* iter=NULL; diff --git a/src/grib_nearest.c b/src/grib_nearest.c index 60b5a5b14..3d55a72eb 100644 --- a/src/grib_nearest.c +++ b/src/grib_nearest.c @@ -17,12 +17,13 @@ #include "grib_api_internal.h" int grib_nearest_find( - grib_nearest *nearest, grib_handle* h, + grib_nearest *nearest, const grib_handle* ch, double inlat, double inlon, unsigned long flags, double* outlats,double* outlons, double* values, double* distances, int* indexes, size_t *len) { + grib_handle* h = (grib_handle*)ch; grib_nearest_class *c = NULL; if (!nearest) return GRIB_INVALID_ARGUMENT; c = nearest->cclass; @@ -128,7 +129,7 @@ double grib_nearest_distance(double radius,double lon1, double lat1, double lon2 return radius*acos(a); } -int grib_nearest_find_multiple(grib_handle* h,int is_lsm, +int grib_nearest_find_multiple(const grib_handle* h,int is_lsm, double* inlats,double* inlons,long npoints, double* outlats,double* outlons, double* values,double* distances, int* indexes) diff --git a/src/grib_query.c b/src/grib_query.c index 6c537139a..1d81fc443 100644 --- a/src/grib_query.c +++ b/src/grib_query.c @@ -421,12 +421,13 @@ static void grib_find_same_and_push(grib_accessors_list* al,grib_accessor* a) } } -grib_accessors_list* grib_find_accessors_list(grib_handle* h,const char* name) +grib_accessors_list* grib_find_accessors_list(const grib_handle* ch,const char* name) { char* str=NULL; grib_accessors_list* al=NULL; codes_condition* condition=NULL; grib_accessor* a=NULL; + grib_handle* h = (grib_handle*)ch; if (name[0]=='/') { condition=(codes_condition*)grib_context_malloc_clear(h->context,sizeof(codes_condition)); @@ -475,8 +476,9 @@ static grib_accessor* search_and_cache(grib_handle* h, const char* name,const ch return a; } -static grib_accessor* _grib_find_accessor(grib_handle* h, const char* name) +static grib_accessor* _grib_find_accessor(const grib_handle* ch, const char* name) { + grib_handle* h = (grib_handle*)ch; grib_accessor* a = NULL; char* p = NULL; DebugAssert(name); @@ -523,7 +525,7 @@ char* grib_split_name_attribute(grib_context* c,const char* name,char* attribute return accessor_name; } -grib_accessor* grib_find_accessor(grib_handle* h, const char* name) +grib_accessor* grib_find_accessor(const grib_handle* h, const char* name) { grib_accessor* aret = NULL; Assert(h); diff --git a/src/grib_value.c b/src/grib_value.c index 2b9c34c8e..4b1fdafc9 100644 --- a/src/grib_value.c +++ b/src/grib_value.c @@ -1156,7 +1156,7 @@ int _grib_get_string_length(grib_accessor* a, size_t* size) return GRIB_SUCCESS; } -int grib_get_string_length(grib_handle* h, const char* name,size_t* size) +int grib_get_string_length(const grib_handle* h, const char* name,size_t* size) { grib_accessor* a = NULL; grib_accessors_list* al=NULL; @@ -1175,7 +1175,7 @@ int grib_get_string_length(grib_handle* h, const char* name,size_t* size) } } -int _grib_get_size(grib_handle* h, grib_accessor* a,size_t* size) +int _grib_get_size(const grib_handle* h, grib_accessor* a,size_t* size) { long count=0; int err=0; @@ -1195,8 +1195,9 @@ int _grib_get_size(grib_handle* h, grib_accessor* a,size_t* size) return GRIB_SUCCESS; } -int grib_get_size(grib_handle* h, const char* name,size_t* size) +int grib_get_size(const grib_handle* ch, const char* name,size_t* size) { + grib_handle* h = (grib_handle*)ch; grib_accessor* a =NULL; grib_accessors_list* al=NULL; int ret=0; @@ -1220,7 +1221,7 @@ int grib_get_size(grib_handle* h, const char* name,size_t* size) } } -int grib_get_length(grib_handle* h, const char* name, size_t* length) +int grib_get_length(const grib_handle* h, const char* name, size_t* length) { return grib_get_string_length(h, name, length); } @@ -1238,8 +1239,9 @@ int grib_get_count(grib_handle* h, const char* name,size_t* size) return GRIB_SUCCESS; } -int grib_get_offset(grib_handle* h, const char* key,size_t* val) +int grib_get_offset(const grib_handle* ch, const char* key,size_t* val) { + grib_handle* h = (grib_handle*)ch; grib_accessor* act = grib_find_accessor(h, key); if(act) { *val = (size_t)grib_byte_offset(act); From 06c22655cf23dbf9b40c73a559cd891912b4b8d3 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 3 Oct 2019 15:18:28 +0100 Subject: [PATCH 28/49] ECC-995: C API: Review const-ness of arguments (part 2) --- src/bufr_keys_iterator.c | 5 ++-- src/eccodes.c | 34 +++++++++++++-------------- src/eccodes.h | 34 +++++++++++++-------------- src/grib_api.h | 36 ++++++++++++++--------------- src/grib_api_prototypes.h | 48 +++++++++++++++++++-------------------- src/grib_keys_iterator.c | 12 +++++----- src/grib_value.c | 34 +++++++++++++-------------- 7 files changed, 102 insertions(+), 101 deletions(-) diff --git a/src/bufr_keys_iterator.c b/src/bufr_keys_iterator.c index 781a90cde..f28876f86 100644 --- a/src/bufr_keys_iterator.c +++ b/src/bufr_keys_iterator.c @@ -82,7 +82,7 @@ int codes_bufr_keys_iterator_rewind(bufr_keys_iterator* ki) return GRIB_SUCCESS; } -static int is_ident_key(bufr_keys_iterator* kiter) +static int is_ident_key(const bufr_keys_iterator* kiter) { if (kiter->current->sub_section) return 0; @@ -200,8 +200,9 @@ int codes_bufr_keys_iterator_next(bufr_keys_iterator* kiter) /* The return value is constructed so we allocate memory for it. */ /* We free in codes_bufr_keys_iterator_delete() */ -char* codes_bufr_keys_iterator_get_name(bufr_keys_iterator* kiter) +char* codes_bufr_keys_iterator_get_name(const bufr_keys_iterator* ckiter) { + bufr_keys_iterator* kiter = (bufr_keys_iterator*)ckiter; int *r=0; char* ret=0; grib_context* c = kiter->handle->context; diff --git a/src/eccodes.c b/src/eccodes.c index 818d6222d..afc558dff 100644 --- a/src/eccodes.c +++ b/src/eccodes.c @@ -57,7 +57,7 @@ const char* codes_get_type_name(int type) { return grib_get_type_name(type); } -int codes_get_native_type(grib_handle* h, const char* name,int* type) +int codes_get_native_type(const grib_handle* h, const char* name,int* type) { return grib_get_native_type(h,name,type); } @@ -309,11 +309,11 @@ int codes_grib_nearest_delete(grib_nearest *nearest) /* get/set keys */ /******************************************************************************/ -int codes_is_missing(grib_handle* h, const char* key, int* err) +int codes_is_missing(const grib_handle* h, const char* key, int* err) { return grib_is_missing(h,key,err); } -int codes_is_defined(grib_handle* h, const char* key) +int codes_is_defined(const grib_handle* h, const char* key) { return grib_is_defined(h,key); } @@ -329,39 +329,39 @@ int codes_get_length(const grib_handle* h, const char* key,size_t *length) { return grib_get_length(h,key,length); } -int codes_get_long(grib_handle* h, const char* key, long* value) +int codes_get_long(const grib_handle* h, const char* key, long* value) { return grib_get_long(h,key,value); } -int codes_get_double(grib_handle* h, const char* key, double* value) +int codes_get_double(const grib_handle* h, const char* key, double* value) { return grib_get_double(h,key,value); } -int codes_get_double_element(grib_handle* h, const char* key, int i, double* value) +int codes_get_double_element(const grib_handle* h, const char* key, int i, double* value) { return grib_get_double_element(h,key,i,value); } -int codes_get_double_elements(grib_handle* h, const char* key, int* i, long size,double* value) +int codes_get_double_elements(const grib_handle* h, const char* key, int* i, long size,double* value) { return grib_get_double_elements(h,key,i,size,value); } -int codes_get_string(grib_handle* h, const char* key, char* mesg, size_t *length) +int codes_get_string(const grib_handle* h, const char* key, char* mesg, size_t *length) { return grib_get_string(h,key,mesg,length); } -int codes_get_string_array(grib_handle* h, const char* key, char** vals, size_t *length) +int codes_get_string_array(const grib_handle* h, const char* key, char** vals, size_t *length) { return grib_get_string_array(h,key,vals,length); } -int codes_get_bytes(grib_handle* h, const char* key, unsigned char* bytes, size_t *length) +int codes_get_bytes(const grib_handle* h, const char* key, unsigned char* bytes, size_t *length) { return grib_get_bytes(h,key,bytes,length); } -int codes_get_double_array(grib_handle* h, const char* key, double* vals, size_t *length) +int codes_get_double_array(const grib_handle* h, const char* key, double* vals, size_t *length) { return grib_get_double_array(h,key,vals,length); } -int codes_get_long_array(grib_handle* h, const char* key, long* vals, size_t *length) +int codes_get_long_array(const grib_handle* h, const char* key, long* vals, size_t *length) { return grib_get_long_array(h,key,vals,length); } @@ -448,7 +448,7 @@ int codes_keys_iterator_next(grib_keys_iterator *kiter) { return grib_keys_iterator_next(kiter); } -const char* codes_keys_iterator_get_name(grib_keys_iterator *kiter) +const char* codes_keys_iterator_get_name(const grib_keys_iterator *kiter) { return grib_keys_iterator_get_name(kiter); } @@ -464,19 +464,19 @@ int codes_keys_iterator_set_flags(grib_keys_iterator *kiter,unsigned long flags) { return grib_keys_iterator_set_flags(kiter,flags); } -int codes_keys_iterator_get_long(grib_keys_iterator *kiter, long *v, size_t *len) +int codes_keys_iterator_get_long(const grib_keys_iterator *kiter, long *v, size_t *len) { return grib_keys_iterator_get_long(kiter,v,len); } -int codes_keys_iterator_get_double(grib_keys_iterator *kiter, double *v, size_t *len) +int codes_keys_iterator_get_double(const grib_keys_iterator *kiter, double *v, size_t *len) { return grib_keys_iterator_get_double(kiter,v,len); } -int codes_keys_iterator_get_string(grib_keys_iterator *kiter, char *v, size_t *len) +int codes_keys_iterator_get_string(const grib_keys_iterator *kiter, char *v, size_t *len) { return grib_keys_iterator_get_string(kiter,v,len); } -int codes_keys_iterator_get_bytes(grib_keys_iterator *kiter, unsigned char *v, size_t *len) +int codes_keys_iterator_get_bytes(const grib_keys_iterator *kiter, unsigned char *v, size_t *len) { return grib_keys_iterator_get_bytes(kiter,v,len); } diff --git a/src/eccodes.h b/src/eccodes.h index 82f910212..485c3b488 100644 --- a/src/eccodes.h +++ b/src/eccodes.h @@ -754,7 +754,7 @@ int codes_get_length(const codes_handle* h, const char* key, size_t *length); * @param value : the address of a long where the data will be retrieved * @return 0 if OK, integer value on error */ -int codes_get_long(codes_handle* h, const char* key, long* value); +int codes_get_long(const codes_handle* h, const char* key, long* value); /** * Get a double value from a key, if several keys of the same name are present, the last one is returned @@ -765,7 +765,7 @@ int codes_get_long(codes_handle* h, const char* key, long* value); * @param value : the address of a double where the data will be retrieved * @return 0 if OK, integer value on error */ -int codes_get_double(codes_handle* h, const char* key, double* value); +int codes_get_double(const codes_handle* h, const char* key, double* value); /** * Get as double the i-th element of the "key" array @@ -776,7 +776,7 @@ int codes_get_double(codes_handle* h, const char* key, double* value); * @param value : the address of a double where the data will be retrieved * @return 0 if OK, integer value on error */ -int codes_get_double_element(codes_handle* h, const char* key, int i, double* value); +int codes_get_double_element(const codes_handle* h, const char* key, int i, double* value); /** * Get as double array the elements of the "key" array whose indexes are listed in the input array i @@ -788,7 +788,7 @@ int codes_get_double_element(codes_handle* h, const char* key, int i, double* va * @param value : the double array for the data values * @return 0 if OK, integer value on error */ -int codes_get_double_elements(codes_handle* h, const char* key, int* i, long size, double* value); +int codes_get_double_elements(const codes_handle* h, const char* key, int* i, long size, double* value); /** * Get a string value from a key, if several keys of the same name are present, the last one is returned @@ -800,7 +800,7 @@ int codes_get_double_elements(codes_handle* h, const char* key, int* i, long siz * @param length : the address of a size_t that contains allocated length of the string on input, and that contains the actual length of the string on output * @return 0 if OK, integer value on error */ -int codes_get_string(codes_handle* h, const char* key, char* mesg, size_t *length); +int codes_get_string(const codes_handle* h, const char* key, char* mesg, size_t *length); /** * Get string array values from a key. If several keys of the same name are present, the last one is returned @@ -812,7 +812,7 @@ int codes_get_string(codes_handle* h, const char* key, char* mesg, size_t *lengt * @param length : the address of a size_t that contains allocated length of the array on input, and that contains the actual length of the array on output * @return 0 if OK, integer value on error */ -int codes_get_string_array(codes_handle* h, const char* key, char** vals, size_t *length); +int codes_get_string_array(const codes_handle* h, const char* key, char** vals, size_t *length); /** * Get raw bytes values from a key. If several keys of the same name are present, the last one is returned @@ -824,7 +824,7 @@ int codes_get_string_array(codes_handle* h, const char* key, char** vals, size_t * @param length : the address of a size_t that contains allocated length of the byte array on input, and that contains the actual length of the byte array on output * @return 0 if OK, integer value on error */ -int codes_get_bytes(codes_handle* h, const char* key, unsigned char* bytes, size_t *length); +int codes_get_bytes(const codes_handle* h, const char* key, unsigned char* bytes, size_t *length); /** * Get double array values from a key. If several keys of the same name are present, the last one is returned @@ -836,7 +836,7 @@ int codes_get_bytes(codes_handle* h, const char* key, unsigned char* bytes, size * @param length : the address of a size_t that contains allocated length of the double array on input, and that contains the actual length of the double array on output * @return 0 if OK, integer value on error */ -int codes_get_double_array(codes_handle* h, const char* key, double* vals, size_t *length); +int codes_get_double_array(const codes_handle* h, const char* key, double* vals, size_t *length); /** * Get long array values from a key. If several keys of the same name are present, the last one is returned @@ -848,7 +848,7 @@ int codes_get_double_array(codes_handle* h, const char* key, double* vals, size_ * @param length : the address of a size_t that contains allocated length of the long array on input, and that contains the actual length of the long array on output * @return 0 if OK, integer value on error */ -int codes_get_long_array(codes_handle* h, const char* key, long* vals, size_t *length); +int codes_get_long_array(const codes_handle* h, const char* key, long* vals, size_t *length); /* setting data */ @@ -1155,7 +1155,7 @@ int codes_keys_iterator_next(codes_keys_iterator *kiter); * @param kiter : valid codes_keys_iterator * @return key name */ -const char* codes_keys_iterator_get_name(codes_keys_iterator *kiter); +const char* codes_keys_iterator_get_name(const codes_keys_iterator *kiter); /*! Delete the keys iterator. * @param kiter : valid codes_keys_iterator @@ -1171,10 +1171,10 @@ int codes_keys_iterator_rewind(codes_keys_iterator* kiter); int codes_keys_iterator_set_flags(codes_keys_iterator *kiter, unsigned long flags); -int codes_keys_iterator_get_long(codes_keys_iterator *kiter, long *v, size_t *len); -int codes_keys_iterator_get_double(codes_keys_iterator *kiter, double *v, size_t *len); -int codes_keys_iterator_get_string(codes_keys_iterator *kiter, char *v, size_t *len); -int codes_keys_iterator_get_bytes(codes_keys_iterator *kiter, unsigned char *v, size_t *len); +int codes_keys_iterator_get_long(const codes_keys_iterator *kiter, long *v, size_t *len); +int codes_keys_iterator_get_double(const codes_keys_iterator *kiter, double *v, size_t *len); +int codes_keys_iterator_get_string(const codes_keys_iterator *kiter, char *v, size_t *len); +int codes_keys_iterator_get_bytes(const codes_keys_iterator *kiter, unsigned char *v, size_t *len); /* @} */ @@ -1189,7 +1189,7 @@ void codes_update_sections_lengths(codes_handle* h); const char* codes_get_error_message(int code); const char* codes_get_type_name(int type); -int codes_get_native_type(codes_handle* h, const char* name, int* type); +int codes_get_native_type(const codes_handle* h, const char* name, int* type); void codes_check(const char* call, const char* file, int line, int e, const char* msg); #define CODES_CHECK(a, msg) GRIB_CHECK(a, msg) @@ -1199,8 +1199,8 @@ void codes_check(const char* call, const char* file, int line, int e, const char int codes_set_values(codes_handle* h, codes_values* codes_values, size_t arg_count); codes_handle* codes_handle_new_from_partial_message_copy(codes_context* c, const void* data, size_t size); codes_handle* codes_handle_new_from_partial_message(codes_context* c, const void* data, size_t buflen); -int codes_is_missing(codes_handle* h, const char* key, int* err); -int codes_is_defined(codes_handle* h, const char* key); +int codes_is_missing(const codes_handle* h, const char* key, int* err); +int codes_is_defined(const codes_handle* h, const char* key); int codes_set_missing(codes_handle* h, const char* key); /* The truncation is the Gaussian number (or order) */ int codes_get_gaussian_latitudes(long truncation, double* latitudes); diff --git a/src/grib_api.h b/src/grib_api.h index fb89e7c1f..3d35d360f 100644 --- a/src/grib_api.h +++ b/src/grib_api.h @@ -767,7 +767,7 @@ int grib_get_length(const grib_handle* h, const char* key,size_t *length); * @param value : the address of a long where the data will be retrieved * @return 0 if OK, integer value on error */ -int grib_get_long(grib_handle* h, const char* key, long* value); +int grib_get_long(const grib_handle* h, const char* key, long* value); /** * Get a double value from a key, if several keys of the same name are present, the last one is returned @@ -778,7 +778,7 @@ int grib_get_long(grib_handle* h, const char* key, long* value); * @param value : the address of a double where the data will be retrieved * @return 0 if OK, integer value on error */ -int grib_get_double(grib_handle* h, const char* key, double* value); +int grib_get_double(const grib_handle* h, const char* key, double* value); /** * Get as double the i-th element of the "key" array @@ -789,7 +789,7 @@ int grib_get_double(grib_handle* h, const char* key, double* value); * @param value : the address of a double where the data will be retrieved * @return 0 if OK, integer value on error */ -int grib_get_double_element(grib_handle* h, const char* key, int i, double* value); +int grib_get_double_element(const grib_handle* h, const char* key, int i, double* value); /** * Get as double array the elements of the "key" array whose indexes are listed in the input array i @@ -801,7 +801,7 @@ int grib_get_double_element(grib_handle* h, const char* key, int i, double* valu * @param value : the double array for the data values * @return 0 if OK, integer value on error */ -int grib_get_double_elements(grib_handle* h, const char* key, int* i, long size, double* value); +int grib_get_double_elements(const grib_handle* h, const char* key, int* i, long size, double* value); /** * Get a string value from a key, if several keys of the same name are present, the last one is returned @@ -813,7 +813,7 @@ int grib_get_double_elements(grib_handle* h, const char* key, int* i, long size, * @param length : the address of a size_t that contains allocated length of the string on input, and that contains the actual length of the string on output * @return 0 if OK, integer value on error */ -int grib_get_string(grib_handle* h, const char* key, char* mesg, size_t *length); +int grib_get_string(const grib_handle* h, const char* key, char* mesg, size_t *length); /** * Get string array values from a key. If several keys of the same name are present, the last one is returned @@ -825,7 +825,7 @@ int grib_get_string(grib_handle* h, const char* key, char* mesg, size_t *length) * @param length : the address of a size_t that contains allocated length of the array on input, and that contains the actual length of the array on output * @return 0 if OK, integer value on error */ -int grib_get_string_array(grib_handle* h, const char* key, char** vals, size_t *length); +int grib_get_string_array(const grib_handle* h, const char* key, char** vals, size_t *length); /** * Get raw bytes values from a key. If several keys of the same name are present, the last one is returned @@ -837,7 +837,7 @@ int grib_get_string_array(grib_handle* h, const char* key, char** vals, size_t * * @param length : the address of a size_t that contains allocated length of the byte array on input, and that contains the actual length of the byte array on output * @return 0 if OK, integer value on error */ -int grib_get_bytes(grib_handle* h, const char* key, unsigned char* bytes, size_t *length); +int grib_get_bytes(const grib_handle* h, const char* key, unsigned char* bytes, size_t *length); /** * Get double array values from a key. If several keys of the same name are present, the last one is returned * @see grib_set_double_array @@ -848,7 +848,7 @@ int grib_get_bytes(grib_handle* h, const char* key, unsigned char* bytes, size_ * @param length : the address of a size_t that contains allocated length of the double array on input, and that contains the actual length of the double array on output * @return 0 if OK, integer value on error */ -int grib_get_double_array(grib_handle* h, const char* key, double* vals, size_t *length); +int grib_get_double_array(const grib_handle* h, const char* key, double* vals, size_t *length); /** * Get long array values from a key. If several keys of the same name are present, the last one is returned @@ -860,7 +860,7 @@ int grib_get_double_array(grib_handle* h, const char* key, double* vals, size_t * @param length : the address of a size_t that contains allocated length of the long array on input, and that contains the actual length of the long array on output * @return 0 if OK, integer value on error */ -int grib_get_long_array(grib_handle* h, const char* key, long* vals, size_t *length); +int grib_get_long_array(const grib_handle* h, const char* key, long* vals, size_t *length); /* setting data */ @@ -1288,8 +1288,8 @@ int codes_bufr_keys_iterator_next(bufr_keys_iterator* kiter); * @param kiter : valid grib_keys_iterator * @return key name */ -const char* grib_keys_iterator_get_name(grib_keys_iterator *kiter); -char* codes_bufr_keys_iterator_get_name(bufr_keys_iterator* kiter); +const char* grib_keys_iterator_get_name(const grib_keys_iterator *kiter); +char* codes_bufr_keys_iterator_get_name(const bufr_keys_iterator* kiter); /*! Delete the iterator. * @param kiter : valid grib_keys_iterator @@ -1307,10 +1307,10 @@ int codes_bufr_keys_iterator_rewind(bufr_keys_iterator* kiter); int grib_keys_iterator_set_flags(grib_keys_iterator *kiter,unsigned long flags); -int grib_keys_iterator_get_long(grib_keys_iterator *kiter, long *v, size_t *len); -int grib_keys_iterator_get_double(grib_keys_iterator *kiter, double *v, size_t *len); -int grib_keys_iterator_get_string(grib_keys_iterator *kiter, char *v, size_t *len); -int grib_keys_iterator_get_bytes(grib_keys_iterator *kiter, unsigned char *v, size_t *len); +int grib_keys_iterator_get_long(const grib_keys_iterator *kiter, long *v, size_t *len); +int grib_keys_iterator_get_double(const grib_keys_iterator *kiter, double *v, size_t *len); +int grib_keys_iterator_get_string(const grib_keys_iterator *kiter, char *v, size_t *len); +int grib_keys_iterator_get_bytes(const grib_keys_iterator *kiter, unsigned char *v, size_t *len); int codes_copy_key(grib_handle* h1,grib_handle* h2,const char* key,int type); /* @} */ @@ -1326,7 +1326,7 @@ void grib_update_sections_lengths(grib_handle* h); const char* grib_get_error_message(int code); const char* grib_get_type_name(int type); -int grib_get_native_type(grib_handle* h, const char* name,int* type); +int grib_get_native_type(const grib_handle* h, const char* name,int* type); void grib_check(const char* call,const char* file,int line,int e,const char* msg); #define GRIB_CHECK(a,msg) grib_check(#a,__FILE__,__LINE__,a,msg) @@ -1336,8 +1336,8 @@ void grib_check(const char* call,const char* file,int line,int e,const char* ms int grib_set_values(grib_handle* h,grib_values* grib_values , size_t arg_count); grib_handle* grib_handle_new_from_partial_message_copy(grib_context* c, const void* data, size_t size); grib_handle* grib_handle_new_from_partial_message(grib_context* c, const void* data, size_t buflen); -int grib_is_missing(grib_handle* h, const char* key, int* err); -int grib_is_defined(grib_handle* h, const char* key); +int grib_is_missing(const grib_handle* h, const char* key, int* err); +int grib_is_defined(const grib_handle* h, const char* key); int grib_set_missing(grib_handle* h, const char* key); /* The truncation is the Gaussian number (or order) */ int grib_get_gaussian_latitudes(long truncation,double* latitudes); diff --git a/src/grib_api_prototypes.h b/src/grib_api_prototypes.h index 6f30f7ec3..47f7b02c1 100644 --- a/src/grib_api_prototypes.h +++ b/src/grib_api_prototypes.h @@ -1183,21 +1183,21 @@ grib_keys_iterator *grib_keys_iterator_new(grib_handle *h, unsigned long filter_ int grib_keys_iterator_set_flags(grib_keys_iterator *ki, unsigned long flags); int grib_keys_iterator_rewind(grib_keys_iterator *ki); int grib_keys_iterator_next(grib_keys_iterator *kiter); -const char *grib_keys_iterator_get_name(grib_keys_iterator *kiter); +const char *grib_keys_iterator_get_name(const grib_keys_iterator *kiter); grib_accessor *grib_keys_iterator_get_accessor(grib_keys_iterator *kiter); int grib_keys_iterator_delete(grib_keys_iterator *kiter); -int grib_keys_iterator_get_long(grib_keys_iterator *kiter, long *v, size_t *len); -int grib_keys_iterator_get_double(grib_keys_iterator *kiter, double *v, size_t *len); -int grib_keys_iterator_get_string(grib_keys_iterator *kiter, char *v, size_t *len); -int grib_keys_iterator_get_bytes(grib_keys_iterator *kiter, unsigned char *v, size_t *len); -int grib_keys_iterator_get_native_type(grib_keys_iterator *kiter); +int grib_keys_iterator_get_long(const grib_keys_iterator *kiter, long *v, size_t *len); +int grib_keys_iterator_get_double(const grib_keys_iterator *kiter, double *v, size_t *len); +int grib_keys_iterator_get_string(const grib_keys_iterator *kiter, char *v, size_t *len); +int grib_keys_iterator_get_bytes(const grib_keys_iterator *kiter, unsigned char *v, size_t *len); +int grib_keys_iterator_get_native_type(const grib_keys_iterator *kiter); /* bufr_keys_iterator.c */ bufr_keys_iterator *codes_bufr_keys_iterator_new(grib_handle *h, unsigned long filter_flags); bufr_keys_iterator *codes_bufr_data_section_keys_iterator_new(grib_handle *h); int codes_bufr_keys_iterator_rewind(bufr_keys_iterator *ki); int codes_bufr_keys_iterator_next(bufr_keys_iterator *kiter); -char *codes_bufr_keys_iterator_get_name(bufr_keys_iterator *kiter); +char *codes_bufr_keys_iterator_get_name(const bufr_keys_iterator *kiter); grib_accessor *codes_bufr_keys_iterator_get_accessor(bufr_keys_iterator *kiter); int codes_bufr_keys_iterator_delete(bufr_keys_iterator *kiter); @@ -1267,8 +1267,8 @@ int grib_is_missing_long(grib_accessor *a, long x); int grib_is_missing_double(grib_accessor *a, double x); int grib_is_missing_string(grib_accessor *a, unsigned char *x, size_t len); int grib_accessor_is_missing(grib_accessor *a, int *err); -int grib_is_missing(grib_handle *h, const char *name, int *err); -int grib_is_defined(grib_handle *h, const char *name); +int grib_is_missing(const grib_handle *h, const char *name, int *err); +int grib_is_defined(const grib_handle *h, const char *name); int grib_set_flag(grib_handle *h, const char *name, unsigned long flag); int grib_set_double_array_internal(grib_handle *h, const char *name, const double *val, size_t length); int grib_set_force_double_array(grib_handle *h, const char *name, const double *val, size_t length); @@ -1278,22 +1278,22 @@ int grib_set_long_array(grib_handle *h, const char *name, const long *val, size_ int grib_get_long_internal(grib_handle *h, const char *name, long *val); int grib_is_in_dump(grib_handle *h, const char *name); int grib_attributes_count(grib_accessor *a, size_t *size); -int grib_get_long(grib_handle *h, const char *name, long *val); +int grib_get_long(const grib_handle *h, const char *name, long *val); int grib_get_double_internal(grib_handle *h, const char *name, double *val); -int grib_get_double(grib_handle *h, const char *name, double *val); +int grib_get_double(const grib_handle *h, const char *name, double *val); int grib_get_double_element_internal(grib_handle *h, const char *name, int i, double *val); -int grib_get_double_element(grib_handle *h, const char *name, int i, double *val); +int grib_get_double_element(const grib_handle *h, const char *name, int i, double *val); int grib_points_get_values(grib_handle *h, grib_points *points, double *val); -int grib_get_double_elements(grib_handle *h, const char *name, int *index_array, long len, double *val_array); +int grib_get_double_elements(const grib_handle *h, const char *name, int *index_array, long len, double *val_array); int grib_get_string_internal(grib_handle *h, const char *name, char *val, size_t *length); -int grib_get_string(grib_handle *h, const char *name, char *val, size_t *length); -int grib_get_bytes_internal(grib_handle *h, const char *name, unsigned char *val, size_t *length); -int grib_get_bytes(grib_handle *h, const char *name, unsigned char *val, size_t *length); -int grib_get_native_type(grib_handle *h, const char *name, int *type); +int grib_get_string(const grib_handle *h, const char *name, char *val, size_t *length); +int grib_get_bytes_internal(const grib_handle *h, const char *name, unsigned char *val, size_t *length); +int grib_get_bytes(const grib_handle *h, const char *name, unsigned char *val, size_t *length); +int grib_get_native_type(const grib_handle *h, const char *name, int *type); const char *grib_get_accessor_class_name(grib_handle *h, const char *name); -int _grib_get_double_array_internal(grib_handle *h, grib_accessor *a, double *val, size_t buffer_len, size_t *decoded_length); -int grib_get_double_array_internal(grib_handle *h, const char *name, double *val, size_t *length); -int grib_get_double_array(grib_handle *h, const char *name, double *val, size_t *length); +int _grib_get_double_array_internal(const grib_handle *h, grib_accessor *a, double *val, size_t buffer_len, size_t *decoded_length); +int grib_get_double_array_internal(const grib_handle *h, const char *name, double *val, size_t *length); +int grib_get_double_array(const grib_handle *h, const char *name, double *val, size_t *length); int _grib_get_string_length(grib_accessor *a, size_t *size); int grib_get_string_length(const grib_handle *h, const char *name, size_t *size); int _grib_get_size(const grib_handle *h, grib_accessor *a, size_t *size); @@ -1301,11 +1301,11 @@ int grib_get_size(const grib_handle *h, const char *name, size_t *size); int grib_get_length(const grib_handle *h, const char *name, size_t *length); int grib_get_count(grib_handle *h, const char *name, size_t *size); int grib_get_offset(const grib_handle *h, const char *key, size_t *val); -int _grib_get_string_array_internal(grib_handle *h, grib_accessor *a, char **val, size_t buffer_len, size_t *decoded_length); -int grib_get_string_array(grib_handle *h, const char *name, char **val, size_t *length); -int _grib_get_long_array_internal(grib_handle *h, grib_accessor *a, long *val, size_t buffer_len, size_t *decoded_length); +int _grib_get_string_array_internal(const grib_handle *h, grib_accessor *a, char **val, size_t buffer_len, size_t *decoded_length); +int grib_get_string_array(const grib_handle *h, const char *name, char **val, size_t *length); +int _grib_get_long_array_internal(const grib_handle *h, grib_accessor *a, long *val, size_t buffer_len, size_t *decoded_length); int grib_get_long_array_internal(grib_handle *h, const char *name, long *val, size_t *length); -int grib_get_long_array(grib_handle *h, const char *name, long *val, size_t *length); +int grib_get_long_array(const grib_handle *h, const char *name, long *val, size_t *length); grib_key_value_list *grib_key_value_list_clone(grib_context *c, grib_key_value_list *list); void grib_key_value_list_delete(grib_context *c, grib_key_value_list *kvl); int grib_get_key_value_list(grib_handle *h, grib_key_value_list *list); diff --git a/src/grib_keys_iterator.c b/src/grib_keys_iterator.c index 17e65c23f..0f87a58b8 100644 --- a/src/grib_keys_iterator.c +++ b/src/grib_keys_iterator.c @@ -168,7 +168,7 @@ int grib_keys_iterator_next(grib_keys_iterator* kiter) return kiter->current != NULL; } -const char* grib_keys_iterator_get_name(grib_keys_iterator* kiter) +const char* grib_keys_iterator_get_name(const grib_keys_iterator* kiter) { /* if(kiter->name_space) */ Assert(kiter->current); @@ -192,27 +192,27 @@ int grib_keys_iterator_delete( grib_keys_iterator* kiter) return 0; } -int grib_keys_iterator_get_long(grib_keys_iterator* kiter,long* v,size_t* len) +int grib_keys_iterator_get_long(const grib_keys_iterator* kiter, long* v, size_t* len) { return grib_unpack_long( kiter->current,v,len); } -int grib_keys_iterator_get_double(grib_keys_iterator* kiter,double* v,size_t* len) +int grib_keys_iterator_get_double(const grib_keys_iterator* kiter,double* v,size_t* len) { return grib_unpack_double( kiter->current,v,len); } -int grib_keys_iterator_get_string(grib_keys_iterator* kiter,char* v,size_t* len) +int grib_keys_iterator_get_string(const grib_keys_iterator* kiter,char* v,size_t* len) { return grib_unpack_string( kiter->current,v,len); } -int grib_keys_iterator_get_bytes(grib_keys_iterator* kiter,unsigned char* v,size_t* len) +int grib_keys_iterator_get_bytes(const grib_keys_iterator* kiter,unsigned char* v,size_t* len) { return grib_unpack_bytes( kiter->current,v,len); } -int grib_keys_iterator_get_native_type(grib_keys_iterator* kiter) +int grib_keys_iterator_get_native_type(const grib_keys_iterator* kiter) { return grib_accessor_get_native_type(kiter->current); } diff --git a/src/grib_value.c b/src/grib_value.c index 4b1fdafc9..6848dfb3b 100644 --- a/src/grib_value.c +++ b/src/grib_value.c @@ -586,14 +586,14 @@ int grib_accessor_is_missing(grib_accessor* a,int* err) } } -int grib_is_missing(grib_handle* h, const char* name,int* err) +int grib_is_missing(const grib_handle* h, const char* name,int* err) { grib_accessor* a = grib_find_accessor(h, name); return grib_accessor_is_missing(a,err); } /* Return true if the given key exists (is defined) in our grib message */ -int grib_is_defined(grib_handle* h, const char* name) +int grib_is_defined(const grib_handle* h, const char* name) { grib_accessor* a = grib_find_accessor(h, name); return (a ? 1 : 0); @@ -868,7 +868,7 @@ int grib_attributes_count(grib_accessor* a, size_t* size) return GRIB_NOT_FOUND; } -int grib_get_long(grib_handle* h, const char* name, long* val) +int grib_get_long(const grib_handle* h, const char* name, long* val) { size_t length = 1; grib_accessor* a = NULL; @@ -900,7 +900,7 @@ int grib_get_double_internal(grib_handle* h, const char* name, double* val) return ret; } -int grib_get_double(grib_handle* h, const char* name, double* val) +int grib_get_double(const grib_handle* h, const char* name, double* val) { size_t length = 1; grib_accessor* a = NULL; @@ -932,7 +932,7 @@ int grib_get_double_element_internal(grib_handle* h, const char* name, int i,dou return ret; } -int grib_get_double_element(grib_handle* h, const char* name, int i, double* val) +int grib_get_double_element(const grib_handle* h, const char* name, int i, double* val) { grib_accessor* act = grib_find_accessor(h, name); @@ -957,7 +957,7 @@ int grib_points_get_values(grib_handle* h, grib_points* points, double* val) return GRIB_SUCCESS; } -int grib_get_double_elements(grib_handle* h, const char* name, int* index_array, long len, double* val_array) +int grib_get_double_elements(const grib_handle* h, const char* name, int* index_array, long len, double* val_array) { double* values=0; int err=0; @@ -1016,7 +1016,7 @@ int grib_get_string_internal(grib_handle* h, const char* name, char* val, size_t return ret; } -int grib_get_string(grib_handle* h, const char* name, char* val, size_t *length) +int grib_get_string(const grib_handle* h, const char* name, char* val, size_t *length) { grib_accessor* a = NULL; grib_accessors_list* al=NULL; @@ -1035,7 +1035,7 @@ int grib_get_string(grib_handle* h, const char* name, char* val, size_t *length) } } -int grib_get_bytes_internal(grib_handle* h, const char* name, unsigned char* val, size_t *length) +int grib_get_bytes_internal(const grib_handle* h, const char* name, unsigned char* val, size_t *length) { int ret = grib_get_bytes(h,name,val,length); @@ -1047,7 +1047,7 @@ int grib_get_bytes_internal(grib_handle* h, const char* name, unsigned char* val return ret; } -int grib_get_bytes(grib_handle* h, const char* name, unsigned char* val, size_t *length) +int grib_get_bytes(const grib_handle* h, const char* name, unsigned char* val, size_t *length) { int err=0; grib_accessor* act = grib_find_accessor(h, name); @@ -1057,7 +1057,7 @@ int grib_get_bytes(grib_handle* h, const char* name, unsigned char* val, size_t return err; } -int grib_get_native_type(grib_handle* h, const char* name,int* type) +int grib_get_native_type(const grib_handle* h, const char* name,int* type) { grib_accessors_list* al=NULL; grib_accessor* a =NULL; @@ -1085,7 +1085,7 @@ const char* grib_get_accessor_class_name(grib_handle* h, const char* name) return act?act->cclass->name:NULL; } -int _grib_get_double_array_internal(grib_handle* h,grib_accessor* a,double* val, size_t buffer_len,size_t *decoded_length) +int _grib_get_double_array_internal(const grib_handle* h,grib_accessor* a,double* val, size_t buffer_len,size_t *decoded_length) { if(a) { int err = _grib_get_double_array_internal(h,a->same,val,buffer_len,decoded_length); @@ -1104,7 +1104,7 @@ int _grib_get_double_array_internal(grib_handle* h,grib_accessor* a,double* val, } } -int grib_get_double_array_internal(grib_handle* h, const char* name, double* val, size_t *length) +int grib_get_double_array_internal(const grib_handle* h, const char* name, double* val, size_t *length) { int ret = grib_get_double_array(h,name,val,length); @@ -1116,7 +1116,7 @@ int grib_get_double_array_internal(grib_handle* h, const char* name, double* val return ret; } -int grib_get_double_array(grib_handle* h, const char* name, double* val, size_t *length) +int grib_get_double_array(const grib_handle* h, const char* name, double* val, size_t *length) { size_t len = *length; grib_accessor* a = NULL; @@ -1250,7 +1250,7 @@ int grib_get_offset(const grib_handle* ch, const char* key,size_t* val) return GRIB_NOT_FOUND; } -int _grib_get_string_array_internal(grib_handle* h,grib_accessor* a,char** val, size_t buffer_len,size_t *decoded_length) +int _grib_get_string_array_internal(const grib_handle* h,grib_accessor* a,char** val, size_t buffer_len,size_t *decoded_length) { if(a) { int err = _grib_get_string_array_internal(h,a->same,val,buffer_len,decoded_length); @@ -1269,7 +1269,7 @@ int _grib_get_string_array_internal(grib_handle* h,grib_accessor* a,char** val, } } -int grib_get_string_array(grib_handle* h, const char* name, char** val, size_t *length) +int grib_get_string_array(const grib_handle* h, const char* name, char** val, size_t *length) { size_t len = *length; grib_accessor* a = NULL; @@ -1294,7 +1294,7 @@ int grib_get_string_array(grib_handle* h, const char* name, char** val, size_t * } } -int _grib_get_long_array_internal(grib_handle* h,grib_accessor* a,long* val, size_t buffer_len,size_t *decoded_length) +int _grib_get_long_array_internal(const grib_handle* h,grib_accessor* a,long* val, size_t buffer_len,size_t *decoded_length) { if(a) { int err = _grib_get_long_array_internal(h,a->same,val,buffer_len,decoded_length); @@ -1325,7 +1325,7 @@ int grib_get_long_array_internal(grib_handle* h, const char* name, long* val, si return ret; } -int grib_get_long_array(grib_handle* h, const char* name, long* val, size_t *length) +int grib_get_long_array(const grib_handle* h, const char* name, long* val, size_t *length) { size_t len = *length; grib_accessor* a = NULL; From 3c68d3acf2c273d127dc06a8b6e8e06086688221 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 3 Oct 2019 17:33:12 +0100 Subject: [PATCH 29/49] ECC-995: C API: Review const-ness of arguments (part 3) --- src/eccodes.c | 8 ++++---- src/eccodes.h | 8 ++++---- src/grib_api.h | 10 +++++----- src/grib_api_prototypes.h | 8 ++++---- src/grib_index.c | 8 ++++---- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/eccodes.c b/src/eccodes.c index afc558dff..d59c3d8a2 100644 --- a/src/eccodes.c +++ b/src/eccodes.c @@ -116,19 +116,19 @@ grib_index* codes_index_read(grib_context* c,const char* filename,int *err) { return grib_index_read(c,filename,err); } -int codes_index_get_size(grib_index* index,const char* key,size_t* size) +int codes_index_get_size(const grib_index* index,const char* key,size_t* size) { return grib_index_get_size(index,key,size); } -int codes_index_get_long(grib_index* index,const char* key,long* values,size_t *size) +int codes_index_get_long(const grib_index* index,const char* key,long* values,size_t *size) { return grib_index_get_long(index,key,values,size); } -int codes_index_get_double(grib_index* index,const char* key, double* values,size_t *size) +int codes_index_get_double(const grib_index* index,const char* key, double* values,size_t *size) { return grib_index_get_double(index,key,values,size); } -int codes_index_get_string(grib_index* index,const char* key,char** values,size_t *size) +int codes_index_get_string(const grib_index* index,const char* key,char** values,size_t *size) { return grib_index_get_string(index,key,values,size); } diff --git a/src/eccodes.h b/src/eccodes.h index 485c3b488..b0cd7c002 100644 --- a/src/eccodes.h +++ b/src/eccodes.h @@ -250,7 +250,7 @@ codes_index* codes_index_read(codes_context* c, const char* filename, int *err); * @param size : number of distinct values of the key in the index * @return 0 if OK, integer value on error */ -int codes_index_get_size(codes_index* index, const char* key, size_t* size); +int codes_index_get_size(const codes_index* index, const char* key, size_t* size); /** * Get the distinct values of the key in argument contained in the index. The key must belong to the index. This function is used when the type of the key was explicitly defined as long or when the native type of the key is long. @@ -262,7 +262,7 @@ int codes_index_get_size(codes_index* index, const char* key, size_t* size); * @param size : size of the values array * @return 0 if OK, integer value on error */ -int codes_index_get_long(codes_index* index, const char* key, long* values, size_t *size); +int codes_index_get_long(const codes_index* index, const char* key, long* values, size_t *size); /** * Get the distinct values of the key in argument contained in the index. The key must belong to the index. This function is used when the type of the key was explicitly defined as double or when the native type of the key is double. @@ -274,7 +274,7 @@ int codes_index_get_long(codes_index* index, const char* key, long* values, size * @param size : size of the values array * @return 0 if OK, integer value on error */ -int codes_index_get_double(codes_index* index, const char* key, double* values, size_t *size); +int codes_index_get_double(const codes_index* index, const char* key, double* values, size_t *size); /** * Get the distinct values of the key in argument contained in the index. The key must belong to the index. This function is used when the type of the key was explicitly defined as string or when the native type of the key is string. @@ -286,7 +286,7 @@ int codes_index_get_double(codes_index* index, const char* key, double* values, * @param size : size of the values array * @return 0 if OK, integer value on error */ -int codes_index_get_string(codes_index* index, const char* key, char** values, size_t *size); +int codes_index_get_string(const codes_index* index, const char* key, char** values, size_t *size); /** diff --git a/src/grib_api.h b/src/grib_api.h index 3d35d360f..f7688bc50 100644 --- a/src/grib_api.h +++ b/src/grib_api.h @@ -292,7 +292,7 @@ grib_index* grib_index_read(grib_context* c,const char* filename,int *err); * @param size : number of distinct values of the key in the index * @return 0 if OK, integer value on error */ -int grib_index_get_size(grib_index* index,const char* key,size_t* size); +int grib_index_get_size(const grib_index* index,const char* key,size_t* size); /** * Get the distinct values of the key in argument contained in the index. The key must belong to the index. This function is used when the type of the key was explicitly defined as long or when the native type of the key is long. @@ -304,7 +304,7 @@ int grib_index_get_size(grib_index* index,const char* key,size_t* size); * @param size : size of the values array * @return 0 if OK, integer value on error */ -int grib_index_get_long(grib_index* index,const char* key, +int grib_index_get_long(const grib_index* index,const char* key, long* values,size_t *size); /** @@ -317,7 +317,7 @@ int grib_index_get_long(grib_index* index,const char* key, * @param size : size of the values array * @return 0 if OK, integer value on error */ -int grib_index_get_double(grib_index* index,const char* key, +int grib_index_get_double(const grib_index* index,const char* key, double* values,size_t *size); /** @@ -330,7 +330,7 @@ int grib_index_get_double(grib_index* index,const char* key, * @param size : size of the values array * @return 0 if OK, integer value on error */ -int grib_index_get_string(grib_index* index,const char* key, +int grib_index_get_string(const grib_index* index,const char* key, char** values,size_t *size); @@ -373,7 +373,7 @@ int grib_index_select_string(grib_index* index,const char* key,char* value); * When no more handles are available from the index a NULL pointer is returned and the err variable is set to GRIB_END_OF_INDEX. * * @param index : an index created from a file. - * @param err : 0 if OK, integer value on error. GRIB_END_OF_INDEX when no more handles are contained in the index. + * @param err : 0 if OK, integer value on error. GRIB_END_OF_INDEX when no more handles are contained in the index. * @return grib handle. */ grib_handle* grib_handle_new_from_index(grib_index* index,int *err); diff --git a/src/grib_api_prototypes.h b/src/grib_api_prototypes.h index 47f7b02c1..07efcdc65 100644 --- a/src/grib_api_prototypes.h +++ b/src/grib_api_prototypes.h @@ -744,10 +744,10 @@ grib_handle *new_message_from_file(int message_type, grib_context *c, FILE *f, i 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); -int grib_index_get_size(grib_index *index, const char *key, size_t *size); -int grib_index_get_string(grib_index *index, const char *key, char **values, size_t *size); -int grib_index_get_long(grib_index *index, const char *key, long *values, size_t *size); -int grib_index_get_double(grib_index *index, const char *key, double *values, size_t *size); +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); diff --git a/src/grib_index.c b/src/grib_index.c index f91aba3a8..d4f1b9fae 100644 --- a/src/grib_index.c +++ b/src/grib_index.c @@ -1278,7 +1278,7 @@ grib_index* grib_index_new_from_file(grib_context* c, char* filename, const char return index; } -int grib_index_get_size(grib_index* index,const char* key,size_t* size) +int grib_index_get_size(const grib_index* index,const char* key,size_t* size) { grib_index_key* k=index->keys; while (k && strcmp(k->name,key)) k=k->next; @@ -1287,7 +1287,7 @@ int grib_index_get_size(grib_index* index,const char* key,size_t* size) return 0; } -int grib_index_get_string(grib_index* index, const char* key, char** values, size_t *size) +int grib_index_get_string(const grib_index* index, const char* key, char** values, size_t *size) { grib_index_key* k=index->keys; grib_string_list* kv; @@ -1308,7 +1308,7 @@ int grib_index_get_string(grib_index* index, const char* key, char** values, siz return GRIB_SUCCESS; } -int grib_index_get_long(grib_index* index, const char* key, long* values, size_t *size) +int grib_index_get_long(const grib_index* index, const char* key, long* values, size_t *size) { grib_index_key* k=index->keys; grib_string_list* kv; @@ -1334,7 +1334,7 @@ int grib_index_get_long(grib_index* index, const char* key, long* values, size_t return GRIB_SUCCESS; } -int grib_index_get_double(grib_index* index,const char* key, double* values,size_t *size) +int grib_index_get_double(const grib_index* index,const char* key, double* values,size_t *size) { grib_index_key* k=index->keys; grib_string_list* kv; From 0b2a635cc4b6d513f286e60cc2c74e2a23ab165b Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Sat, 5 Oct 2019 12:08:55 +0100 Subject: [PATCH 30/49] Bump up version --- .appveyor.yml | 2 +- VERSION.cmake | 2 +- version.sh | 13 +------------ 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 082eea05d..ebf87f9ea 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -2,7 +2,7 @@ # general configuration # #---------------------------------# -version: 2.14.0-{build}-{branch} +version: 2.15.0-{build}-{branch} branches: only: diff --git a/VERSION.cmake b/VERSION.cmake index 7a613a4b5..ef8ca29cf 100644 --- a/VERSION.cmake +++ b/VERSION.cmake @@ -1 +1 @@ -set( ${PROJECT_NAME}_VERSION_STR "2.14.0" ) +set( ${PROJECT_NAME}_VERSION_STR "2.15.0" ) diff --git a/version.sh b/version.sh index bc2104d7d..c70f25f7b 100644 --- a/version.sh +++ b/version.sh @@ -1,20 +1,9 @@ -# Copyright 2005-2019 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. -# -# Package name and versioning information -# -# # Package base name PACKAGE_NAME='eccodes' # Package version ECCODES_MAJOR_VERSION=2 -ECCODES_MINOR_VERSION=14 +ECCODES_MINOR_VERSION=15 ECCODES_REVISION_VERSION=0 ECCODES_CURRENT=1 From a39b9253ed20e5949465cfc2e2066a5310c7cea1 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Sun, 6 Oct 2019 19:09:14 +0100 Subject: [PATCH 31/49] ECC-999: new -10 degree celsius isothermal level (Part 1) --- definitions/grib1/localConcepts/ecmf/cfVarName.def | 2 +- definitions/grib1/localConcepts/ecmf/name.def | 4 ++-- definitions/grib1/localConcepts/ecmf/paramId.def | 2 +- definitions/grib1/localConcepts/ecmf/shortName.def | 2 +- definitions/grib1/localConcepts/ecmf/units.def | 2 +- definitions/grib2/cfVarName.def | 9 +++++++++ definitions/grib2/localConcepts/ecmf/cfVarName.def | 6 ------ definitions/grib2/localConcepts/ecmf/name.def | 6 ------ definitions/grib2/localConcepts/ecmf/paramId.def | 6 ------ definitions/grib2/localConcepts/ecmf/shortName.def | 6 ------ definitions/grib2/localConcepts/ecmf/units.def | 6 ------ definitions/grib2/name.def | 9 +++++++++ definitions/grib2/paramId.def | 9 +++++++++ definitions/grib2/shortName.def | 9 +++++++++ definitions/grib2/units.def | 9 +++++++++ 15 files changed, 51 insertions(+), 36 deletions(-) diff --git a/definitions/grib1/localConcepts/ecmf/cfVarName.def b/definitions/grib1/localConcepts/ecmf/cfVarName.def index 70819a846..e5ec76ee9 100644 --- a/definitions/grib1/localConcepts/ecmf/cfVarName.def +++ b/definitions/grib1/localConcepts/ecmf/cfVarName.def @@ -9534,7 +9534,7 @@ table2Version = 228 ; indicatorOfParameter = 23 ; } -#Zero degree level +#0 degrees C isothermal level (atm) 'deg0l' = { table2Version = 228 ; indicatorOfParameter = 24 ; diff --git a/definitions/grib1/localConcepts/ecmf/name.def b/definitions/grib1/localConcepts/ecmf/name.def index 8bb75fe63..fd9c24459 100644 --- a/definitions/grib1/localConcepts/ecmf/name.def +++ b/definitions/grib1/localConcepts/ecmf/name.def @@ -9534,8 +9534,8 @@ table2Version = 228 ; indicatorOfParameter = 23 ; } -#Zero degree level -'Zero degree level' = { +#0 degrees C isothermal level (atm) +'0 degrees C isothermal level (atm)' = { table2Version = 228 ; indicatorOfParameter = 24 ; } diff --git a/definitions/grib1/localConcepts/ecmf/paramId.def b/definitions/grib1/localConcepts/ecmf/paramId.def index e7e57b9be..7a92a2750 100644 --- a/definitions/grib1/localConcepts/ecmf/paramId.def +++ b/definitions/grib1/localConcepts/ecmf/paramId.def @@ -9534,7 +9534,7 @@ table2Version = 228 ; indicatorOfParameter = 23 ; } -#Zero degree level +#0 degrees C isothermal level (atm) '228024' = { table2Version = 228 ; indicatorOfParameter = 24 ; diff --git a/definitions/grib1/localConcepts/ecmf/shortName.def b/definitions/grib1/localConcepts/ecmf/shortName.def index 92c1dd09e..b427216bc 100644 --- a/definitions/grib1/localConcepts/ecmf/shortName.def +++ b/definitions/grib1/localConcepts/ecmf/shortName.def @@ -9534,7 +9534,7 @@ table2Version = 228 ; indicatorOfParameter = 23 ; } -#Zero degree level +#0 degrees C isothermal level (atm) 'deg0l' = { table2Version = 228 ; indicatorOfParameter = 24 ; diff --git a/definitions/grib1/localConcepts/ecmf/units.def b/definitions/grib1/localConcepts/ecmf/units.def index 1c8093d7b..c1900f81c 100644 --- a/definitions/grib1/localConcepts/ecmf/units.def +++ b/definitions/grib1/localConcepts/ecmf/units.def @@ -9534,7 +9534,7 @@ table2Version = 228 ; indicatorOfParameter = 23 ; } -#Zero degree level +#0 degrees C isothermal level (atm) 'm' = { table2Version = 228 ; indicatorOfParameter = 24 ; diff --git a/definitions/grib2/cfVarName.def b/definitions/grib2/cfVarName.def index be228be35..1b49e04f4 100644 --- a/definitions/grib2/cfVarName.def +++ b/definitions/grib2/cfVarName.def @@ -549,6 +549,15 @@ typeOfFirstFixedSurface = 1 ; aerosolType = 62003 ; } +#0 degrees C isothermal level (atm) +'deg0l' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 20 ; + scaledValueOfFirstFixedSurface = 27315 ; + scaleFactorOfFirstFixedSurface = 2 ; + } #10 metre wind gust in the last 3 hours 'fg310' = { discipline = 0 ; diff --git a/definitions/grib2/localConcepts/ecmf/cfVarName.def b/definitions/grib2/localConcepts/ecmf/cfVarName.def index 0863d8551..aa2527c25 100644 --- a/definitions/grib2/localConcepts/ecmf/cfVarName.def +++ b/definitions/grib2/localConcepts/ecmf/cfVarName.def @@ -13283,12 +13283,6 @@ parameterCategory = 228 ; parameterNumber = 23 ; } -#Zero degree level -'deg0l' = { - discipline = 192 ; - parameterCategory = 228 ; - parameterNumber = 24 ; - } #Horizontal visibility 'hvis' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/ecmf/name.def b/definitions/grib2/localConcepts/ecmf/name.def index fff8241a0..ce2c269dc 100644 --- a/definitions/grib2/localConcepts/ecmf/name.def +++ b/definitions/grib2/localConcepts/ecmf/name.def @@ -13283,12 +13283,6 @@ parameterCategory = 228 ; parameterNumber = 23 ; } -#Zero degree level -'Zero degree level' = { - discipline = 192 ; - parameterCategory = 228 ; - parameterNumber = 24 ; - } #Horizontal visibility 'Horizontal visibility' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/ecmf/paramId.def b/definitions/grib2/localConcepts/ecmf/paramId.def index 67f42d74b..b53f79577 100644 --- a/definitions/grib2/localConcepts/ecmf/paramId.def +++ b/definitions/grib2/localConcepts/ecmf/paramId.def @@ -13283,12 +13283,6 @@ parameterCategory = 228 ; parameterNumber = 23 ; } -#Zero degree level -'228024' = { - discipline = 192 ; - parameterCategory = 228 ; - parameterNumber = 24 ; - } #Horizontal visibility '228025' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/ecmf/shortName.def b/definitions/grib2/localConcepts/ecmf/shortName.def index 9e2b01f58..b96fa903c 100644 --- a/definitions/grib2/localConcepts/ecmf/shortName.def +++ b/definitions/grib2/localConcepts/ecmf/shortName.def @@ -13283,12 +13283,6 @@ parameterCategory = 228 ; parameterNumber = 23 ; } -#Zero degree level -'deg0l' = { - discipline = 192 ; - parameterCategory = 228 ; - parameterNumber = 24 ; - } #Horizontal visibility 'hvis' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/ecmf/units.def b/definitions/grib2/localConcepts/ecmf/units.def index 69070ecd0..0a5d9b664 100644 --- a/definitions/grib2/localConcepts/ecmf/units.def +++ b/definitions/grib2/localConcepts/ecmf/units.def @@ -13283,12 +13283,6 @@ parameterCategory = 228 ; parameterNumber = 23 ; } -#Zero degree level -'m' = { - discipline = 192 ; - parameterCategory = 228 ; - parameterNumber = 24 ; - } #Horizontal visibility 'm' = { discipline = 192 ; diff --git a/definitions/grib2/name.def b/definitions/grib2/name.def index 3f9337236..7690bcb86 100644 --- a/definitions/grib2/name.def +++ b/definitions/grib2/name.def @@ -549,6 +549,15 @@ typeOfFirstFixedSurface = 1 ; typeOfSecondFixedSurface = 8 ; } +#0 degrees C isothermal level (atm) +'0 degrees C isothermal level (atm)' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 20 ; + scaledValueOfFirstFixedSurface = 27315 ; + scaleFactorOfFirstFixedSurface = 2 ; + } #10 metre wind gust in the last 3 hours '10 metre wind gust in the last 3 hours' = { discipline = 0 ; diff --git a/definitions/grib2/paramId.def b/definitions/grib2/paramId.def index f1ea4a752..7dbb28536 100644 --- a/definitions/grib2/paramId.def +++ b/definitions/grib2/paramId.def @@ -549,6 +549,15 @@ aerosolType = 62003 ; is_aerosol = 1 ; } +#0 degrees C isothermal level (atm) +'228024' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 20 ; + scaledValueOfFirstFixedSurface = 27315 ; + scaleFactorOfFirstFixedSurface = 2 ; + } #10 metre wind gust in the last 3 hours '228028' = { discipline = 0 ; diff --git a/definitions/grib2/shortName.def b/definitions/grib2/shortName.def index 1d4c25b78..519442a04 100644 --- a/definitions/grib2/shortName.def +++ b/definitions/grib2/shortName.def @@ -549,6 +549,15 @@ typeOfFirstFixedSurface = 1 ; aerosolType = 62003 ; } +#0 degrees C isothermal level (atm) +'deg0l' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 20 ; + scaledValueOfFirstFixedSurface = 27315 ; + scaleFactorOfFirstFixedSurface = 2 ; + } #10 metre wind gust in the last 3 hours '10fg3' = { discipline = 0 ; diff --git a/definitions/grib2/units.def b/definitions/grib2/units.def index 24ab62918..06b49a98d 100644 --- a/definitions/grib2/units.def +++ b/definitions/grib2/units.def @@ -549,6 +549,15 @@ typeOfFirstFixedSurface = 1 ; typeOfSecondFixedSurface = 8 ; } +#0 degrees C isothermal level (atm) +'m' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 20 ; + scaledValueOfFirstFixedSurface = 27315 ; + scaleFactorOfFirstFixedSurface = 2 ; + } #10 metre wind gust in the last 3 hours 'm s**-1' = { discipline = 0 ; From ef800b0a00739ad7a0e85221e60e9be65f4b52b8 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Sun, 6 Oct 2019 19:19:01 +0100 Subject: [PATCH 32/49] ECC-934 NCEP table --- definitions/grib2/localConcepts/kwbc/name.def | 6 +++--- definitions/grib2/localConcepts/kwbc/paramId.def | 4 ++-- definitions/grib2/localConcepts/kwbc/shortName.def | 4 ++-- definitions/grib2/localConcepts/kwbc/units.def | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/definitions/grib2/localConcepts/kwbc/name.def b/definitions/grib2/localConcepts/kwbc/name.def index 4b9eff223..aa9759030 100644 --- a/definitions/grib2/localConcepts/kwbc/name.def +++ b/definitions/grib2/localConcepts/kwbc/name.def @@ -101,8 +101,8 @@ parameterCategory = 1 ; parameterNumber = 205 ; } -#Water equivalent of accumulated snow depth -'Water equivalent of accumulated snow depth' = { +#Water equivalent of accumulated snow depth (deprecated) +'Water equivalent of accumulated snow depth (deprecated)' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 11 ; @@ -1648,4 +1648,4 @@ discipline = 0 ; parameterCategory = 1 ; parameterNumber = 8 ; - } +} diff --git a/definitions/grib2/localConcepts/kwbc/paramId.def b/definitions/grib2/localConcepts/kwbc/paramId.def index 2ab92166c..eba8b0bb0 100644 --- a/definitions/grib2/localConcepts/kwbc/paramId.def +++ b/definitions/grib2/localConcepts/kwbc/paramId.def @@ -101,7 +101,7 @@ parameterCategory = 1 ; parameterNumber = 205 ; } -#Water equivalent of accumulated snow depth +#Water equivalent of accumulated snow depth (deprecated) '260056' = { discipline = 0 ; parameterCategory = 1 ; @@ -1648,4 +1648,4 @@ discipline = 0 ; parameterCategory = 1 ; parameterNumber = 8 ; - } +} diff --git a/definitions/grib2/localConcepts/kwbc/shortName.def b/definitions/grib2/localConcepts/kwbc/shortName.def index 448ff6a15..1e85feed5 100644 --- a/definitions/grib2/localConcepts/kwbc/shortName.def +++ b/definitions/grib2/localConcepts/kwbc/shortName.def @@ -101,7 +101,7 @@ parameterCategory = 1 ; parameterNumber = 205 ; } -#Water equivalent of accumulated snow depth +#Water equivalent of accumulated snow depth (deprecated) 'sdwe' = { discipline = 0 ; parameterCategory = 1 ; @@ -1648,4 +1648,4 @@ discipline = 0 ; parameterCategory = 1 ; parameterNumber = 8 ; - } +} diff --git a/definitions/grib2/localConcepts/kwbc/units.def b/definitions/grib2/localConcepts/kwbc/units.def index 3366ed15e..ac782eb8c 100644 --- a/definitions/grib2/localConcepts/kwbc/units.def +++ b/definitions/grib2/localConcepts/kwbc/units.def @@ -101,7 +101,7 @@ parameterCategory = 1 ; parameterNumber = 205 ; } -#Water equivalent of accumulated snow depth +#Water equivalent of accumulated snow depth (deprecated) 'kg m**-2' = { discipline = 0 ; parameterCategory = 1 ; From fa6f081e712b832192c2885d9af5561bffb18b7e Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Sun, 6 Oct 2019 19:36:30 +0100 Subject: [PATCH 33/49] ECC-999: new -10 degree celsius isothermal level (Part 2) --- definitions/grib1/2.98.228.table | 1 + definitions/grib1/localConcepts/ecmf/cfVarName.def | 5 +++++ definitions/grib1/localConcepts/ecmf/name.def | 5 +++++ definitions/grib1/localConcepts/ecmf/paramId.def | 5 +++++ definitions/grib1/localConcepts/ecmf/shortName.def | 5 +++++ definitions/grib1/localConcepts/ecmf/units.def | 5 +++++ definitions/grib2/cfVarName.def | 9 +++++++++ definitions/grib2/name.def | 9 +++++++++ definitions/grib2/paramId.def | 9 +++++++++ definitions/grib2/shortName.def | 9 +++++++++ definitions/grib2/units.def | 9 +++++++++ 11 files changed, 71 insertions(+) diff --git a/definitions/grib1/2.98.228.table b/definitions/grib1/2.98.228.table index 5dd02af69..c93451d40 100644 --- a/definitions/grib1/2.98.228.table +++ b/definitions/grib1/2.98.228.table @@ -18,6 +18,7 @@ 17 dctb DCTB Duct base height (m) 18 tplb TPLB Trapping layer base height (m) 19 tplt TPLT Trapping layer top height (m) +20 degm10l -10 degrees C isothermal level (m) 21 fdir FDIR Total sky direct solar radiation at surface (J m**-2) 22 cdir CDIR Clear-sky direct solar radiation at surface (J m**-2) 23 cbh CBH Cloud base height (m) diff --git a/definitions/grib1/localConcepts/ecmf/cfVarName.def b/definitions/grib1/localConcepts/ecmf/cfVarName.def index e5ec76ee9..8d7a0369b 100644 --- a/definitions/grib1/localConcepts/ecmf/cfVarName.def +++ b/definitions/grib1/localConcepts/ecmf/cfVarName.def @@ -9519,6 +9519,11 @@ table2Version = 221 ; indicatorOfParameter = 56 ; } +#-10 degrees C isothermal level (atm) +'degm10l' = { + table2Version = 228 ; + indicatorOfParameter = 20 ; + } #Total sky direct solar radiation at surface 'fdir' = { table2Version = 228 ; diff --git a/definitions/grib1/localConcepts/ecmf/name.def b/definitions/grib1/localConcepts/ecmf/name.def index fd9c24459..7323f9fc5 100644 --- a/definitions/grib1/localConcepts/ecmf/name.def +++ b/definitions/grib1/localConcepts/ecmf/name.def @@ -9519,6 +9519,11 @@ table2Version = 221 ; indicatorOfParameter = 56 ; } +#-10 degrees C isothermal level (atm) +'-10 degrees C isothermal level (atm)' = { + table2Version = 228 ; + indicatorOfParameter = 20 ; + } #Total sky direct solar radiation at surface 'Total sky direct solar radiation at surface' = { table2Version = 228 ; diff --git a/definitions/grib1/localConcepts/ecmf/paramId.def b/definitions/grib1/localConcepts/ecmf/paramId.def index 7a92a2750..8b2378233 100644 --- a/definitions/grib1/localConcepts/ecmf/paramId.def +++ b/definitions/grib1/localConcepts/ecmf/paramId.def @@ -9519,6 +9519,11 @@ table2Version = 221 ; indicatorOfParameter = 56 ; } +#-10 degrees C isothermal level (atm) +'228020' = { + table2Version = 228 ; + indicatorOfParameter = 20 ; + } #Total sky direct solar radiation at surface '228021' = { table2Version = 228 ; diff --git a/definitions/grib1/localConcepts/ecmf/shortName.def b/definitions/grib1/localConcepts/ecmf/shortName.def index b427216bc..01113ad30 100644 --- a/definitions/grib1/localConcepts/ecmf/shortName.def +++ b/definitions/grib1/localConcepts/ecmf/shortName.def @@ -9519,6 +9519,11 @@ table2Version = 221 ; indicatorOfParameter = 56 ; } +#-10 degrees C isothermal level (atm) +'degm10l' = { + table2Version = 228 ; + indicatorOfParameter = 20 ; + } #Total sky direct solar radiation at surface 'fdir' = { table2Version = 228 ; diff --git a/definitions/grib1/localConcepts/ecmf/units.def b/definitions/grib1/localConcepts/ecmf/units.def index c1900f81c..609f3d1cd 100644 --- a/definitions/grib1/localConcepts/ecmf/units.def +++ b/definitions/grib1/localConcepts/ecmf/units.def @@ -9519,6 +9519,11 @@ table2Version = 221 ; indicatorOfParameter = 56 ; } +#-10 degrees C isothermal level (atm) +'m' = { + table2Version = 228 ; + indicatorOfParameter = 20 ; + } #Total sky direct solar radiation at surface 'J m**-2' = { table2Version = 228 ; diff --git a/definitions/grib2/cfVarName.def b/definitions/grib2/cfVarName.def index 1b49e04f4..7f50f22fb 100644 --- a/definitions/grib2/cfVarName.def +++ b/definitions/grib2/cfVarName.def @@ -549,6 +549,15 @@ typeOfFirstFixedSurface = 1 ; aerosolType = 62003 ; } +#-10 degrees C isothermal level (atm) +'degm10l' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 20 ; + scaledValueOfFirstFixedSurface = 26315 ; + scaleFactorOfFirstFixedSurface = 2 ; + } #0 degrees C isothermal level (atm) 'deg0l' = { discipline = 0 ; diff --git a/definitions/grib2/name.def b/definitions/grib2/name.def index 7690bcb86..1de5374da 100644 --- a/definitions/grib2/name.def +++ b/definitions/grib2/name.def @@ -549,6 +549,15 @@ typeOfFirstFixedSurface = 1 ; typeOfSecondFixedSurface = 8 ; } +#-10 degrees C isothermal level (atm) +'-10 degrees C isothermal level (atm)' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 20 ; + scaledValueOfFirstFixedSurface = 26315 ; + scaleFactorOfFirstFixedSurface = 2 ; + } #0 degrees C isothermal level (atm) '0 degrees C isothermal level (atm)' = { discipline = 0 ; diff --git a/definitions/grib2/paramId.def b/definitions/grib2/paramId.def index 7dbb28536..9350fab36 100644 --- a/definitions/grib2/paramId.def +++ b/definitions/grib2/paramId.def @@ -549,6 +549,15 @@ aerosolType = 62003 ; is_aerosol = 1 ; } +#-10 degrees C isothermal level (atm) +'228020' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 20 ; + scaledValueOfFirstFixedSurface = 26315 ; + scaleFactorOfFirstFixedSurface = 2 ; + } #0 degrees C isothermal level (atm) '228024' = { discipline = 0 ; diff --git a/definitions/grib2/shortName.def b/definitions/grib2/shortName.def index 519442a04..ada15bea2 100644 --- a/definitions/grib2/shortName.def +++ b/definitions/grib2/shortName.def @@ -549,6 +549,15 @@ typeOfFirstFixedSurface = 1 ; aerosolType = 62003 ; } +#-10 degrees C isothermal level (atm) +'degm10l' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 20 ; + scaledValueOfFirstFixedSurface = 26315 ; + scaleFactorOfFirstFixedSurface = 2 ; + } #0 degrees C isothermal level (atm) 'deg0l' = { discipline = 0 ; diff --git a/definitions/grib2/units.def b/definitions/grib2/units.def index 06b49a98d..81640195b 100644 --- a/definitions/grib2/units.def +++ b/definitions/grib2/units.def @@ -549,6 +549,15 @@ typeOfFirstFixedSurface = 1 ; typeOfSecondFixedSurface = 8 ; } +#-10 degrees C isothermal level (atm) +'m' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 20 ; + scaledValueOfFirstFixedSurface = 26315 ; + scaleFactorOfFirstFixedSurface = 2 ; + } #0 degrees C isothermal level (atm) 'm' = { discipline = 0 ; From cf408e19d86a0f80b7cd1edc353c4d8ff213c080 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 7 Oct 2019 14:40:52 +0100 Subject: [PATCH 34/49] ECC-1000: 'grib_ls -l' fails when used on two files with different grids --- tests/CMakeLists.txt | 1 + tests/grib_ecc-1000.sh | 49 ++++++++++++++++++++++++++++++++++++++++++ tools/grib_get.c | 4 +++- tools/grib_ls.c | 2 ++ 4 files changed, 55 insertions(+), 1 deletion(-) create mode 100755 tests/grib_ecc-1000.sh diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0c65d771f..4cf19a8b9 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -116,6 +116,7 @@ list( APPEND tests_data_reqd grib_ecc-600 grib_ecc-923 grib_ecc-984 + grib_ecc-1000 bufr_ecc-556 gts_get gts_ls diff --git a/tests/grib_ecc-1000.sh b/tests/grib_ecc-1000.sh new file mode 100755 index 000000000..23c977e81 --- /dev/null +++ b/tests/grib_ecc-1000.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# Copyright 2005-2019 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 +set -u +# --------------------------------------------------------- +# This is the test for the JIRA issue ECC-1000 +# Nearest neighbour using grib_get/grib_ls on severa files +# --------------------------------------------------------- +label="grib_ecc-1000-test" +tempOut=temp.${label}.out +tempRef=temp.${label}.ref + +input_ll=${data_dir}/regular_latlon_surface.grib1 +input_gg=${data_dir}/reduced_gaussian_model_level.grib1 + +# Test 'grib_get' tool +# -------------------- +${tools_dir}/grib_get -F%.1f -l0,0 $input_ll $input_gg > $tempOut +cat > $tempRef < $tempOut +cat > $tempRef <name); + if (nearest) grib_nearest_delete(nearest); + nearest = NULL; return 0; } @@ -213,7 +215,7 @@ void grib_tool_print_key_values(grib_runtime_options* options,grib_handle* h) int grib_tool_finalise_action(grib_runtime_options* options) { if (nearest) grib_nearest_delete(nearest); - + nearest = NULL; return 0; } diff --git a/tools/grib_ls.c b/tools/grib_ls.c index 1a10e687d..5d01c085f 100644 --- a/tools/grib_ls.c +++ b/tools/grib_ls.c @@ -193,6 +193,8 @@ int grib_tool_new_filename_action(grib_runtime_options* options,const char* file int grib_tool_new_file_action(grib_runtime_options* options,grib_tools_file* file) { exit_if_input_is_directory(grib_tool_name, file->name); + if (nearest) grib_nearest_delete(nearest); + nearest = NULL; return 0; } From cb839e23b768cec3e138ea8df2b373638be9330d Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 7 Oct 2019 16:09:13 +0100 Subject: [PATCH 35/49] ECC-1001: grib_ls -j -l lat,lon broken (JSON output with nearest) --- tests/CMakeLists.txt | 1 + tests/grib_ecc-1001.sh | 43 ++++++++++++++++++++++++++++++++++++++++++ tools/grib_ls.c | 4 ++-- tools/grib_tools.c | 12 ++++++------ 4 files changed, 52 insertions(+), 8 deletions(-) create mode 100755 tests/grib_ecc-1001.sh diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4cf19a8b9..a224f69eb 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -117,6 +117,7 @@ list( APPEND tests_data_reqd grib_ecc-923 grib_ecc-984 grib_ecc-1000 + grib_ecc-1001 bufr_ecc-556 gts_get gts_ls diff --git a/tests/grib_ecc-1001.sh b/tests/grib_ecc-1001.sh new file mode 100755 index 000000000..d5402ab45 --- /dev/null +++ b/tests/grib_ecc-1001.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# Copyright 2005-2019 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 +set -u +# --------------------------------------------------------- +# This is the test for the JIRA issue ECC-1001 +# grib_ls -j -l command (JSON for nearest) +# --------------------------------------------------------- +label="grib_ecc-1001-test" +tempOut=temp.${label}.out + +# Decide if we have the JSON verifier commandline utility +JSON_VERIF="json_xs" +JSON_CHECK="" +if command -v $JSON_VERIF >/dev/null 2>&1; then + JSON_CHECK=$JSON_VERIF +fi + +inputs=" + $ECCODES_SAMPLES_PATH/GRIB1.tmpl + $ECCODES_SAMPLES_PATH/GRIB2.tmpl + ${data_dir}/high_level_api.grib2 +" + +for f in $inputs; do + rm -f $tempOut + ${tools_dir}/grib_ls -m -j -l 51.0,1.0,1 $f > $tempOut + if test "x$JSON_CHECK" != "x"; then + $JSON_VERIF -t none < $tempOut + fi +done + + +# Clean up +rm -f $tempOut diff --git a/tools/grib_ls.c b/tools/grib_ls.c index 5d01c085f..2214434d9 100644 --- a/tools/grib_ls.c +++ b/tools/grib_ls.c @@ -335,7 +335,7 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h) } } - if (options->json_output) { + if (!json_latlon && options->json_output) { if (!first_handle && options->handle_count>1) { fprintf(stdout,",\n"); } @@ -394,7 +394,7 @@ int grib_tool_finalise_action(grib_runtime_options* options) } } - if (options->json_output) fprintf(stdout,"\n]}\n"); + if (!json_latlon && options->json_output) fprintf(stdout,"\n]}\n"); if (nearest) grib_nearest_delete(nearest); if (json_latlon) printf("\n]\n"); diff --git a/tools/grib_tools.c b/tools/grib_tools.c index 66a189025..b77c00211 100644 --- a/tools/grib_tools.c +++ b/tools/grib_tools.c @@ -248,7 +248,7 @@ static int grib_tool_with_orderby(grib_runtime_options* options) continue; } - if (options->json_output == 0) + if (options->json_output == 0 || options->latlon) grib_print_header(options,h); else grib_tools_set_print_keys(options,h,options->name_space); @@ -351,7 +351,7 @@ static int grib_tool_without_orderby(grib_runtime_options* options) continue; } - if (options->json_output == 0) + if (options->json_output == 0 || options->latlon) grib_print_header(options,h); else grib_tools_set_print_keys(options,h,options->name_space); @@ -619,7 +619,7 @@ static void grib_print_header(grib_runtime_options* options,grib_handle* h) size_t strlenkey=0; int width; int written_to_dump = 0; /* boolean */ - if (options->json_output) + if (options->json_output && !options->latlon) return; /* For JSON output we do not print a single header for all msgs */ if (options->handle_count!=1) return; @@ -969,7 +969,7 @@ void grib_print_key_values(grib_runtime_options* options, grib_handle* h) if (!options->verbose) return; - if (options->json_output) { + if (options->json_output && !options->latlon) { /* fprintf(dump_file, "\"message %d\" : {\n", options->handle_count); */ fprintf(dump_file, " {\n"); for (i=0;iprint_keys_count;i++) { @@ -1151,7 +1151,7 @@ void grib_print_file_statistics(grib_runtime_options* options,grib_tools_file* f { grib_failed* failed=NULL; Assert(file); - if (options->json_output) + if (options->json_output && !options->latlon) return; failed=file->failed; @@ -1179,7 +1179,7 @@ void grib_print_file_statistics(grib_runtime_options* options,grib_tools_file* f void grib_print_full_statistics(grib_runtime_options* options) { - if (options->json_output) + if (options->json_output && !options->latlon) return; if (options->print_statistics && options->verbose) fprintf(dump_file,"%d of %d total messages in %d files\n", From 82221ef7d60173e0f85b4dbc1e50f2d736eda708 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 7 Oct 2019 16:38:01 +0100 Subject: [PATCH 36/49] ECC-1001: grib_ls -j -l lat,lon broken (JSON output with nearest) --- .appveyor.yml | 2 +- VERSION.cmake | 2 +- tests/CMakeLists.txt | 1 + tests/grib_ecc-1001.sh | 43 ++++++++++++++++++++++++++++++++++++++++++ tools/grib_ls.c | 4 ++-- tools/grib_tools.c | 12 ++++++------ version.sh | 13 +------------ 7 files changed, 55 insertions(+), 22 deletions(-) create mode 100755 tests/grib_ecc-1001.sh diff --git a/.appveyor.yml b/.appveyor.yml index 082eea05d..e329b92d7 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -2,7 +2,7 @@ # general configuration # #---------------------------------# -version: 2.14.0-{build}-{branch} +version: 2.14.1-{build}-{branch} branches: only: diff --git a/VERSION.cmake b/VERSION.cmake index 7a613a4b5..c1cc7c2a9 100644 --- a/VERSION.cmake +++ b/VERSION.cmake @@ -1 +1 @@ -set( ${PROJECT_NAME}_VERSION_STR "2.14.0" ) +set( ${PROJECT_NAME}_VERSION_STR "2.14.1" ) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6a50bcb44..46ed04240 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -114,6 +114,7 @@ list( APPEND tests_data_reqd grib_ecc-600 grib_ecc-923 grib_ecc-984 + grib_ecc-1001 bufr_ecc-556 gts_get gts_ls diff --git a/tests/grib_ecc-1001.sh b/tests/grib_ecc-1001.sh new file mode 100755 index 000000000..d5402ab45 --- /dev/null +++ b/tests/grib_ecc-1001.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# Copyright 2005-2019 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 +set -u +# --------------------------------------------------------- +# This is the test for the JIRA issue ECC-1001 +# grib_ls -j -l command (JSON for nearest) +# --------------------------------------------------------- +label="grib_ecc-1001-test" +tempOut=temp.${label}.out + +# Decide if we have the JSON verifier commandline utility +JSON_VERIF="json_xs" +JSON_CHECK="" +if command -v $JSON_VERIF >/dev/null 2>&1; then + JSON_CHECK=$JSON_VERIF +fi + +inputs=" + $ECCODES_SAMPLES_PATH/GRIB1.tmpl + $ECCODES_SAMPLES_PATH/GRIB2.tmpl + ${data_dir}/high_level_api.grib2 +" + +for f in $inputs; do + rm -f $tempOut + ${tools_dir}/grib_ls -m -j -l 51.0,1.0,1 $f > $tempOut + if test "x$JSON_CHECK" != "x"; then + $JSON_VERIF -t none < $tempOut + fi +done + + +# Clean up +rm -f $tempOut diff --git a/tools/grib_ls.c b/tools/grib_ls.c index 1a10e687d..73ebfeced 100644 --- a/tools/grib_ls.c +++ b/tools/grib_ls.c @@ -333,7 +333,7 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h) } } - if (options->json_output) { + if (!json_latlon && options->json_output) { if (!first_handle && options->handle_count>1) { fprintf(stdout,",\n"); } @@ -392,7 +392,7 @@ int grib_tool_finalise_action(grib_runtime_options* options) } } - if (options->json_output) fprintf(stdout,"\n]}\n"); + if (!json_latlon && options->json_output) fprintf(stdout,"\n]}\n"); if (nearest) grib_nearest_delete(nearest); if (json_latlon) printf("\n]\n"); diff --git a/tools/grib_tools.c b/tools/grib_tools.c index 66a189025..b77c00211 100644 --- a/tools/grib_tools.c +++ b/tools/grib_tools.c @@ -248,7 +248,7 @@ static int grib_tool_with_orderby(grib_runtime_options* options) continue; } - if (options->json_output == 0) + if (options->json_output == 0 || options->latlon) grib_print_header(options,h); else grib_tools_set_print_keys(options,h,options->name_space); @@ -351,7 +351,7 @@ static int grib_tool_without_orderby(grib_runtime_options* options) continue; } - if (options->json_output == 0) + if (options->json_output == 0 || options->latlon) grib_print_header(options,h); else grib_tools_set_print_keys(options,h,options->name_space); @@ -619,7 +619,7 @@ static void grib_print_header(grib_runtime_options* options,grib_handle* h) size_t strlenkey=0; int width; int written_to_dump = 0; /* boolean */ - if (options->json_output) + if (options->json_output && !options->latlon) return; /* For JSON output we do not print a single header for all msgs */ if (options->handle_count!=1) return; @@ -969,7 +969,7 @@ void grib_print_key_values(grib_runtime_options* options, grib_handle* h) if (!options->verbose) return; - if (options->json_output) { + if (options->json_output && !options->latlon) { /* fprintf(dump_file, "\"message %d\" : {\n", options->handle_count); */ fprintf(dump_file, " {\n"); for (i=0;iprint_keys_count;i++) { @@ -1151,7 +1151,7 @@ void grib_print_file_statistics(grib_runtime_options* options,grib_tools_file* f { grib_failed* failed=NULL; Assert(file); - if (options->json_output) + if (options->json_output && !options->latlon) return; failed=file->failed; @@ -1179,7 +1179,7 @@ void grib_print_file_statistics(grib_runtime_options* options,grib_tools_file* f void grib_print_full_statistics(grib_runtime_options* options) { - if (options->json_output) + if (options->json_output && !options->latlon) return; if (options->print_statistics && options->verbose) fprintf(dump_file,"%d of %d total messages in %d files\n", diff --git a/version.sh b/version.sh index bc2104d7d..d7f952fc8 100644 --- a/version.sh +++ b/version.sh @@ -1,21 +1,10 @@ -# Copyright 2005-2019 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. -# -# Package name and versioning information -# -# # Package base name PACKAGE_NAME='eccodes' # Package version ECCODES_MAJOR_VERSION=2 ECCODES_MINOR_VERSION=14 -ECCODES_REVISION_VERSION=0 +ECCODES_REVISION_VERSION=1 ECCODES_CURRENT=1 ECCODES_REVISION=0 From 9cb06b5ac6f8bd05e4a1184c83d4590d09699528 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 7 Oct 2019 16:53:33 +0100 Subject: [PATCH 37/49] ECC-999 --- definitions/grib1/2.98.228.table | 1 + .../grib1/localConcepts/ecmf/cfVarName.def | 7 ++++++- definitions/grib1/localConcepts/ecmf/name.def | 9 +++++++-- .../grib1/localConcepts/ecmf/paramId.def | 7 ++++++- .../grib1/localConcepts/ecmf/shortName.def | 7 ++++++- definitions/grib1/localConcepts/ecmf/units.def | 7 ++++++- definitions/grib2/cfVarName.def | 18 ++++++++++++++++++ .../grib2/localConcepts/ecmf/cfVarName.def | 6 ------ definitions/grib2/localConcepts/ecmf/name.def | 6 ------ .../grib2/localConcepts/ecmf/paramId.def | 6 ------ .../grib2/localConcepts/ecmf/shortName.def | 6 ------ definitions/grib2/localConcepts/ecmf/units.def | 6 ------ definitions/grib2/localConcepts/kwbc/name.def | 6 +++--- .../grib2/localConcepts/kwbc/paramId.def | 4 ++-- .../grib2/localConcepts/kwbc/shortName.def | 4 ++-- definitions/grib2/localConcepts/kwbc/units.def | 2 +- definitions/grib2/name.def | 18 ++++++++++++++++++ definitions/grib2/paramId.def | 18 ++++++++++++++++++ definitions/grib2/shortName.def | 18 ++++++++++++++++++ definitions/grib2/units.def | 18 ++++++++++++++++++ 20 files changed, 130 insertions(+), 44 deletions(-) diff --git a/definitions/grib1/2.98.228.table b/definitions/grib1/2.98.228.table index 5dd02af69..c93451d40 100644 --- a/definitions/grib1/2.98.228.table +++ b/definitions/grib1/2.98.228.table @@ -18,6 +18,7 @@ 17 dctb DCTB Duct base height (m) 18 tplb TPLB Trapping layer base height (m) 19 tplt TPLT Trapping layer top height (m) +20 degm10l -10 degrees C isothermal level (m) 21 fdir FDIR Total sky direct solar radiation at surface (J m**-2) 22 cdir CDIR Clear-sky direct solar radiation at surface (J m**-2) 23 cbh CBH Cloud base height (m) diff --git a/definitions/grib1/localConcepts/ecmf/cfVarName.def b/definitions/grib1/localConcepts/ecmf/cfVarName.def index 70819a846..8d7a0369b 100644 --- a/definitions/grib1/localConcepts/ecmf/cfVarName.def +++ b/definitions/grib1/localConcepts/ecmf/cfVarName.def @@ -9519,6 +9519,11 @@ table2Version = 221 ; indicatorOfParameter = 56 ; } +#-10 degrees C isothermal level (atm) +'degm10l' = { + table2Version = 228 ; + indicatorOfParameter = 20 ; + } #Total sky direct solar radiation at surface 'fdir' = { table2Version = 228 ; @@ -9534,7 +9539,7 @@ table2Version = 228 ; indicatorOfParameter = 23 ; } -#Zero degree level +#0 degrees C isothermal level (atm) 'deg0l' = { table2Version = 228 ; indicatorOfParameter = 24 ; diff --git a/definitions/grib1/localConcepts/ecmf/name.def b/definitions/grib1/localConcepts/ecmf/name.def index 8bb75fe63..7323f9fc5 100644 --- a/definitions/grib1/localConcepts/ecmf/name.def +++ b/definitions/grib1/localConcepts/ecmf/name.def @@ -9519,6 +9519,11 @@ table2Version = 221 ; indicatorOfParameter = 56 ; } +#-10 degrees C isothermal level (atm) +'-10 degrees C isothermal level (atm)' = { + table2Version = 228 ; + indicatorOfParameter = 20 ; + } #Total sky direct solar radiation at surface 'Total sky direct solar radiation at surface' = { table2Version = 228 ; @@ -9534,8 +9539,8 @@ table2Version = 228 ; indicatorOfParameter = 23 ; } -#Zero degree level -'Zero degree level' = { +#0 degrees C isothermal level (atm) +'0 degrees C isothermal level (atm)' = { table2Version = 228 ; indicatorOfParameter = 24 ; } diff --git a/definitions/grib1/localConcepts/ecmf/paramId.def b/definitions/grib1/localConcepts/ecmf/paramId.def index e7e57b9be..8b2378233 100644 --- a/definitions/grib1/localConcepts/ecmf/paramId.def +++ b/definitions/grib1/localConcepts/ecmf/paramId.def @@ -9519,6 +9519,11 @@ table2Version = 221 ; indicatorOfParameter = 56 ; } +#-10 degrees C isothermal level (atm) +'228020' = { + table2Version = 228 ; + indicatorOfParameter = 20 ; + } #Total sky direct solar radiation at surface '228021' = { table2Version = 228 ; @@ -9534,7 +9539,7 @@ table2Version = 228 ; indicatorOfParameter = 23 ; } -#Zero degree level +#0 degrees C isothermal level (atm) '228024' = { table2Version = 228 ; indicatorOfParameter = 24 ; diff --git a/definitions/grib1/localConcepts/ecmf/shortName.def b/definitions/grib1/localConcepts/ecmf/shortName.def index 92c1dd09e..01113ad30 100644 --- a/definitions/grib1/localConcepts/ecmf/shortName.def +++ b/definitions/grib1/localConcepts/ecmf/shortName.def @@ -9519,6 +9519,11 @@ table2Version = 221 ; indicatorOfParameter = 56 ; } +#-10 degrees C isothermal level (atm) +'degm10l' = { + table2Version = 228 ; + indicatorOfParameter = 20 ; + } #Total sky direct solar radiation at surface 'fdir' = { table2Version = 228 ; @@ -9534,7 +9539,7 @@ table2Version = 228 ; indicatorOfParameter = 23 ; } -#Zero degree level +#0 degrees C isothermal level (atm) 'deg0l' = { table2Version = 228 ; indicatorOfParameter = 24 ; diff --git a/definitions/grib1/localConcepts/ecmf/units.def b/definitions/grib1/localConcepts/ecmf/units.def index 1c8093d7b..609f3d1cd 100644 --- a/definitions/grib1/localConcepts/ecmf/units.def +++ b/definitions/grib1/localConcepts/ecmf/units.def @@ -9519,6 +9519,11 @@ table2Version = 221 ; indicatorOfParameter = 56 ; } +#-10 degrees C isothermal level (atm) +'m' = { + table2Version = 228 ; + indicatorOfParameter = 20 ; + } #Total sky direct solar radiation at surface 'J m**-2' = { table2Version = 228 ; @@ -9534,7 +9539,7 @@ table2Version = 228 ; indicatorOfParameter = 23 ; } -#Zero degree level +#0 degrees C isothermal level (atm) 'm' = { table2Version = 228 ; indicatorOfParameter = 24 ; diff --git a/definitions/grib2/cfVarName.def b/definitions/grib2/cfVarName.def index be228be35..7f50f22fb 100644 --- a/definitions/grib2/cfVarName.def +++ b/definitions/grib2/cfVarName.def @@ -549,6 +549,24 @@ typeOfFirstFixedSurface = 1 ; aerosolType = 62003 ; } +#-10 degrees C isothermal level (atm) +'degm10l' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 20 ; + scaledValueOfFirstFixedSurface = 26315 ; + scaleFactorOfFirstFixedSurface = 2 ; + } +#0 degrees C isothermal level (atm) +'deg0l' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 20 ; + scaledValueOfFirstFixedSurface = 27315 ; + scaleFactorOfFirstFixedSurface = 2 ; + } #10 metre wind gust in the last 3 hours 'fg310' = { discipline = 0 ; diff --git a/definitions/grib2/localConcepts/ecmf/cfVarName.def b/definitions/grib2/localConcepts/ecmf/cfVarName.def index 0863d8551..aa2527c25 100644 --- a/definitions/grib2/localConcepts/ecmf/cfVarName.def +++ b/definitions/grib2/localConcepts/ecmf/cfVarName.def @@ -13283,12 +13283,6 @@ parameterCategory = 228 ; parameterNumber = 23 ; } -#Zero degree level -'deg0l' = { - discipline = 192 ; - parameterCategory = 228 ; - parameterNumber = 24 ; - } #Horizontal visibility 'hvis' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/ecmf/name.def b/definitions/grib2/localConcepts/ecmf/name.def index fff8241a0..ce2c269dc 100644 --- a/definitions/grib2/localConcepts/ecmf/name.def +++ b/definitions/grib2/localConcepts/ecmf/name.def @@ -13283,12 +13283,6 @@ parameterCategory = 228 ; parameterNumber = 23 ; } -#Zero degree level -'Zero degree level' = { - discipline = 192 ; - parameterCategory = 228 ; - parameterNumber = 24 ; - } #Horizontal visibility 'Horizontal visibility' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/ecmf/paramId.def b/definitions/grib2/localConcepts/ecmf/paramId.def index 67f42d74b..b53f79577 100644 --- a/definitions/grib2/localConcepts/ecmf/paramId.def +++ b/definitions/grib2/localConcepts/ecmf/paramId.def @@ -13283,12 +13283,6 @@ parameterCategory = 228 ; parameterNumber = 23 ; } -#Zero degree level -'228024' = { - discipline = 192 ; - parameterCategory = 228 ; - parameterNumber = 24 ; - } #Horizontal visibility '228025' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/ecmf/shortName.def b/definitions/grib2/localConcepts/ecmf/shortName.def index 9e2b01f58..b96fa903c 100644 --- a/definitions/grib2/localConcepts/ecmf/shortName.def +++ b/definitions/grib2/localConcepts/ecmf/shortName.def @@ -13283,12 +13283,6 @@ parameterCategory = 228 ; parameterNumber = 23 ; } -#Zero degree level -'deg0l' = { - discipline = 192 ; - parameterCategory = 228 ; - parameterNumber = 24 ; - } #Horizontal visibility 'hvis' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/ecmf/units.def b/definitions/grib2/localConcepts/ecmf/units.def index 69070ecd0..0a5d9b664 100644 --- a/definitions/grib2/localConcepts/ecmf/units.def +++ b/definitions/grib2/localConcepts/ecmf/units.def @@ -13283,12 +13283,6 @@ parameterCategory = 228 ; parameterNumber = 23 ; } -#Zero degree level -'m' = { - discipline = 192 ; - parameterCategory = 228 ; - parameterNumber = 24 ; - } #Horizontal visibility 'm' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/kwbc/name.def b/definitions/grib2/localConcepts/kwbc/name.def index 4b9eff223..aa9759030 100644 --- a/definitions/grib2/localConcepts/kwbc/name.def +++ b/definitions/grib2/localConcepts/kwbc/name.def @@ -101,8 +101,8 @@ parameterCategory = 1 ; parameterNumber = 205 ; } -#Water equivalent of accumulated snow depth -'Water equivalent of accumulated snow depth' = { +#Water equivalent of accumulated snow depth (deprecated) +'Water equivalent of accumulated snow depth (deprecated)' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 11 ; @@ -1648,4 +1648,4 @@ discipline = 0 ; parameterCategory = 1 ; parameterNumber = 8 ; - } +} diff --git a/definitions/grib2/localConcepts/kwbc/paramId.def b/definitions/grib2/localConcepts/kwbc/paramId.def index 2ab92166c..eba8b0bb0 100644 --- a/definitions/grib2/localConcepts/kwbc/paramId.def +++ b/definitions/grib2/localConcepts/kwbc/paramId.def @@ -101,7 +101,7 @@ parameterCategory = 1 ; parameterNumber = 205 ; } -#Water equivalent of accumulated snow depth +#Water equivalent of accumulated snow depth (deprecated) '260056' = { discipline = 0 ; parameterCategory = 1 ; @@ -1648,4 +1648,4 @@ discipline = 0 ; parameterCategory = 1 ; parameterNumber = 8 ; - } +} diff --git a/definitions/grib2/localConcepts/kwbc/shortName.def b/definitions/grib2/localConcepts/kwbc/shortName.def index 448ff6a15..1e85feed5 100644 --- a/definitions/grib2/localConcepts/kwbc/shortName.def +++ b/definitions/grib2/localConcepts/kwbc/shortName.def @@ -101,7 +101,7 @@ parameterCategory = 1 ; parameterNumber = 205 ; } -#Water equivalent of accumulated snow depth +#Water equivalent of accumulated snow depth (deprecated) 'sdwe' = { discipline = 0 ; parameterCategory = 1 ; @@ -1648,4 +1648,4 @@ discipline = 0 ; parameterCategory = 1 ; parameterNumber = 8 ; - } +} diff --git a/definitions/grib2/localConcepts/kwbc/units.def b/definitions/grib2/localConcepts/kwbc/units.def index 3366ed15e..ac782eb8c 100644 --- a/definitions/grib2/localConcepts/kwbc/units.def +++ b/definitions/grib2/localConcepts/kwbc/units.def @@ -101,7 +101,7 @@ parameterCategory = 1 ; parameterNumber = 205 ; } -#Water equivalent of accumulated snow depth +#Water equivalent of accumulated snow depth (deprecated) 'kg m**-2' = { discipline = 0 ; parameterCategory = 1 ; diff --git a/definitions/grib2/name.def b/definitions/grib2/name.def index 3f9337236..1de5374da 100644 --- a/definitions/grib2/name.def +++ b/definitions/grib2/name.def @@ -549,6 +549,24 @@ typeOfFirstFixedSurface = 1 ; typeOfSecondFixedSurface = 8 ; } +#-10 degrees C isothermal level (atm) +'-10 degrees C isothermal level (atm)' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 20 ; + scaledValueOfFirstFixedSurface = 26315 ; + scaleFactorOfFirstFixedSurface = 2 ; + } +#0 degrees C isothermal level (atm) +'0 degrees C isothermal level (atm)' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 20 ; + scaledValueOfFirstFixedSurface = 27315 ; + scaleFactorOfFirstFixedSurface = 2 ; + } #10 metre wind gust in the last 3 hours '10 metre wind gust in the last 3 hours' = { discipline = 0 ; diff --git a/definitions/grib2/paramId.def b/definitions/grib2/paramId.def index f1ea4a752..9350fab36 100644 --- a/definitions/grib2/paramId.def +++ b/definitions/grib2/paramId.def @@ -549,6 +549,24 @@ aerosolType = 62003 ; is_aerosol = 1 ; } +#-10 degrees C isothermal level (atm) +'228020' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 20 ; + scaledValueOfFirstFixedSurface = 26315 ; + scaleFactorOfFirstFixedSurface = 2 ; + } +#0 degrees C isothermal level (atm) +'228024' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 20 ; + scaledValueOfFirstFixedSurface = 27315 ; + scaleFactorOfFirstFixedSurface = 2 ; + } #10 metre wind gust in the last 3 hours '228028' = { discipline = 0 ; diff --git a/definitions/grib2/shortName.def b/definitions/grib2/shortName.def index 1d4c25b78..ada15bea2 100644 --- a/definitions/grib2/shortName.def +++ b/definitions/grib2/shortName.def @@ -549,6 +549,24 @@ typeOfFirstFixedSurface = 1 ; aerosolType = 62003 ; } +#-10 degrees C isothermal level (atm) +'degm10l' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 20 ; + scaledValueOfFirstFixedSurface = 26315 ; + scaleFactorOfFirstFixedSurface = 2 ; + } +#0 degrees C isothermal level (atm) +'deg0l' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 20 ; + scaledValueOfFirstFixedSurface = 27315 ; + scaleFactorOfFirstFixedSurface = 2 ; + } #10 metre wind gust in the last 3 hours '10fg3' = { discipline = 0 ; diff --git a/definitions/grib2/units.def b/definitions/grib2/units.def index 24ab62918..81640195b 100644 --- a/definitions/grib2/units.def +++ b/definitions/grib2/units.def @@ -549,6 +549,24 @@ typeOfFirstFixedSurface = 1 ; typeOfSecondFixedSurface = 8 ; } +#-10 degrees C isothermal level (atm) +'m' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 20 ; + scaledValueOfFirstFixedSurface = 26315 ; + scaleFactorOfFirstFixedSurface = 2 ; + } +#0 degrees C isothermal level (atm) +'m' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 20 ; + scaledValueOfFirstFixedSurface = 27315 ; + scaleFactorOfFirstFixedSurface = 2 ; + } #10 metre wind gust in the last 3 hours 'm s**-1' = { discipline = 0 ; From d0d01dd956bb174357934190a0d5783d0a4dab31 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 7 Oct 2019 17:57:26 +0100 Subject: [PATCH 38/49] ECC-1002: Windows: encoding tests fail: 'maximum allowable value is 0' --- src/grib_accessor_class_unsigned.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/grib_accessor_class_unsigned.c b/src/grib_accessor_class_unsigned.c index 37200e0e6..87dd69ff3 100644 --- a/src/grib_accessor_class_unsigned.c +++ b/src/grib_accessor_class_unsigned.c @@ -244,7 +244,7 @@ int pack_long_unsigned_helper(grib_accessor* a, const long* val, size_t *len, in } if (nbits < 33) { unsigned long maxval = (1UL << nbits)-1; - if (v > maxval) { + if (maxval > 0 && v > maxval) { /* See ECC-1002 */ grib_context_log(a->context, GRIB_LOG_ERROR, "Key \"%s\": Trying to encode value of %ld but the maximum allowable value is %ld (number of bits=%ld)\n", a->name, v, maxval, nbits); From a0fbb239c5a5b79447473ee9a3f15b52a799752a Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 7 Oct 2019 17:58:13 +0100 Subject: [PATCH 39/49] ECC-1002: Windows: encoding tests fail: 'maximum allowable value is 0' --- src/grib_accessor_class_unsigned.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/grib_accessor_class_unsigned.c b/src/grib_accessor_class_unsigned.c index 37200e0e6..87dd69ff3 100644 --- a/src/grib_accessor_class_unsigned.c +++ b/src/grib_accessor_class_unsigned.c @@ -244,7 +244,7 @@ int pack_long_unsigned_helper(grib_accessor* a, const long* val, size_t *len, in } if (nbits < 33) { unsigned long maxval = (1UL << nbits)-1; - if (v > maxval) { + if (maxval > 0 && v > maxval) { /* See ECC-1002 */ grib_context_log(a->context, GRIB_LOG_ERROR, "Key \"%s\": Trying to encode value of %ld but the maximum allowable value is %ld (number of bits=%ld)\n", a->name, v, maxval, nbits); From ccd4f3c3869edc7f67b33b896d0d758fcca87b0b Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 7 Oct 2019 18:25:39 +0100 Subject: [PATCH 40/49] ECC-1002: Windows: encoding tests fail --- tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 46ed04240..69c027ea8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -56,7 +56,6 @@ list( APPEND tests_no_data_reqd grib_2nd_order_numValues grib_ecc-136 grib_ecc-967 - grib_ecc-979 julian bufr_dump_samples bufr_json_samples @@ -113,6 +112,7 @@ list( APPEND tests_data_reqd grib_ecc-873 grib_ecc-600 grib_ecc-923 + grib_ecc-979 grib_ecc-984 grib_ecc-1001 bufr_ecc-556 From aef9a9ca215fd308d4f5d373008a3c1f50c49c39 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 8 Oct 2019 13:53:49 +0100 Subject: [PATCH 41/49] Documentation --- tools/grib_ls.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/grib_ls.c b/tools/grib_ls.c index 2214434d9..dad47e29d 100644 --- a/tools/grib_ls.c +++ b/tools/grib_ls.c @@ -52,6 +52,13 @@ int grib_options_count=sizeof(grib_options)/sizeof(grib_option); static double lat=0; static double lon=0; static int mode=0; +/* Note: + * There are two JSON-output modes: + * 1. With a provided lat-lon for the nearest neighbour (options->latlon==1) + * 2. All other cases (options->json_output==1) + * The first is special and has a very different format. They need to be + * treated differently + */ static int json_latlon=0; static int first_handle=1; static grib_nearest* nearest=NULL; From ec0d4c0311e1ec274170136ad6f48ebe1825e247 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 8 Oct 2019 15:55:59 +0100 Subject: [PATCH 42/49] ECC-1003: Performance: Use faster shift operator rather than power function --- src/grib_accessor_class_codetable.c | 3 ++- src/grib_accessor_class_smart_table.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/grib_accessor_class_codetable.c b/src/grib_accessor_class_codetable.c index d0881e2b7..43087097d 100644 --- a/src/grib_accessor_class_codetable.c +++ b/src/grib_accessor_class_codetable.c @@ -359,7 +359,8 @@ static grib_codetable* load_table(grib_accessor_codetable* self) } else { size = grib_byte_count((grib_accessor*)self) * 8; } - size = grib_power(size,2); + + size = (1UL << size); /* 2^size */ t = (grib_codetable*)grib_context_malloc_clear_persistent(c,sizeof(grib_codetable) + (size-1)*sizeof(code_table_entry)); diff --git a/src/grib_accessor_class_smart_table.c b/src/grib_accessor_class_smart_table.c index 8c7da3673..66e5b57e3 100644 --- a/src/grib_accessor_class_smart_table.c +++ b/src/grib_accessor_class_smart_table.c @@ -281,7 +281,7 @@ static grib_smart_table* load_table(grib_accessor_smart_table* self) next = next->next; } - size = grib_power(self->widthOfCode,2); + size = (1UL << self->widthOfCode); /* 2 ^ self->widthOfCode */ t = (grib_smart_table*)grib_context_malloc_clear_persistent(c,sizeof(grib_smart_table)); t->entries=(grib_smart_table_entry*)grib_context_malloc_clear_persistent(c,size*sizeof(grib_smart_table_entry)); @@ -473,7 +473,7 @@ static int get_table_codes(grib_accessor* a) if (!self->dirty) return 0; - table_size = grib_power(self->widthOfCode,2); + table_size = (1 << self->widthOfCode); /* 2 ^ self->widthOfCode */ if(!self->table) self->table = load_table(self); From 32fb8bd28b37a09cd80bf3265195e267e0b89f40 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 8 Oct 2019 18:24:59 +0100 Subject: [PATCH 43/49] Add extra info during cmake step --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e3878778b..f52cfa830 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,6 +64,7 @@ endif() ecbuild_debug("ECCODES_BIG_ENDIAN=${ECCODES_BIG_ENDIAN}") ecbuild_debug("ECCODES_LITTLE_ENDIAN=${ECCODES_LITTLE_ENDIAN}") +ecbuild_info("Operating system=${CMAKE_SYSTEM} (${EC_OS_BITS} bits)") ############################################################################### # some variables/options of this project From e321fbca05c97515d9460c88d341d90ff611f70b Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 8 Oct 2019 20:51:41 +0100 Subject: [PATCH 44/49] MEMFS: more descriptive message --- memfs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/memfs.py b/memfs.py index 4cc140304..32a0ab7df 100755 --- a/memfs.py +++ b/memfs.py @@ -38,7 +38,7 @@ for directory in dirs: for dirpath, dirnames, files in os.walk(directory, followlinks=True): for ex in EXCLUDED: if ex in dirnames: - print('Note: %s/%s will not be included.' % (dirpath,ex)) + print('Note: eccodes memfs.py script: %s/%s will not be included.' % (dirpath,ex)) # Prune the walk by modifying the dirnames in-place dirnames[:] = [dirname for dirname in dirnames if dirname not in EXCLUDED] From be02024939e8d11ce69facd968f44cb87de03cbf Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 10 Oct 2019 14:52:05 +0100 Subject: [PATCH 45/49] Remove old script --- license.pl | 128 ----------------------------------------------------- 1 file changed, 128 deletions(-) delete mode 100755 license.pl diff --git a/license.pl b/license.pl deleted file mode 100755 index 394a5b571..000000000 --- a/license.pl +++ /dev/null @@ -1,128 +0,0 @@ -#!/usr/bin/perl -use strict; - -my $APACHE = <<"EOF"; -Copyright 2005-2019 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. -EOF - -my $LGPL = <<"EOF"; -Copyright 2005-2007 ECMWF - -Licensed under the GNU Lesser General Public License which -incorporates the terms and conditions of version 3 of the GNU -General Public License. -See LICENSE and gpl-3.0.txt for details. -EOF - -my $GPL = <<"EOF"; -Copyright 2005-2007 ECMWF - -Licensed under the GNU General Public License version 3. -See LICENSE for details. -EOF - - -my $LICENSE = $APACHE; - -my %COMMENTS = ( - - java => { start => "/**\n" , end => "*/\n\n" , comment => "* " }, - xml => { start => "\n\n" , after => "\<\?xml[^<]*\>" }, -# xsd => { start => "\n\n" }, -# jsp => { start => "\n\n" }, - sh => { comment => "# ", end => "\n", after => "^#!/.*\n" }, - pl => { comment => "# ", end => "\n", after => "^#!/.*\n" }, - js => { start => "/**\n" , end => "*/\n\n" , comment => "* " }, - c => { start => "/**\n" , end => "*/\n\n" , comment => "* " }, - h => { start => "/**\n" , end => "*/\n\n" , comment => "* " }, - l => { start => "/**\n" , end => "*/\n\n" , comment => "* " }, - y => { start => "/**\n" , end => "*/\n\n" , comment => "* " }, - css => { start => "/**\n" , end => "*/\n\n" , comment => "* " }, - sql => { comment => "-- ", end => "\n" }, - properties => { comment => "# ", end => "\n" }, - def => { comment => "# ", end => "\n" }, - F => { comment => "C ", end => "C\n\n " }, - f => { comment => "C ", end => "C\n\n" }, - - ); - - -foreach my $file ( @ARGV ) -{ - my $doit=1; - - $file =~ /\.(\w+)/; - my $ext = $1; - - my $c = $COMMENTS{$ext}; - - unless($c) - { - print "$file: unsupported extension. File ignored\n"; - next; - } - - open(IN,"<$file") or die "$file: $!"; - my @text = ; - close(IN); - - if(join("",@text) =~ /Licensed under the/gs) - { - print "$file: License already stated. File ignored\n"; - next; - } - - open(OUT,">$file.tmp") or die "$file.tmp: $!"; - - if($c->{after}) - { - my @x; - my $re = $c->{after}; - loop: while(@text) - { - if($text[0] =~ m/$re/) - { - print OUT @x, shift @text; - @x = (); - last loop; - } - push @x,shift @text; - } - @text = (@x,@text); - } - - print OUT $c->{start}; - foreach my $line ( split("\n",$LICENSE) ) - { - print OUT $c->{comment}, $line,"\n"; - } - print OUT $c->{end}; - - print OUT @text; - close(OUT) or die "$file: $!"; - - if($doit) { - use File::Copy qw(cp); - use File::Compare qw(compare_text compare); - - if(compare_text("$file.tmp",$file)) { - print "UPDATING file $file\n"; - system("p4 edit $file") unless(-w $file); - cp($file,"$file.old") or die "cp($file,$file.old): $!"; - cp("$file.tmp",$file) or die "cp($file.tmp,$file): $!"; - } - } else { - print "IGNORING file $file\n"; - } - - unlink("$file.tmp"); - - -} - From e57d8ede9531039a05ce344ee5eb04655281a833 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Fri, 11 Oct 2019 13:34:19 +0100 Subject: [PATCH 46/49] Better error messages --- src/grib_accessor_class_data_g1simple_packing.c | 2 +- src/grib_accessor_class_data_g2simple_packing.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/grib_accessor_class_data_g1simple_packing.c b/src/grib_accessor_class_data_g1simple_packing.c index 6f9ab42c3..0dd23b033 100644 --- a/src/grib_accessor_class_data_g1simple_packing.c +++ b/src/grib_accessor_class_data_g1simple_packing.c @@ -283,7 +283,7 @@ static int pack_double(grib_accessor* a, const double* cval, size_t *len) case GRIB_SUCCESS: break; default: - grib_context_log(a->context,GRIB_LOG_ERROR,"unable to compute packing parameters\n"); + grib_context_log(a->context,GRIB_LOG_ERROR,"GRIB1 simple packing: unable to set values"); return ret; } diff --git a/src/grib_accessor_class_data_g2simple_packing.c b/src/grib_accessor_class_data_g2simple_packing.c index 6748b965d..033b4848a 100644 --- a/src/grib_accessor_class_data_g2simple_packing.c +++ b/src/grib_accessor_class_data_g2simple_packing.c @@ -218,7 +218,7 @@ static int pack_double(grib_accessor* a, const double* cval, size_t *len) case GRIB_SUCCESS: break; default: - grib_context_log(a->context,GRIB_LOG_ERROR,"unable to compute packing parameters\n"); + grib_context_log(a->context,GRIB_LOG_ERROR,"GRIB2 simple packing: unable to set values"); return ret; } From ba524c3218f72db14f5dd0c054f02d0eb417080a Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Fri, 11 Oct 2019 13:35:01 +0100 Subject: [PATCH 47/49] GRIB encoding: keep values reasonable for examples/tests --- examples/C/large_grib1.c | 4 ++-- tests/bufr_ecc-604.c | 2 +- tests/grib_ecc-604.c | 2 +- tests/grib_encode_pthreads.c | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/C/large_grib1.c b/examples/C/large_grib1.c index f631824c3..8fc11852e 100644 --- a/examples/C/large_grib1.c +++ b/examples/C/large_grib1.c @@ -29,8 +29,8 @@ int main() } for (i=0; i100) {e*=10; count=1;} + if (count>1000) {e*=2; count=1;} values[i]=d; d+=e; count++; From 73672e7b73a3fa7c0de6714cca830a6be2718941 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 14 Oct 2019 15:48:44 +0100 Subject: [PATCH 48/49] ECC-995: C API: Review const-ness of arguments (part 4) --- src/eccodes.c | 8 ++++---- src/eccodes.h | 2 +- src/grib_api.h | 14 +++++++------- src/grib_api_prototypes.h | 2 +- src/grib_nearest.c | 9 +++++---- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/eccodes.c b/src/eccodes.c index d59c3d8a2..7ed0ad6ed 100644 --- a/src/eccodes.c +++ b/src/eccodes.c @@ -294,10 +294,10 @@ int codes_grib_nearest_find(grib_nearest *nearest, const grib_handle* h,double i { return grib_nearest_find(nearest, h, inlat, inlon, flags, outlats, outlons, values, distances, indexes, len); } -int codes_grib_nearest_find_multiple(const grib_handle* h,int is_lsm, - double* inlats,double* inlons,long npoints, - double* outlats,double* outlons, - double* values,double* distances, int* indexes) +int codes_grib_nearest_find_multiple(const grib_handle* h, int is_lsm, + const double* inlats, const double* inlons, long npoints, + double* outlats, double* outlons, + double* values, double* distances, int* indexes) { return grib_nearest_find_multiple(h, is_lsm, inlats, inlons, npoints, outlats, outlons, values, distances, indexes); } diff --git a/src/eccodes.h b/src/eccodes.h index b0cd7c002..46838dd78 100644 --- a/src/eccodes.h +++ b/src/eccodes.h @@ -706,7 +706,7 @@ int codes_grib_nearest_delete(codes_nearest *nearest); * @return 0 if OK, integer value on error */ int codes_grib_nearest_find_multiple(const codes_handle* h, int is_lsm, - double* inlats, double* inlons, long npoints, + const double* inlats, const double* inlons, long npoints, double* outlats, double* outlons, double* values, double* distances, int* indexes); diff --git a/src/grib_api.h b/src/grib_api.h index f7688bc50..323fc28a8 100644 --- a/src/grib_api.h +++ b/src/grib_api.h @@ -682,9 +682,9 @@ grib_nearest* grib_nearest_new(const grib_handle* h, int* error); * @param len : size of the arrays * @return 0 if OK, integer value on error */ -int grib_nearest_find(grib_nearest *nearest, const grib_handle* h,double inlat,double inlon, - unsigned long flags,double* outlats,double* outlons, - double* values,double* distances,int* indexes,size_t *len); +int grib_nearest_find(grib_nearest* nearest, const grib_handle* h, double inlat, double inlon, + unsigned long flags, double* outlats, double* outlons, + double* values, double* distances, int* indexes, size_t* len); /** * Frees an nearest from memory @@ -718,10 +718,10 @@ int grib_nearest_delete(grib_nearest *nearest); * @param indexes : returned array of indexes of the nearest points * @return 0 if OK, integer value on error */ -int grib_nearest_find_multiple(const grib_handle* h,int is_lsm, - double* inlats,double* inlons,long npoints, - double* outlats,double* outlons, - double* values,double* distances, int* indexes); +int grib_nearest_find_multiple(const grib_handle* h, int is_lsm, + const double* inlats, const double* inlons, long npoints, + double* outlats, double* outlons, + double* values, double* distances, int* indexes); /* @} */ diff --git a/src/grib_api_prototypes.h b/src/grib_api_prototypes.h index 07efcdc65..726ad40dd 100644 --- a/src/grib_api_prototypes.h +++ b/src/grib_api_prototypes.h @@ -1391,7 +1391,7 @@ int grib_nearest_init(grib_nearest *i, grib_handle *h, grib_arguments *args); int grib_nearest_delete(grib_nearest *i); void grib_binary_search(double xx[], const unsigned long n, double x, int *ju, int *jl); double grib_nearest_distance(double radius, double lon1, double lat1, double lon2, double lat2); -int grib_nearest_find_multiple(const grib_handle *h, int is_lsm, double *inlats, double *inlons, long npoints, double *outlats, double *outlons, double *values, double *distances, int *indexes); +int grib_nearest_find_multiple(const grib_handle *h, int is_lsm, const double *inlats, const double *inlons, long npoints, double *outlats, double *outlons, double *values, double *distances, int *indexes); /* grib_nearest_class.c */ grib_nearest *grib_nearest_factory(grib_handle *h, grib_arguments *args); diff --git a/src/grib_nearest.c b/src/grib_nearest.c index 3d55a72eb..77e90f6a5 100644 --- a/src/grib_nearest.c +++ b/src/grib_nearest.c @@ -129,10 +129,11 @@ double grib_nearest_distance(double radius,double lon1, double lat1, double lon2 return radius*acos(a); } -int grib_nearest_find_multiple(const grib_handle* h,int is_lsm, - double* inlats,double* inlons,long npoints, - double* outlats,double* outlons, - double* values,double* distances, int* indexes) +int grib_nearest_find_multiple( + const grib_handle* h, int is_lsm, + const double* inlats, const double* inlons, long npoints, + double* outlats, double* outlons, + double* values, double* distances, int* indexes) { grib_nearest* nearest=0; double* pdistances=distances; From 51754a218a09d4b45617c3dbdfc39405c6ec7a33 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 15 Oct 2019 10:34:47 +0100 Subject: [PATCH 49/49] Spelling --- examples/C/grib_multi.c | 2 +- examples/deprecated/multi.c | 2 +- examples/deprecated/multi_fortran.F | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/C/grib_multi.c b/examples/C/grib_multi.c index 2c9b3c991..67d19ca58 100644 --- a/examples/C/grib_multi.c +++ b/examples/C/grib_multi.c @@ -14,7 +14,7 @@ * Description: How to decode GRIB messages containing multiple * fields. Try to turn on and off multi support to * see the difference. Default is OFF. - * For all the tools defalut is multi support ON. + * For all the tools default is multi support ON. * */ #include diff --git a/examples/deprecated/multi.c b/examples/deprecated/multi.c index 6eb780fb4..c9171ebc4 100644 --- a/examples/deprecated/multi.c +++ b/examples/deprecated/multi.c @@ -14,7 +14,7 @@ * Description: How to decode grib messages containing multiple * fields. Try to turn on and off multi support to * see the difference. Default is OFF. - * For all the tools defalut is multi support ON. + * For all the tools default is multi support ON. * * * diff --git a/examples/deprecated/multi_fortran.F b/examples/deprecated/multi_fortran.F index 29b363cad..2f143f1c2 100644 --- a/examples/deprecated/multi_fortran.F +++ b/examples/deprecated/multi_fortran.F @@ -13,7 +13,7 @@ C C Description: How to decode grib messages containing multiple C fields. Try to turn on and off multi support to C see the difference. Default is OFF. -C For all the tools defalut is multi support ON. +C For all the tools default is multi support ON. C C C